How to initialize ADC for PIC18f4620?

1. How to initialize ADC for PIC18f4620?

how to intitialize ADC in PIC18f4620?

i'm planning to make a temperature sensor using lm35.. pls help me.. where do i start..

sorry for my english..

2. Re: How to initialize ADC for PIC18f4620?

You can find a project here: Tahmid's blog: Digital thermometer with LM35 and PIC18F452

There are many temperature sensor circuits here: Tahmid's blog

Using Analog to Digital Converter
http://www.gooligum.com.au/tutorials...C_Mid_A_13.pdf
http://www.gooligum.com.au/tutorials...IC_Mid_C_8.pdf

Hope this helps.
Tahmid.

1 members found this post helpful.

•

3. Re: How to initialize ADC for PIC18f4620?

thank you very much..

ADCON2 = 0x80; what is the meaning of "0x80"?

im using MikroC sir.. PIC18f4620.

4. Re: How to initialize ADC for PIC18f4620?

0x80 means 80 in hexadecimal which is equal to 128 in decimal and 10000000 in binary.

Go to page 227 of the datasheet. There you have the ADCON2 register.
Writing 0x80 means you're commanding the ADC to display readings as right justified. Acquisition time is 0TAD, conversion clock is FOSC/2.

Go through the tutorials above and you should be able to understand everything clearly.

Hope this helps.
Tahmid.

1 members found this post helpful.

•

5. Re: How to initialize ADC for PIC18f4620?

sir can you please check what's wrong with my code?
the problem is i can't get the actual temperature.. for example The value of my LM35 is 31.0C in ISIS, but the output in virtual terminal is 31.2C..
27.0 c = 27.3 c
27.1 c = 27.3 c
27.2 c = 27.3 c
27.3 c = 27.3 c
27.4 c = 27.3 c
27.5 c = 27.8 c

void main() {
int IntegTemp1, IntegTemp2,DeciTemp;
TRISA = 0xFF; // PORTA is input
TRISB = 0x3F; // Pins RB7, RB6 are outputs
TRISD = 0; // PORTD is output
usart_init(9600);
delay_ms(500);

do {
IntegTemp1 = (int) Temp*.01;
IntegTemp2 = (int) Temp*.1 - (IntegTemp1*10);
DeciTemp = (int) Temp*1 - (IntegTemp1*100+(IntegTemp2*10));

usart_write('T');
usart_write('E');
usart_write('M');
usart_write('P');
usart_write('=');
usart_write(IntegTemp1+48);
usart_write(IntegTemp2+48);
usart_write('.');
usart_write(DeciTemp+48);
usart_write(' ');
usart_write('C');
usart_write(13);
usart_write(10);
delay_ms(400);
} while(1);
}

6. Re: How to initialize ADC for PIC18f4620?

This is because, LM35 provides an output with a guaranteed accuracy of 0.5°C. Expecting any better accuracy is useless. So, your reading has to vary by 0.5°C steps, not 0.1°C steps like your program does.

Hope this helps.
Tahmid.

1 members found this post helpful.

7. Re: How to initialize ADC for PIC18f4620?

so if i want better accuracy, i have to change my sensor(LM35)?
can you suggest other sensor for temperature sir...?

8. Re: How to initialize ADC for PIC18f4620?

Yes, you need to change the sensor. I don't know of any sensor IC that accurate. However, you could see if you can find a suitable thermistor. There are some quite accurate ones.

•

Tnx sir.

--[[ ]]--