Friday, September 17, 2010

Interface of MPXV5100G Pressure transducer with microcontroller


Interface of MPXV5100G Pressure transducer with microcontroller


How to Interface pressure sensor with microcontroller at89s51?

This article will help the reader to solve the above mentioned problem. In this project a microcontroller from 8051 family is used. The source code is written in Keil c51 language (uv3 , micro vision 3). The c-code of the program of the project about pressure interface is also given at the end of this post. The reader is strogly encouraged and suggested to click or check the links available of this page to have more information. For this sponsor links are also some time helping because they point out to relvent ads and materials. All questions and enquires are requested post in comments. I used to check the questions in comments and then answer these. Below is the PIN configuration of pressure sensor "MPXV5100G" used in this project.
Similarly below is the block diagram of sensor which shows its different parts.This is the physical appearance of the pressure transducer.
The MPX5100 series piezo resistive transducer is a state-of-the-art monolithic silicon pressure sensor designed for a wide range of applications, but particularly it is convenient to interface to microcontroller or microprocessor with A/D inputs. This is thin-film metallization, and bipolar processing to provide an accurate, high level analog output signal that is proportional to the applied pressure. More details can be found here MPXV5100 on the datasheet of pressure transducer. This sensor measures differential pressure comparing to atmospheric so when there is no pressure applied it shows 0kPa. It measure pressure between 0kPa to 100kPa.
This is the circuit diagram of the differential pressure monitor.
ADC0804 is used to convert analog voltage produced from differential pressure transducer to digital signal. The analog voltages from 0 to 5v are converted using adc-0804 to digital number from 0 to 255. Then from data-sheet of the differential pressure transducer a formula is developed to convert these values to kpa, so we get a range of 0kPa to 100kPa value. The results are shown on LCD screen, for this an alpha-numeric LCD of 2 line 16 characters (2x16) is used. Below is the full c-code of the project.
//#include (reg51)
sbit lcd_d7 = P2^3;//4 bit connection
sbit lcd_d6 = P2^2;
sbit lcd_d5 = P2^1;
sbit lcd_d4 = P2^0;
sbit lcd_en = P2^4;
sbit lcd_rs = P2^5;
sbit adc_rd = P3^6;
sbit adc_wr = P3^7;
sbit adc_int = P3^5;
unsigned int r,mpr;
unsigned char bt;
unsigned int d =0;
void initializelcd();
void delay(n);
void lcd_send_byte(unsigned char godata,bit w);
void gotoxy(unsigned char x, unsigned char y);
void printlcd(unsigned char *ch);
void display_pressure_on_lcd(unsigned int);
void adc0804_value(void);
void pressure_conversion(unsigned char);
main()
{ delay(1000); initializelcd();
delay(1000); gotoxy(0,0);
delay(1500);
printlcd("Differential P.");
delay(500); //delay(15000);
while(1)
{ adc0804_value();
if(bt!=0) pressure_conversion(bt);
else mpr = 0;
gotoxy(0,1); delay(500);
display_pressure_on_lcd(mpr); printlcd("kPa");
gotoxy(9,1); delay(500);
display_pressure_on_lcd(bt); printlcd("D.#");
delay(9000); delay(9000); } }
void initializelcd(void)
{ delay(16000); lcd_en = 1; lcd_send_byte(0x30,0);
delay(1000); lcd_en = 0; delay(1000);
lcd_en = 1; lcd_send_byte(0x30,0);
delay(1000); lcd_en = 0; delay(1000);
lcd_en = 1; lcd_send_byte(0x30,0);
delay(1000); lcd_en = 0; delay(1000);
lcd_en = 1; lcd_send_byte(0x20,0);
delay(1000); lcd_en = 0; delay(1000);
lcd_en = 1; lcd_send_byte(0x28,0);
delay(500); lcd_send_byte(0x10,0);
delay(500); lcd_send_byte(0x01,0);
delay(500); lcd_send_byte(0x06,0);
delay(500); lcd_send_byte(0x0c,0);
delay(500); lcd_send_byte(0x1c,0);
delay(500); lcd_send_byte(0x01,0);
delay(500); }
void delay(n) int n; { int i; for (i=0;i
void lcd_send_byte(unsigned char godata,bit w)
{ lcd_d4 = 0;lcd_d5 = 0; lcd_d6 = 0;
lcd_d7 = 0; lcd_rs = w; lcd_en=0; delay(2);
lcd_d4 = (( godata & 0x10) == 0x10);
lcd_d5 = (( godata & 0x20) == 0x20);
lcd_d6 = (( godata & 0x40) == 0x40);
lcd_d7 = (( godata & 0x80) == 0x80);
delay(2); lcd_en = 1; delay(2);
lcd_en = 0;
delay(2); lcd_d4 = 0;lcd_d5 = 0;
lcd_d6 = 0;lcd_d7 = 0; lcd_rs = w;
lcd_en=0; delay(2);
lcd_d4 = (( godata & 0x01) == 0x01);
lcd_d5 = (( godata & 0x02) == 0x02);
lcd_d6 = (( godata & 0x04) == 0x04);
lcd_d7 = (( godata & 0x08) == 0x08);
delay(2); lcd_en = 1; delay(2); lcd_en = 0; }
void gotoxy(unsigned char x, unsigned char y)
{ unsigned char c; if (x==0&&y==0) c=0x02;
else
{ c=0x80; c=cx;
if(y==1) c=c0x40; }
lcd_send_byte(c,0); }
void printlcd(unsigned char *ch)
{ while(*ch) { lcd_send_byte(*ch,1); ch++; }}
void display_pressure_on_lcd(unsigned int pt)
{ lcd_send_byte((pt/1000)+48,1);
r=pt%1000;
lcd_send_byte((r/100)+48,1);
r=r%100; printlcd(".");
lcd_send_byte((r/10)+48,1);
lcd_send_byte((r%10)+48,1); }
void adc0804_value(void)
{ adc_wr = 0;
adc_rd = 0;
while(!adc_int);
bt = P1;
adc_wr = 1;
adc_rd = 1; }
void pressure_conversion(unsigned char x)
{
mpr = (((((x+0.3)/255)-0.005)/0.01)*100);
}
8051 Project, 8051 projects,ADC0804,adc0808,adc0809,microcontroller projects, at89c51 projects, 8051 serial port communication

No comments: