interfacing tgs2600 (gas sensor) with pic16f877a

Digital Fiber, Photoelectric, Laser Range, Optical, Temperature, Rotary Encoder, Ultrasonic, Gas, Gyro, Accelerometer, FlexiBend, Flexiforce, Compass......

interfacing tgs2600 (gas sensor) with pic16f877a

Postby yesmylord » Fri Mar 11, 2011 3:50 pm

hello everyone..
I am having a trouble to interfacing gas sensor with pic16f877a.
how to make a code for a program that start a motor when the sensor detect a smoke.
I already modify some of the code that i found at other forum..here is the code that i made..i am using mikroc compiler


void main()
{
ADCON0 = 0xFF;
TRISC.F0=0;
PORTC.F0=0;
TRISC.F1=0;
PORTC.F1=0;
TRISC.F2=0;
PORTC.F2=0;
ADCON0=0b10000001;
ADCON1=0b01000100;

unsigned int temp;
unsigned double val;
unsigned float rs;

void main ()
{

while(1) // create infinite loop
{

temp= ADC_Read(0); // Read from pin RA0
val =(unsigned double)(temp);
rs=((1023*47000/val) -4700;
rs/=1000;
rs=rs/32.8;

if ( rs<0.35)
{
PortC.F0=1; // then RB6 will turn On

}

else if (rs<0.16)
{
PortC.F1=1;
}while(1);
}
} }

any help will ve appriciate..thx
yesmylord
Greenhorn
 
Posts: 2
Joined: Fri Mar 11, 2011 3:43 pm

Re: interfacing tgs2600 (gas sensor) with pic16f877a

Postby hyng » Sat Mar 12, 2011 2:43 pm

Have you try to compile your code? is it successful? Is microc allow decimal points in program? Your project is quite similar to PR11
Temperature Control System Using LM35, analog detection to activate the motor.
User avatar
hyng
Moderator
 
Posts: 292
Joined: Thu Apr 16, 2009 11:35 am

Re: interfacing tgs2600 (gas sensor) with pic16f877a

Postby yesmylord » Mon Mar 14, 2011 1:36 pm

here is my new code..
i already successfully compile the code
but when i testing it with the cigarette smoke ..
the motor doesnt run and one more question..
how do i make a component symbol for tgs2600 for proteus?

unsigned char ch;
unsigned int adc_rd,temp_res;
unsigned double val;
unsigned float rs;
char *text,*text1;
long tlong;
int i,j;

void main() {
TRISD=0;
PORTD=0;
INTCON = 0;
ADCON0=0b10000001; //enable ADC converter module
ADCON1=0b01000100;
Lcd_Config(&PORTB, 4, 5, 6, 3, 2, 1, 0);
LCD_Cmd(LCD_CURSOR_OFF);
LCD_Cmd(LCD_CLEAR);

temp_res = ADC_Read(0); // Read from pin RA0
val =(unsigned double)(temp_res);
rs=((1023*47000/val)-4700);
rs/=1000;
rs=rs/32.8;

for(i=0;i<5;i++){
LCD_Cmd(LCD_CLEAR);
text = "Smoke Magic";
LCD_Out(1,i,text);
Delay_ms(100);
}
text1 = " Clean";
LCD_Out(2,3,text1);
ADCON1 = 0x82;
TRISA = 0xFF;
Delay_ms(1000);
LCD_Cmd(LCD_CLEAR);

text = "Suhu:";
for(j=16;j>0;j--){
LCD_Cmd(LCD_CLEAR);
LCD_Out(1,j,text);
Delay_ms(100);
}

while (1) {
adc_rd = ADC_read(2);

tlong = (long)adc_rd * 5000;
tlong = tlong / 1023 - 40;
ch = tlong / 1000;

if(ch==0)
LCD_Chr(2,6,' ');
else
LCD_Chr(2,6,48+ch);

ch = (tlong / 100) % 10;

LCD_Chr_CP(48+ch);
ch = (tlong / 10) % 10;
LCD_Chr_CP(48+ch);
LCD_Chr_CP('.');

ch = tlong % 10;
LCD_Chr_CP(48+ch);
LCD_Chr_CP('C');
Delay_ms(200);


for(i=1; i<20; i++) {delay_ms(1000);}
PORTD.F2 =1;
PORTD.F1 =1;

for(i=1; i<21; i++) {delay_ms(1000);}
PORTD.F1=0;

for (i=1; i<23; i++) {delay_ms(1000);}
PORTD.F2=0;
i=0;

for ( rs<0.35)
PortD.F7=1;
delay_ms(1000);
PortD.F5=1;

for (rs>0.35)
PortD.F6=1;


} }
yesmylord
Greenhorn
 
Posts: 2
Joined: Fri Mar 11, 2011 3:43 pm

Re: interfacing tgs2600 (gas sensor)

Postby Bridget Tham » Sun Feb 12, 2012 11:21 pm

Hi,

I am using the TGS2600 (gas sensor) that will interface with eZ430-RF2500 kit. Can anyone help me for the calculation to get the gas level such as hydrogen and carbon monoxide? I know I need to get the calculation from the graph in the datasheet. But I have no idea in how to calculate the gas level. Please help.
http://www.ti.com/tool/ez430-rf2500
http://www.cytron.com.my/viewProduct.php?pcode=SN-TGS-2600&name=Air%20Contaminant%20Sensor

And I have found the codes shown in above comment. Could someone explain to me the calculation below? Thanks.

val =(unsigned double)(temp_res);
rs=((1023*47000/val)-4700);
rs/=1000;
rs=rs/32.8;

while (1) {
adc_rd = ADC_read(2);

tlong = (long)adc_rd * 5000;
tlong = tlong / 1023 - 40;
ch = tlong / 1000;
Bridget Tham
Freshie
 
Posts: 4
Joined: Tue Jan 03, 2012 11:51 pm

Re: interfacing tgs2600 (gas sensor) with pic16f877a

Postby melina92 » Sat Dec 07, 2013 7:29 am

dear forum members, can anyone help me how to do the calculation for tgs 2600.. in term of percentage and ppm??
melina92
Fledgling
 
Posts: 1
Joined: Sat Dec 07, 2013 7:14 am

Re: interfacing tgs2600 (gas sensor) with pic16f877a

Postby yonghui » Sun Dec 08, 2013 6:42 pm

i think u can get the information to calculate the required parameter from its datasheet.
thanks&regards,
yh
yonghui
Moderator
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm


Return to Sensor

Who is online

Users browsing this forum: No registered users and 11 guests

cron