Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

lookuptable help

Status
Not open for further replies.

rems

New Member
How to create a lookup table for NTC temperature sensor to convert Adc values to temperature.
 
How to create a lookup table for NTC temperature sensor to convert Adc values to temperature.

hi,
Which language are you using for your program.?
 
Thanks.Ntc which iam using is different company,it doesnt have a table in its datasheet.can i create table with the one you have mentioned.
 
Eric... Good tool, I didn't see that when I looked in the tools page.

hi Ian,
I created it some time ago, we seemed to go thru a period of heater control threads, got fed up of using my slide rule.:rolleyes:

If you have an idea for a Tool, let me know I could write some Java Script and post it.
 
I need to build Command string from PIC to send to serial port (RS232)
the protocol is <STX> <channelno> temperature <checksum><ETX>.sorry for silly questions as iam very new to this field.
 
setup an array.....

Array[0] = STX // start char
Array[1] = CH; // Channel no
Array[2] = TempHB; // High byte
Array[3] = TempLB; // low byte
Array[4] = CRC; /// CRC = (CH^TempHB^TempB)
Array[5] = ETX; // end char

Then Send each character in turn
Unless you need to do a full CRC...
 
I am interested in a method for temp calc as well.

Using the tool mentioned I can produce an expected thermistor voltage and an adc binary value for each voltage @ a 4 degree step. In a 0 to 80 degree range that's 20 items in a select case statement.

Now while I can determine the closest 4 degree step value < = the thermistor value (say 28 degrees) I need to include the single degree binary step value for that temp range (28 to 32) as an assigned variable in the case statement .With this single degree binary value I can calc the true temp to a single degree accuracy.
That's how I'd approach it in Oshon. Is there a more efficient way?

Here's a code chunk.

Code:
             Case >= 580
			ftemps = 56
			bdegree = 9
			base = 580
		Case >= 542
			ftemps = 60
			bdegree = 9
			base = 542
		Case >= 507
			ftemps = 64
			bdegree = 9
			base = 507
		Case >= 470
			ftemps = 68
			bdegree = 9
			base = 470
		Case >= 434
			ftemps = 72
			bdegree = 9
			base = 470
		Case Else
		ftemps = 80  'TOP TEMP RANGE
		If i > 1000 Then ftemps.7 = True  'MAKE IT VERY -VE
	EndSelect
	bdegree = (i - base) / bdegree  'CALC TEMP CORRECTION
	If ftemps.7 = False Then  'SIGNED INTEGER CHECK
	ftemps = ftemps - bdegree  'IF TEMPS IS +VE DEGREES
	Else
	ftemps = ftemps + bdegree  'IF FTEMPS IS -VE DEGREES.
	signed = True
	Endif
	ftemps.7 = False  'CLEAR SIGN
 
Last edited:
hi,i have created the lookup table using these formulas analog voltage=R1/R1+Rt*Vref
and ADC=1024/VCC*Analog Voltage .Cold anyone tell me how to convert this ADC value to temperature using the Lookup table.Sorry for the silly question.
 
First you need to span your ADC reading to the span of your lookup

If your first ADC reading is 0 and your last is 1023 then you just divide the ADC span to give you an integer number that relates to the lookup

ie.... If you have 12 items in the lookup then divide the ADC reading by 85 (85 * 12 = 1020)

BUT If your ADC readings starts at .... 200 and finishes around 900 ( this is an example ) then your ADC span will be 700...For 12 items the figure would be 58...

So it depends on a) the number of items in the lookup and b) the span of the ADC the pertains to the lookup.
 
how can i calculate the temperature using this.i have got a NTC calculator which shows the temperature by giving the beta value,R25 andresistance.**broken link removed** i get the formula for that.So i can just apply the formula in my program of temperature sensor.i have to set up ADc,read the Adc,convert the Adc to temperature using lookuptable and calibration factors and send them to the PC using RS232/USB could anyone help.
i have started my program ,to setup adc,This is my first program in PIC and C.please help.i didnt understan what are the calibration factors related to lookup table
Void ADCInit()
unsigned int ADCread(unsigned Char ch)
{
if (ch>13) //i have 4 thermistors voltage connected to input of pic16f1937
return 0;
ADCONO=0*00;
ADCONO=(ch<<1); //select ADCchannel
ADCONO=1;//swich on adc module
GODONE=1;//START CONVERSION
While(GODONE); //waiting conversion to finish
ADCONO=0;
return ADRES;
}
void main()
{
ADCinit()
while()
{
unsigned int val;
val=ADCRead (0);//read channel 0
 
Ok first show me your lookup table that you intend to use...

I will try and figure out a formula to get the correct temp... One small detail... The input impedance of the adc is >10kΩ so the smallest temp will be 17°C

You could try to get to zero but that will be over 20kΩ ( you might need to buffer the input ) 100°C is about 400Ω
 
Hi,
i am attaching the datasheet of thermsitor whic iam using and the lookup table.Could you please check my program is correct or not ot set up ADC.I need to convert ADc to temperature using lookup table.is ther any other way to write program for that.
Thanks in Advance
 
Are these calculated values? or have you tested these...

0°C @ 48kΩ input impedance... I doubt the PIC's adc will be stable enough to read this... You will need to buffer this as the impedance is far too high.

Using the same resistor for RT1 and a voltage follower... the results look quite linear (very unusual ) how did you calculate the thermal resistance?



Bear with me here....Eric and I are discussing the PIC's ADC capability.... Back in a mo...

Here is the application PDF for those devices... https://www.electro-tech-online.com/custompdfs/2012/06/PDF_Applicationnotes.pdf

It shows the use of a capacitor on the ADC pin.....

I'll get back to you on the lookup!!!
 
Last edited:
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top