Easytherm is a tool that helps making curves from a few calibration points for an NTC temperature sensor.
To make the process easier, we
- wrote a tool "propertherm"
- [calibration data] for the most common sensors. 2700_270 and 3000_270 will be the most popular. See factor_notes.txt in the zip for upgrade notes, and hints to select your new curve, based on the reading offset from the traditional tables that are embedded in released firmware. diff=14 means the new table will display +14F (+8C) higher (at certain hightemp/lowtemp point) than the traditional "factory-released" firmware. You'll have to cutnpaste your favorite tables to vems.hex (every time you upgrade)
- that can be applied to vems.hex with patch command,
- or any text-editor (256 bytes of calibration lives in a 16line snippet, easy to change vems.hex)
- probably make propertherm available through a web-form (CGI)
- note that we keep distributing vems.hex with the same calibration data used since long (eg. in 1.0.23): even just 4 MAT and 4 CLT sensor-calibrations would blow up the number of vems.hex combinations x 16 times, which makes no sense: easy to change in vems.hex anyway
The coolant and manifold air temperature sensors are (in 99.9% of cases) NTC type. The ExhaustGasTemp sensor can never be an NTC type.
Easytherm files are located in the files section of the Megasquirt group at http://groups.yahoo.com/ or directly from [msefi.com]
Steps:
- if possible, 3 calibration points must be measured. Say, at sensor temperatures
- 95C warmed engine
- 20C cold engine
- and 0C (a cup of icy water before installing the sensor to the final location)
- Check pullup resistor values, v3.2 has 2.7k resistor instead of 2.49k used in megasquirt. If incorrect pullup value is used, there will be a few degrees error in the lower temperature range.
- .inc file can be generated with easytherm, or other means. This is a very simple function, a few lines.
- note: (AFAIK) MSToolsII can also be used to create .inc files
- but: the upload function in MSToolsII is NOT compatible with GenBoard. GenBoard's has it's own firmware generation and upload procedure. The .inc files need a slight automatic formatting (into .c files) with the following commands, so that they will actually be used in the firmware build process:
- perl bin/inc2tbl NAME-OF-THE-MAT-INC-FILE > etc/airdenfactor.c
- perl bin/inc2tbl NAME-OF-THE-CLT-INC-FILE > etc/thermfactor.c
- See GenBoard/FirmWare for firmware compiling and uploading
Developer TODO - to make some of the above few simple steps automagic:
- add makefile entries, so inc2tbl is automagically run if etc/airdenfactor.inc is newer than etc/airdenfactor.c
- likewise for etc/thermfactor.c
- generate etc/airdenfactor.inc from simple text-based etc/airdenfactor.cal textfile of a few calibration points (containing Celsius => whatever)
- update the above steps to match
Marcell started to write a small utility to make calibration table, in vems.hex snippet form, for engines like MembersPage/NanassyPeter/Status
Marcell found that fitting a 2nd order polynom (parabola) to 3 measured points over the whole temp-range (IIRC this is what easytherm does, I read it a long time ago, but I couldn't download to check) gives very poor fitting to the NTC curve.
The proper way is:
- DONE: use proper NTC calibration data (we found appr 20 points at elfa, and another pdf, see /svn/vems/chipdocs/...). Let's call this NTC_res[]
- DONE: interpolate between these points. If we have 20 datapoints in NTC_res[0] to NTC_res[19] array, we can fit 18 2nd order poly (call it NTC_res_poly[1] to NTC_res_poly[18], index 0 is not used ) around index 1..18 : note that this is a short section, not on the whole curve!
- I solved the equation with parabola.oct (http://www.octave.org program). simulated annealing could also be used (more cpu-clocks but this is a one time operation on PC).
- DONE: blend between neighboring parabolas, for example between NTC_res[3] and NTC_res[4] we blend between NTC_res NTC_res_poly[3] and NTC_res_poly[4]. We call the result ntc_res_blend().
- DONE: the model scales the ntc_res_blend() according to parameters. aref is appr 255, which is the open-circuit (Rntc=inf) adc reading (might be > 255, since it is theoretical). Also, not real (10..11 bit) ADC reading, but truncated to 8 bits.
- DONE: model actually uses $model_nominal_res = $model_param->[0]; and $model_nominal_aref = $model_param->[1];
- DONE: we find model_nominal_res and model_nominal_aref that gives best fitting between user-specified datapoints (simulated annealing makes it possible to use any number of points!) and ntc_res_blend()
- we like the values where sum( err * err) is minimal
- DONE: in simulated_annealing(), updated errsquare to use model() of ntc_res_blend() and sum( err * err )
- DONE: print it in vems.hex form, so any factory vems.hex can be easily changed to contain the new tables (0x100 .. 0x1FF, 0x200..0x2FF, 0x300..0x3FF for the 3 tables: airden, matfactor, thermfactor, check makefile for the exact order)
- DONE: railing, and check output for sanity
developers: /svn/firmware/utilities/propertherm/