Welcome! Log In Create A New Profile

Advanced

Problem of generation "temperature lookup table"

Posted by BingDai 
Problem of generation "temperature lookup table"
January 22, 2010 06:54PM
Hello Reprappers,

I am trying to use a thermistor on the extruder. According to the instruction (http://reprapdoc.voodoo.co.nz/bin/view/Main/Temperature_Sensor_2_0), I should use the Python script (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py) to generate a "Temperature Lookup Table" to adjust extruder-related parameters of the firmware.

However, I am having trouble compiling the script.

The error message is attached.

Could you help me with it?

Thanks!


Bing

"// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=10000 --t0=25 --r1=680 --r2=1600 --beta=3947 --max-adc=1023
// r0: 10000
// t0: 25
// r1: 680
// r2: 1600
// beta: 3947
// max adc: 1023
#define NUMTEMPS 20
short temptable[NUMTEMPS][2] = {
{1, 608},
{54, 182},
{107, 138},
{160, 110},
{213, 84},
{266, 52},
Traceback (most recent call last):
File "D:\Program Files\Eclipse\Thermistor\createTemperatureLookup.py", line 126, in
main(sys.argv[1:])
File "D:\Program Files\Eclipse\Thermistor\createTemperatureLookup.py", line 119, in main
print " {%s, %s}," % (adc, int(t.temp(adc)))
File "D:\Program Files\Eclipse\Thermistor\createTemperatureLookup.py", line 52, in temp
return (self.beta / log(r / self.k)) - 273.15 # temperature
ValueError: math domain error
"
Re: Problem of generation "temperature lookup table"
January 23, 2010 03:52AM
It goes wrong because you ran it with the default values, which for some reason do not make sense.

max-adc is 1023 but if you read the comment in the script:

--max-adc=... the max ADC reading to use. if you use R1, it limits the top value for the thermistor circuit, and thus the possible range of ADC values

So it is trying to calculate temperatures for ADC values that are impossible to reach so it gets the log of a negative number.

I have attached a modified script that calculates max_adc itself, based on R1 and R2, so no need to pass it on the command line.

This is what it printed: -
// Thermistor lookup table for RepRap Temperature Sensor Boards (http://make.rrrf.org/ts)
// Made with createTemperatureLookup.py (http://svn.reprap.org/trunk/reprap/firmware/Arduino/utilities/createTemperatureLookup.py)
// ./createTemperatureLookup.py --r0=10000 --t0=25 --r1=680 --r2=1600 --beta=3947 --max-adc=305
// r0: 10000
// t0: 25
// r1: 680
// r2: 1600
// beta: 3947
// max adc: 305
#define NUMTEMPS 19
short temptable[NUMTEMPS][2] = {
   {1, 608},
   {17, 262},
   {33, 215},
   {49, 188},
   {65, 170},
   {81, 156},
   {97, 145},
   {113, 135},
   {129, 126},
   {145, 117},
   {161, 109},
   {177, 102},
   {193, 94},
   {209, 86},
   {225, 78},
   {241, 69},
   {257, 59},
   {273, 47},
   {289, 28}
};

As you can see a 10K thermistor is not a good choice for a 5V system as only uses about 30% of the ADC resolution. Are you actually using these component values? If not you need to pass them on the command line.


[www.hydraraptor.blogspot.com]
Attachments:
open | download - createTemperatureLookup.py (4.8 KB)
Re: Problem of generation "temperature lookup table"
January 25, 2010 08:07PM
The new Python script can be compiled. Thanks nophead!smiling smiley
Re: Problem of generation "temperature lookup table"
January 26, 2010 04:54AM
OK I have updated the version in SVN.


[www.hydraraptor.blogspot.com]
Sorry, only registered users may post in this forum.

Click here to login