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;
}
PIC18f4550 gas sensor
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: PIC18f4550 gas sensor
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
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
Re: PIC18f4550 gas sensor
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.
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.
Re: PIC18f4550 gas sensor
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.+ 0.9; // Calculate ppm
ppm = pow(10,lgPPM); // Calculate ppm
}
if i delete this function, the lcd can display the "Hydrogen Click".
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.+ 0.9; // Calculate ppm
ppm = pow(10,lgPPM); // Calculate ppm
}
if i delete this function, the lcd can display the "Hydrogen Click".
- Aleksandar.Mitrovic
- mikroElektronika team
- Posts: 1697
- Joined: 11 Mar 2015 12:48
Re: PIC18f4550 gas sensor
Hi,
We will continue our conversation here:
http://www.mikroe.com/forum/viewtopic.p ... 50#p267650
Best regards,
Aleksandar
We will continue our conversation here:
http://www.mikroe.com/forum/viewtopic.p ... 50#p267650
Best regards,
Aleksandar