NTC Thermistor Thermometer compilation error

Moderator: Benj

Post Reply
User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

NTC Thermistor Thermometer compilation error

Post by stasiks »

Good day need to create a primitive thermometer all materials have already prepared for suspending programming construct again which problem:

Code: Select all

termometrs.c:239: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'char'
termometrs.c: In function 'main':
termometrs.c:803: error: expected expression before '[' token

Taking http://www.matrixmultimedia.com/mmforum ... 26&t=10066 Look-Up Tables Tutorial
In view of that the C language do not understand, I tried myself deal but can not get it.
Here's where Flowchat file and C file
Using ATmega32
Thank
Attachments
termometrs.fcf_avr
Flowchat file
(12 KiB) Downloaded 301 times
termometrs.c
C file
(18.39 KiB) Downloaded 306 times

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by Enamul »

Hi,
Just need to change little bit in supplementary code...
now you are using the following

Code: Select all

#define TEMP_CAL
rom char* TEMP_CAL ={
    -40,-35,-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125};
Replace that with the following...

Code: Select all

ROMARRAY_S TEMP_CAL ROMARRAY_E ={
    -40,-35,-30,-25,-20,-15,-10,-5,0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125};
I have compiled this..seems fine
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Thank the problem was resolved, but the Look-Up Tables do not want to work, showing all sorts of nonsense. :?
I began to think or AVR is no different teams, in help file anything useful unfortunately, did not find :?:

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by Enamul »

Hi,
It might be due to the value you are getting from adc which are not in the look-up table. This look-up table is for definite range of numbers....33 max adc value..which need to be used technically and might need to adjust with the NTC thermistor you are using. If you could post the details about thermistor you are using we probably could adjust the program to show right temperature. :)
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Hello
I understood why this program does not work: ADC value must be one of the values ​​given in my case ADC is divided by the 33th
Problem is that he is using the values ​​given in "25,30,35", but I need "22.5,31,18.8, -6.3" yet i have no clue how to do it.
The problem is that do not understand how to use the Look-Up Tables, here is a calculation file.
Attachments
Temp.xls
Themp
(11.5 KiB) Downloaded 307 times

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

HI,
Please help deal with this thermometer, I diligently read and studied materal I could find on the internet but I did not understand how to correct the NTC Logoritmik curve with LUT. I know that can be connected in parallel with the thermistor resistance as a result will be almost linear curve, but I am more Interests learn programming tricks for the future, to know how to use the LUT and everything related to it

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by Enamul »

Hi,
Sorry I didn't notice that you have posted a nice excel file. I am just looking it right now. I will post the corrected lookup-table asap. Can you please tell me the temperature range you are actually interested in? Because the Look-up table for 255 adc value will not be good one for you rather its better to select a window..
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by Enamul »

Hi,
I have plotted a curve of temp vs resistance using your data and polyfit that using excel to generate the expression of the curve which helps me to generate the values I need to make the Lookup table. I have attached here the excel file and the new code with look up table that should work on your hardware. The range of temperature I have selected is -10 deg to +58 deg. I think this is pretty reasonable.
Hope this will help :)
Attachments
termometrs_v2.fcf_avr
(13.34 KiB) Downloaded 298 times
Temp.xls
(46.5 KiB) Downloaded 284 times
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Hi,
Thank you for your quick reply, and for the work done for me. Are or may be if i ask a lot of questions this project context?
What is very interesting the LUT does not recognise the value of the "-" sign, so had to be think about and got:
sing
sing
Crop-1.jpg (40 KiB) Viewed 11053 times
Another benefit interesting fact of the readings fell below the 10> 9 Then the display is depicted as 90 in order to solve this problem Temp was transformed into a string.
You LUT data value is repeated because their values ​​were very close to each other? Can you tell by simple words to be carried out to get the value by "," and reduce the number of LUTs, know that it is possible for but do not know how by do it.
Thank you very much.

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by Enamul »

Hi,
Sorry..I should notice that your temp variable is byte not int. That's why it can't have -ve value. I have changed that to int...I can't understand why you are using RAM write function and other lcd write options in that way>..Can you please explain that?
Attachments
termometrs_v3.fcf_avr
(13.34 KiB) Downloaded 303 times
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Interestingly, unfortunately I can not home burn in the processor but nothing changed in the simulation, RAM write, I tried it and check how it done,I live in Latvian and Latvian alphabet characters are like "ā, ī, ē,ū, ģ, ķ, š'' is a very pleasing that the device with you contact in native language :lol: . it will be useful in the future. :wink:

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by Enamul »

That's good idea. But not all language alphabets' are available in ascii table.
Enamul
University of Nottingham
enamul4mm@gmail.com

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Here's why there is a need RAM write in ascii table LV language symbol is - so have to build myself. :mrgreen:
How to stays with the thermometer? or can suggest features that would be needed to create a more precise measurement, as they are used and can organize itself to try to divine :D

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Hi,
If someone is interested I found a very good address:http://appnote.avrportal.com/

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

Hi,
Please help with the mathematical side,with this calculator:http://appnote.avrportal.com/calculator/thermistor-ntc calculation each Gard ADC value while bringing the data to appears on the screen permissiveness miracles, that is why I continued to search and found this tutorial in c language: http://home.roboticlab.eu/en/examples/sensor/thermistor and realized that something is missing just do not understand what.

User avatar
stasiks
Posts: 18
Joined: Tue Aug 14, 2012 1:53 am
Contact:

Re: NTC Thermistor Thermometer compilation error

Post by stasiks »

HI,
Well then I have finally programmed thermometer, unfortunately not in the way as they would like, The AVR support logarithm calculations. Using the following formula got a great result:
Support resistance = 10K
NTC thermistor= 10K
NTC*1024=10000*1024=10240000
Temp_K = log ((10240000 / ADC_Temp) - 10000) The calculation logarithmic curve
Temp_K = 1 / (0.0012208921705562318 + (0.00022188369299232732 + (0.0000001145501465461871 * Temp_K) * Temp_K) * Temp_K) Calculate the Temperature K
Temp_C = Temp_K - 273.15 Convert from K>C
Temp_12.fcf_avr
Thermometr
(16 KiB) Downloaded 237 times
Works great, but would like to do the same LUT. I understand if the ADC value is five then receives the value of the fifth

Code: Select all

0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125
result is 25.
Is there any way where the LUT values ​​are compared with I desired and the number of values ​​to be displayed? if the ADC value is 12 then the LTU is found in Table 12, and the value of he is representative of the serial number

Code: Select all

6, 6, 7, 7, 8, 8, 9, 9, 10, 11, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 24, 25, 26, 28, 29, 31, 33, 34, 36, 38, 40, 42, 44, 46, 48, 50, 53, 55, 57, 60, 62, 65, 67, 70, 73, 75, 78, 81, 84, 87, 90, 92, 95, 98, 101, 104, 107, 110
result is 11
Thank.

Post Reply