It is currently 20 Apr 2018 15:30

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: PIC18f4550 gas sensor
PostPosted: 31 Jan 2016 15:14 
Offline

Joined: 31 Jan 2016 14:45
Posts: 7
my code cant detect gas. please help. im using mq6 gas sensor.
:( :( :( :(



void main() {
ADCON1 = 0b00001111; // Configure A/D for digital inputs
ADON_bit = 0;


TRISA = 0xff;
TRISB = 0xff;
TRISC = 0xff;
TRISD = 0;


PORTD=0;

while(1)
{
if(PORTA.RA0)
{
RD0_bit = 1;

}
else
RD0_bit = 0;


}


Top
 Profile  
 
PostPosted: 01 Feb 2016 12:59 
Offline
mikroElektronika team
User avatar

Joined: 11 Mar 2015 12:48
Posts: 1697
Hi,

Can you please tell me which compiler are you using?
Since you posted on the mikroBasic and you have code written in C language.

I suggest you to take a look at the examples which we have for MQ 8 sensor and customize it for your needs:
http://www.libstock.com/projects/view/1 ... ck-example


Best regards,
Aleksandar


Top
 Profile  
 
PostPosted: 02 Feb 2016 13:43 
Offline

Joined: 31 Jan 2016 14:45
Posts: 7
Im using mikro C sir. i bought 3 sensors already coz i thought it might be the sensor but it all didnt work.
i guess its because of this INTCON and CMCON. i dont have enough background about these 2.


Last edited by dscythe on 02 Feb 2016 17:23, edited 1 time in total.

Top
 Profile  
 
PostPosted: 02 Feb 2016 16:41 
Offline

Joined: 31 Jan 2016 14:45
Posts: 7
Sir im now using the code from Libstock(you gave me)
but it seems this fucntion cause the LCD being blank
void calculatePPM() {
double lgPPM;
Vrl = (double)adc_rd * Vadc_5; // For 5V Vcc use Vadc_5 and for 3V Vcc use Vadc_33
Rs = Rl * (5 - Vrl)/Vrl; // Calculate sensor resistance
ratio = Rs/Rl; // Calculate ratio
lgPPM = (log10(ratio) * -0.8)+ 0.9; // Calculate ppm
ppm = pow(10,lgPPM); // Calculate ppm
}


if i delete this function, the lcd can display the "Hydrogen Click".


Top
 Profile  
 
PostPosted: 03 Feb 2016 16:17 
Offline
mikroElektronika team
User avatar

Joined: 11 Mar 2015 12:48
Posts: 1697
Hi,

We will continue our conversation here:
viewtopic.php?f=88&t=66821&p=267650#p267650

Best regards,
Aleksandar


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: