Traumflug / Teacup_Firmware

Firmware for RepRap and other 3D printers
http://forums.reprap.org/read.php?147
GNU General Public License v2.0
310 stars 198 forks source link

Thermistor table generated wrongly #307

Open thomaskilian opened 5 years ago

thomaskilian commented 5 years ago

I can't run the configtool.py on my Mac (no input possible; I don't want to go through that Python version hell to find the wx-issue). Anyhow, I tried to generate the temptable with createTemperatureLookup.py but failed. It creates a 2-dim array like

const uint16_t temptable[NUMTEMPS][2] PROGMEM = { 
// {ADC, temp*4 }, // temp         Rtherm     Vtherm      resolution   power
   {   1,   2433}, //  608.44 C,        2 Ohm, 0.005 V, 118.68 C/count, 0.02mW

etc. So the access fails when trying to access the 3d dimension:

/Users/thomaskilian/Documents/Teacup_Firmware/temp.c: In function 'temp_table_lookup':
/Users/thomaskilian/Documents/Teacup_Firmware/temp.c:175:48: error: subscripted value is neither array nor pointer nor vector
     if (pgm_read_word(&(temptable[table_num][j][0])) >= temp)
                                                ^

Any quick fix for that?

triffid commented 5 years ago

should be

temptable[NUM_THERMISTORS][NUMTEMPS][2] PROGMEM = {
    { // heater 0
        {  1, 2433},
        { ...
        ....
    },
    { // heater 1
        { ...
       ...
    }
    ...
}

I guess since we support multiple temperature inputs, and note you may need to multiply the temperatures by 4 since last I checked, teacup still uses 14.2 fixed point for temperatures.

thomaskilian commented 5 years ago

Seems like that fixed the syntax. I'll see what temps it will spit out now :-) Thanks!

Wurstnase commented 5 years ago

Looks like we need to rework the createTemperatureLookup.py.

Some time ago @phord reworked the part in the config tool. So the table becomes much more accurate for all values.

AnHardt commented 5 years ago

Don't know how the the search for values is done in teacup but maybe it's worth to minimise the amount of values. One could search the turning point and search from there to the ends, for lines not more apart from the ideale funktion than a defined error.

Wurstnase commented 5 years ago

@AnHardt check this thread how Teacup do it with the precalculated temptables. https://github.com/Traumflug/Teacup_Firmware/pull/208#issue-66080498