Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

display Temp reading on LCD

Status
Not open for further replies.

hhhsssmmm

Member level 1
Joined
May 14, 2009
Messages
37
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,732
hello

I have a PIC18F4220 running @ 20MHz and using C18 compiler.

I have a 20x2 LCD module connected to my PIC and i can successfully display my characters & strings etc out on to the LCD. The LCD is configured for 8bit mode operation....no nibbling!

I now have a temperature sensor module connected to an ADC input on the PIC and wish to display the current temperature reading out on the LCD screen. However, my problem and confusion in displaying the temperature on the LCD is based on how to prepare the software algorithm for displaying. The area of my obstcale and confusion is as follows...

1) "My ADC input (temperature reading) is saved in a 16bit int variable (10bit ADC). The LCD is sent byte size information from the PIC to display the relavent data. So how to transfer the tempurature saved in 16bit ADC variable out on to the LCD?"

2) "Also how to convert the 16bit ADC value (temperature reading) into the relavent scaled tempurature output for LCD display? The temperature reading can be anything such as... '23.4' or '18.0' degrees celcius etc"

Can anyone please suggest an algorithm and if possible show me some web link where such examples have been carried out before?

thank you
Haseeb
 

Regarding Q2, you have to check back the temperature sensor data sheet to know the relation between the temperature and the output voltage. In addition, there should be a mapping between the ADC readings and the input values. This depends on your connections. All in all you have two equations. The first to convert ADC value to the Voltage input. The second to convert the voltage to a temperature value.

Regarding Q1, you should write a utility to convert a numerical value into a string of characters. Finally you will send the string of characters to the LCD.

This is just brainstorming and an initial thought that we can refine together.

--
Amr Ali
www.embedded-tips.blogspot.com
 

Hi,
For conversion, you should check datasheet and then construct the program. If you are using LM35, something like this should do:
Code:
		  ADResult = (ADC_Value * 5000) >> 10;
          value[0] = (ADCResult / 100) % 10;
          value[1] = (ADCResult / 10) % 10;
          value[2] = ADCResult % 10;
          vstring[0] = value[0] + 48;
          vstring[1] = value[1] + 48;
          vstring[2] = value[2] + 48;
Then send vstring to LCD and display output.
Hope this helps.
Tahmid.

Added after 1 minutes:

ADC_Value in the above code stores the 10-bit ADC value.
ADResult must be declared as long, value as an integer array, vstring as a character array.
Tahmid.
 
can anyone give code for showing negative temperature for pic?
 

I assume negative temperature mean you want interface a sensor.
Every sensor got transfer function: Voltage to temperature or resistance to temperature.


By first lines of this code your getting you can see ADC value converted to a voltage 0 - 5 V. ( ADC value * 5000 / 1024 ) (/1024 - >> 10) )

By reading c language manual and your c compiler manual you will find that thing you want to achieve ... pretty easy ;)
 

Hi,
For negative temperature, it would be best you use something like the DS1820 and use the one-wire protocol. I use this with mikroC. Very easy.
Tahmid.

Added after 1 hours 5 minutes:

Or you could use the MCP9700.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top