Programming for tgs 2600 in PIC16F877A

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

Programming for tgs 2600 in PIC16F877A

Postby fyp09 » Sun Feb 07, 2010 5:10 pm

As the question above, my project want to replace ultrasonic port with gas sensor(tgs2600) .So i put PR15 program into PR23 programming PIC16F877A.

if (!sw2) // if button SW2is pressed
{
while(!sw2); // wait until button is released
switch(m) // check what is the current mode, execute the mode
{

case 0 : line_follow(); // mode 1 : line follow
break;
case 1 : wireless_xbee(); // mode 2 : wireless xbee mode
break;
case 2 : analog_sen(); // mode 3 : analog sensor mode
break;
case 3 : gas_sensor(); // mode 4 : gas sensor mode
break;
case 4 : SKPS_PScon(); // mode 5 : PS2 Controller Mode
break;
default : ;

void gas_sensor()
{
unsigned char temp; //declare a temporary variable for reading ADC


lcd_clr();
lcd_goto(0); //set lcd cursor to location 0
send_string("Gas Sensor "); //display "Gas Sensor"
temp=read_ad(0); //read AN0 (Gas Sensor)
lcd_goto(20); //set lcd cursor to location 20
send_num(temp); //display the analog value of the gas sensor
}

unsigned char read_ad(unsigned char channel) //fucntion read analog input according to the given channel
{
unsigned char result; //declare a variable call result

ADGO=1; //start ADC convertion
while(ADGO); //wait for ADC convertion to complete
result=ADRESH; //read the result
return result; //return the result

}





But when i load these code..the gas sensor does not update the value even i put smokes on the sensor...what should i do with the coding.Please help.
fyp09
Newbie
 
Posts: 14
Joined: Mon Dec 07, 2009 11:24 am

Re: Programming for tgs 2600 in PIC16F877A

Postby ober » Sun Feb 21, 2010 12:45 pm

Can you minimize the troubleshooting area? Check the hardware connection, check the voltage output of gas sensor when smoke is there, check your code with ultrasonic which should have some reading, have you compile the code in to hex code? Test each of the area and let us know.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: Programming for tgs 2600 in PIC16F877A

Postby fyp09 » Sat Mar 13, 2010 7:31 pm

May I know how to send the result of the sensor(gas sensor TGS 2600) back to the computer using the PR23 (including xbee). For example the value of the gas sensor is 00160 so i would like the robot send the information to the computer using Xbee.Please help me, thanks :ugeek:
fyp09
Newbie
 
Posts: 14
Joined: Mon Dec 07, 2009 11:24 am

Re: Programming for tgs 2600 in PIC16F877A

Postby ober » Sun Mar 14, 2010 9:24 pm

XBee is just a wireless device, it offers bi-directional wireless communication. The simplest way to use it is to assume it is wireless UART.

So sending your data wirelessly to your computer 1 byte after another, and at your computer, you receive the data from COM port (Serial Port) if you are connecting SKXBee through USB port. Use HyperTerminal to display data receive at computer, and further develop a program to process those data.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to DIY Project Set

Who is online

Users browsing this forum: No registered users and 7 guests

cron