heat.heaters[1].current reports 2000 in config.g
-
Duet2 wifi
RRF3.3b3I have a global variable that is created in config.g using
global LastTemp = heat.heaters[1].current ; Set variable to current extruder temp.
I note that during config.g the value is always set to 2000 (I sometimes see a spike in the DWC temp graph when resetting as well).
The global is created well after the heaters and tools so I'm a bit confused by this.Subsequently the variable is correctly reported and set during the execution of daemon.g, so I can easily work around it, but I was looking for some clarification as to the timing with regards to heater temps being measured.
It seems like it doesn't happen until after config.gIs there anything else that we should be aware of similar to this?
Config.g
; Configuration file for Duet WiFi (firmware version 3) ; executed by the firmware on start-up ; ; generated by RepRapFirmware Configuration Tool v2.1.4 on Sat Jan 04 2020 09:46:45 GMT+1000 (Australian Eastern Standard Time) ; serial comms / Paneldue M575 P1 B57600 S1 ; General preferences G90 ; send absolute coordinates... M83 ; ...but relative extruder moves M550 P"3Dprinter" ; set printer name ; Network M554 P192.168.1.1 ; set gateway M553 P255.255.255.0 ; set netmask M552 S1 P"DARE" ; enable network M586 P0 S1 ; enable HTTP M586 P1 S1 ; enable FTP M586 P2 S1 ; enable Telnet ; Drives M569 P0 S1 ; physical drive 0 (X) goes forwards M569 P1 S0 ; physical drive 1 (Y) goes backwards M569 P2 S1 ; physical drive 2 (Z) goes forwards M569 P3 S0 ; physical drive 3 (E0) goes backwards M584 X0 Y1 Z2:4 E3 ; two Z motors connected to driver outputs Z and E1 M671 X-74:240 Y79:79 S5.5 ; leadscrews at left (connected to Z) and right (connected to E1) of X axis M350 X16 Y16 Z16 I1 ; Configure microstepping with interpolation for XYZ M350 E16 I1 ; Configure microstepping with interpolation for E0 M92 X100.00 Y100.00 Z400.00 ; set steps per mm XYZ M92 E854 ; set E steps/mm for Titan Aero ; axis settings M98 P"0:/sys/set_max_speeds.g" ; set all the max speeds in macro as these are adjusted during home moves so we only want to adjust in one spot M906 X1100 Y1100 Z1100 E1400 I30 ; set motor currents (mA) and motor idle factor in per cent M84 S30 ; Set idle timeout ; Axis Limits M208 X0:215 Y0:198 Z0:180 ; X carriage moves from 0 to 200, Y bed goes from 0 to 198 ; Endstops M574 X1 S1 P"xstop" ; configure active-high endstop for low end on X via pin xstop M574 Y1 S1 P"ystop" ; configure active-high endstop for low end on Y via pin ystop M574 Z1 S2 ; configure Z-probe endstop for low end on Z ; Z-Probe M950 S0 C"exp.heater3" ; create servo pin 0 for BLTouch ;M558 P9 C"^zprobe.in" H6 F180:60 T2400 A10 S0.03 R0.5 B0 ; set Z probe type to bltouch and the dive height + speeds M558 P9 C"^zprobe.in" H6 F600:180 T2400 A10 S0.03 R0.5 B0 ; set Z probe type to bltouch and the dive height + speeds G31 P500 X27 Y-2 Z0.48 ; set Z probe trigger value, offset and trigger height M557 X30:200 Y10:180 S30 ; define mesh grid ; 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 temp 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 ; Set PID autotune parameters M307 H0 R0.553 C379.7 D21.16 S0.80 B0 V0 M307 H1 R2.354 C140.7:139.6 D7.38 S1.00 V24.3 ;set PID values for heater 1 (hotend) ; Joystick M308 S3 P"exp.thermistor4" Y"linear-analog" A"JoyStick-X" F1 B100 C-100 ; set analog input on E3 Temp with min/max of -100 to 100 M308 S4 P"exp.thermistor6" Y"linear-analog" A"JoyStick-Y" F1 B100 C-100 ; set analog input on E5 Temp with min/max of -100 to 100 M581 T7 P7 ; set up trigger for GpIn 7 M950 J7 C"!^exp.31" ; Input 7 uses Expansion 31 pin activate pullup and inverted ; Servos and input/output M950 P5 C"exp.e5_stop" ; Output 5 uses E5_STOP pin M950 J6 C"exp.e6_stop" ; Input 6 uses E6_STOP pin ; Filament monitor M591 P1 C"e0stop" S1 D0 ; filament monitor for extruder 0 connected to E0 endstop ; Fans M950 F0 C"fan0" Q50 ; create fan 0 on pin fan0 and set its frequency M106 P0 C"Part_Fan" S0 B2.0 H-1 ; set fan 0 name and value. Thermostatic control is turned off ; Adjust MCU temp reading to match ambient ;water pump M950 F1 C"!fan1+^exp.pb6" Q25000 ; create fan 1 (water pump) on inverted pin fan1 and set its frequency. Set RPM to E3 stop with pullup enabled M106 P1 C"Water Pump" H1 L0.5 X1 B1.2 T50:60 ; set fan 1 name and value. Thermostatic control is turned on. Monitoring hoted sensor ; water temp monitor & fan M950 F2 C"!fan2+^exp.e3_stop" Q25000 ; create fan 2 on pin fan2 and set its frequency M308 S5 P"e1temp" Y"thermistor" A"Water temp" T10000 B3950 ; Configure Water temp sensor M106 P2 C"Radiator Fan" H5 L0 X1 B1.2 T33:38 ; set fan 4 value, turn on at 30% if the water temperature reaches 30C, and increase to full speed gradually as the temperature rises to 40C ; MCU temp sensor M308 S2 P"mcu-temp" Y"mcu-temp" A"Duet Board" ; Configure MCU sensor ; Calibrate MCU temp M912 P0 S-4 ; Tools M563 P0 S"Extruder1" D0 H1 F0 ; define tool 0 G10 P0 X0 Y0 Z0 ; set tool 0 axis offsets G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C ; Global Variables global LastCheckTime = 0 ; variable for use in daemon.g global LastTemp = heat.heaters[1].current ; Set variable to current extruder temp. global LoadedFilament = "No_Filament" ; create a filament variable ;Select tool zero T0 P0 ; extrusion if move.extruders[state.currentTool].filament="" echo "No filament loaded. Cold extrude & retract set to defaults" M302 S190 R110 ; Allow extrusion starting from 190°C and retractions already from 110°C (defaults) else set global.LoadedFilament = move.extruders[state.currentTool].filament ; set the variable to the currently loaded filament echo "Loading config for " ^ global.LoadedFilament ^ " filament" M703 ; if a filament is loaded, set all the heats and speeds for it by loading config.g ; Custom settings M376 H4 ; set bed compensation taper (H4 means taper over 4mm) ; Power failure recovery M911 S22.5 R23.0 P"M42 P5 S0 M106 P0 S0 M913 X0 Y0 G91 M83 G1 Z3 E-2 F1000" ; If power drops below 22v then turn off fans, Set X & Y current to zero, raise head, retract. ; turn on LED strip driven by P5 output M42 P5 S1 ;Valve Control test ; Set up scaling variables {(output_end - output_start) / (input_end - input_start)} ;M950 S1 C"exp.heater4" ; assign GPIO port 0 to heater4 on expansion connector, servo mode global InputStart = 0 global InputEnd = 1 global OutputStart = 0 global OutputEnd = 180 global ScaleFactor = (global.OutputEnd - global.OutputStart) / (global.InputEnd - global.InputStart) ; no need for the math in this instance but it makes it clear how you arrive at the value. global ServoOut = floor(global.ScaleFactor * (fans[0].actualValue - global.InputStart) + 0.5) + global.OutputStart ; calculate position required on sevo - use floor() to apply rounding ;M280 P1 S{global.servo_out} ; adjust valve position to reflect fan speed. ;play startup tune G4 S8 ; Allow time for PanelDue to start & wifi connection etc M98 P"0:/macros/songs/itchyscratchy.g" ; Play tune M501 ; load config-overide.g
-
@owend, if the temperature sensor is a thermistor then the filtering software takes a little while to gather enough readings to provide a temperature. I suggest you create your global variable near the end of config.g and use a G4 delay command before it.
-
@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