___ ( _`\ | ( (_) | |___ | (_, ) (____/'
### ## ### ## # ##### ## ## ## ## #### ###
## ## ## ## ## ## #### ## ## ## ##
_ | | | | | |___ |_____|
#### ## ##### ## ## #####
IMPORTANT: enter the case-INsensitive alphabetic (no numbers) code AND WRITE SOME SHORT summary of changes (below) if you are saving changes. (not required for previewing changes). Wiki-spamming is not tolerated, will be removed, so it does NOT even show up in history. Spammers go away now. Visit Preferences to set your user name Summary of change: '''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" ** ''Is there any doco describing the expected input/file format for propertherm?'' * [http://www.vems.hu/files/Firmware/release/airXfactor.zip calibration data] for the most common NTC 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) * [http://www.vems.hu/files/Firmware/release/ptc_airX_cltfactor.zip PTC tables] With a '''PTC MAT that exactly matches Miska's''' [http://www.vems.hu/files/MembersPage/MiskaPeippo/AudiS6/mat_data.txt Audi PTC MAT] airXfactor_2252_256.hex applies (admittedly, the 2252 is confusing, it means scale up the reference curve's parameters by *2252/2252=1.0 which means to use the reference values directly; Historical reason, see standard NTC curve to understand). Note that min to max range for a PTC is worse than for an NTC, appr. 1/12 of the ADC range is utilized for -40..+101C. This makes it more sensitive to calibration. * 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 [http://www.msefi.com/dload.php?action=category&cat_id=27 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 '''Very important to review the tables before using''' * First check (no matter what tool you use) that the '''tables are monotonous''' increasing / decreasing (whichever applies). * You might want to edit the 0 and 255 line to NOT assume failed sensor. It's often a bad idea (eg. 255 reading does happen with NTC, in very cold near -40C! A guy in sweden almost blew up his engine because of using the default megasquirt table asis, with the 255 adcreading assuming "failed sensor" and 76C). Easy-therm will easily output useless/dangerous tables without warning. Bad enough is that only 3 points are used (propertherm can use any number of points). <code> -40,395 -20,425 0,457 20,490 30,503 40,520 60,555 80,585 100,620 </code> The following 3 picked points: <code> -20,425 0, 457 40, 520 </code> generated non-monotonous tables. The fitted parabola was totally trash for what it was ment. Either use propertherm or make the tables manually. ---- '''PROPERTHERM Developer TODO''' - to make some of the above few simple steps automagic: * note that automatism here might be dangerous. The user should be aware if changing the tables, and he must know what he does/uses (otherwise he might forget when upgrading firmware!!!). Best to check the vems.hex table manually too. * 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 propertherm, a '''utility to make calibration tables'''. Main functions: * '''Best curve fitting''' on user-supplied data (any number of points! Less than 3 points make little sense of course). This is an advanced function, uses simulated annealing. The output is "model parameters", which is aref and ntc resistance when thinking in the NTC model. See ** add_adcread_internal() ** and temp_but_read() for useful functions to specify $measured->{} points * '''Printing output "hex-snippets" to .hex files''' for the given modelparam. Format is originally in vems.hex snippet form, but easy to make it output any desired format. At the same time, useful info is plotted on how the new table differs from $orig_mat_byadc, $orig_mat_bytemp that read_inc() read from an .inc file from standard input. See ** print_factor() can be called for any modelparam (check the double for-cycle that actually calls it). TODO: check for CLT (likely same as MAT, but 03xx addresses used). We 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 * TODO: during simulated annealing, add restrictions for the model parameters, so they cannot deviate too much * '''TODO: drop the adc=0 and 255 special values''' according to GenBoard/UnderDevelopment/FirmwareChanges developers: /svn/firmware/utilities/propertherm/ Optional: Add document to category: Wiki formatting: * is Bullet list ** Bullet list subentry ... '''Bold''', ---- is horizontal ruler, <code> preformatted text... </code> See wiki editing HELP for tables and other formatting tips and tricks.