@dc42
Thanks that worked.
For those interested it takes my system about 0.3-0.5 seconds for the thermistor values to stabilize.
Of course as DC42 said, a simple G4 S1 before creating the global variables is sufficient to compensate!
But I was curious how long it took. 🙄
To test I added an echo command immediately after the creation of the heaters and sensors.
; Heaters
M308 S0 P"bedtemp" Y"thermistor" A"Bed" B3950 C7.06e-8 ; configure sensor 0 as thermistor on pin bedtemp
M950 H0 C"bedheat" T0 Q10 ; create bed heater output on bedheat and map it to sensor 0 and set PWM frequency to 10hz
M140 H0 ; Set bed themp to zero
M143 H0 S130 A0 C0 ; set temperature limit for heater 0 to 130C - fault if too high
M308 S1 P"e0temp" Y"thermistor" A"Nozzle-1" B4725 C7.06e-8 ; configure sensor 1 as thermistor on pin e0temp
M950 H1 C"e0heat" T1 ; create nozzle heater output on e0heat and map it to sensor 1
M143 H1 S285 A0 C0 ; set temperature limit for heater 1 to 280C - fault if too high
echo "sensor create time: " ^ state.upTime ^ "." ^ state.msUpTime
Then where I initialise the variables (near the end of config.g) I created a loop until the sensor value <>2000.
On other systems 2000 may be incorrect, but it's what I get.
; Global Variables for heater checking routine in daemon.g
while heat.heaters[1].current = 2000 ; loop until thermistor values are stable
G4 P1
if iterations > 10000 ; if it takes more than 10 seconds we have a problem with the thermistor
M118 P0 L1 S"Thermistor failed to stabilize in less than 10 seconds"
break
echo "sensor stable time: " ^ state.upTime ^ "." ^ state.msUpTime
if !exists(global.LastTemp)
global LastTemp = heat.heaters[1].current ; Set variable to current extruder temp.
else
set global.LastTemp = heat.heaters[1].current ; Set variable to current extruder temp.
if !exists(global.LastCheckTime)
global LastCheckTime = 0 ; variable for use in daemon.g
else
set global.LastCheckTime = 0 ; variable for use in daemon.g
The results show the "elapsed time"
M98 P"0:/sys/config.g"
HTTP is enabled on port 80
FTP is enabled on port 21
TELNET is enabled on port 23
sensor create time: 2805.265
Warning: Heater 0 appears to be over-powered. If left on at full power, its temperature is predicted to reach 234C
sensor stable time: 2805.726
Loading config for ABS filament