## PR11 - Convert from analog voltage to Celsius

LED Blinking, Walking with Cytron Servo, Displaying RFID, Multi-function Mobile Robot......

### PR11 - Convert from analog voltage to Celsius

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
PHKan

Posts: 4
Joined: Sun Jul 08, 2012 1:36 pm

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

I think this is exactly what you need. Getting Started with SK40C: Project 5
~> How to ask QUESTIONS the SMART way in FORUM? <~

sich

Posts: 603
Joined: Tue Apr 21, 2009 2:15 pm

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

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
PHKan

Posts: 4
Joined: Sun Jul 08, 2012 1:36 pm

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

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.
thanks&regards,
yh
yonghui

Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

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

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!
putu

Posts: 4
Joined: Tue Jan 14, 2014 10:27 am

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

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my

ober

Posts: 1455
Joined: Wed Apr 15, 2009 1:03 pm

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

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?
putu

Posts: 4
Joined: Tue Jan 14, 2014 10:27 am

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

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my

ober

Posts: 1455
Joined: Wed Apr 15, 2009 1:03 pm