PIC18f4550 gas sensor

Beta Testing discussion on mikroBasic PRO for PIC.
Post Reply
Author
Message
dscythe
Posts: 7
Joined: 31 Jan 2016 14:45

PIC18f4550 gas sensor

#1 Post by dscythe » 31 Jan 2016 15:14

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;


}

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: PIC18f4550 gas sensor

#2 Post by Aleksandar.Mitrovic » 01 Feb 2016 12:59

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

dscythe
Posts: 7
Joined: 31 Jan 2016 14:45

Re: PIC18f4550 gas sensor

#3 Post by dscythe » 02 Feb 2016 13:43

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.

dscythe
Posts: 7
Joined: 31 Jan 2016 14:45

Re: PIC18f4550 gas sensor

#4 Post by dscythe » 02 Feb 2016 16:41

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".

User avatar
Aleksandar.Mitrovic
mikroElektronika team
Posts: 1697
Joined: 11 Mar 2015 12:48

Re: PIC18f4550 gas sensor

#5 Post by Aleksandar.Mitrovic » 03 Feb 2016 16:17

Hi,

We will continue our conversation here:
http://www.mikroe.com/forum/viewtopic.p ... 50#p267650

Best regards,
Aleksandar

Post Reply

Return to “mikroBasic PRO for PIC Beta Testing”