Page 1 of 1

### PR11 - Convert from analog voltage to Celsius

Posted: Thu Sep 20, 2012 5:17 pm
Based on ADC, how to calculate or how to convert from analog voltage to Celsius (digital values) which displayed on the LCD screen? Can you show or any an block diagram of ADC with PIC16F876A?

regards,
Kan

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Fri Sep 21, 2012 4:05 pm
I think this is exactly what you need. Getting Started with SK40C: Project 5

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Fri Sep 21, 2012 10:23 pm
Thank you for given the project 5 of PIC16F877. As according to PR11 project, can you let me know , which part of code for ADC converting from analog voltage to digital voltage?

regards,
Kan

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Sat Sep 22, 2012 1:53 pm
analog channel which ADC reads, ADC will sample n digitize the analog value, dont worry the code to convert analog value to digital, just read the ADC buffer value, it is digital.
after u get the value which adc read, then u can refer the datasheet of the temperature sensor, what is the relation between the voltage reading the temperature. for LM35 it will be linear relation, so just divide or multiply some constant value u get from the datasheet u will get the temperature in celcius.
then display the value to LCD. u will need to convert the value into BCD and to the ascii code. mayb u can directly use some LCD function there.

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Tue Jan 14, 2014 11:51 am
yonghui WROTE:analog channel which ADC reads, ADC will sample n digitize the analog value, dont worry the code to convert analog value to digital, just read the ADC buffer value, it is digital.
after u get the value which adc read, then u can refer the datasheet of the temperature sensor, what is the relation between the voltage reading the temperature. for LM35 it will be linear relation, so just divide or multiply some constant value u get from the datasheet u will get the temperature in celcius.
then display the value to LCD. u will need to convert the value into BCD and to the ascii code. mayb u can directly use some LCD function there.

Can you please let me know how I can see the temperature reading/ADC value of the sensors using the MPlab IDE software? I want to see in real time that these value change as the temperature increase or decrease. For debugging / troubleshooting purposes. Thanks!

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Wed Jan 15, 2014 3:29 pm
putu WROTE:Can you please let me know how I can see the temperature reading/ADC value of the sensors using the MPlab IDE software? I want to see in real time that these value change as the temperature increase or decrease. For debugging / troubleshooting purposes. Thanks!

There are a few methods:
- You can use a debugger to check the value of ADRESH/L register. This method can be done with MPLAB IDE + Debugger (PICkit2, PICkit3, ICD2, or ICD3, UIC00B is compatible with PICkit2). Anyway, you will need to check the User's Manual of specify tools to perform debug.
- You can develop UART function and send the register (ADRES) to computer and display it with any available terminal program such as HyperTerminal, RealTerm, PuTty, etc.
- Yan can add LCD and use some available LCD function to display the value on LCD.

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Wed Jan 15, 2014 10:32 pm
Hi, For PR11, can i change the existing 2x16 LCD to a bigger LCD like a 4 liner? If so, what should be changed in the program code?

### Re: PR11 - Convert from analog voltage to Celsius

Posted: Thu Jan 16, 2014 11:13 am
Yes, you can! Just in case, do check whether the pins are compatible with common use 2x16 parallel LCD. As for library, I guess you need to modify the function to move cursor to 2nd line, 3rd line and also 4th line. The rest should be the same. Try and see.