Calculating average temperature using 2 pt1000 sensors
-
Hello.
I have a large-format COREXY printer, and due to the large bed size, I thought I'd use two PT1000 thermostats to more accurately measure the average surface temperature.
I've tried a number of methods, but haven't found a solution. I get this error:
Error in start-up file macro line 78: Unknown sensor type name "mavg".file config.g
; Configuration file for RepRapFirmware on Duet 3 Main Board 6HC ; executed by the firmware on start-up ; ; generated by RepRapFirmware Configuration Tool v3.5.8 on Thu Jan 09 2025 09:36:34 GMT-0800 (Pacific Standard Time) ; General G90 ; absolute coordinates M83 ; relative extruder moves M550 P"Duet 3" ; set hostname ; Accessories M575 P2 S0 B57600 ; configure PanelDue support ; Network M552 P0.0.0.0 S1 ; configure Ethernet adapter M586 P0 S1 ; configure HTTP ; Wait a moment for the CAN expansion boards to become available G4 S2 ; Accelerometers M955 P121.0 I20 ; configure accelerometer on board #121 ; Kinematics M669 K1 ; configure CoreXY kinematics M98 P"bed_average.g" ; Smart Drivers M569 P0.0 S1 D2 ; driver 0.0 goes forwards (X axis) M569 P0.1 S1 D2 ; driver 0.1 goes forwards (Y axis) M569 P0.2 S1 D2 ; driver 0.2 goes forwards (Z axis) M569 P0.3 S1 D2 ; driver 0.3 goes forwards (Z axis) M569 P0.4 S1 D2 ; driver 0.4 goes forwards (Z axis) M569 P0.5 S1 D2 ; driver 0.5 goes forwards (Z axis) M569 P121.0 S1 D2 ; driver 121.0 goes forwards (extruder 0) ; Motor Idle Current Reduction M906 I30 ; set motor current idle factor M84 S30 ; set motor current idle timeout ; Axes ; Define positions of Z motors M584 X0.0 Y0.1 Z0.2:0.3:0.4:0.5 ; map Z to drivers 0.2, 0.3, 0.4, 0.5 M350 X16 Y16 Z16 I1 ; configure microstepping with interpolation M906 X2500 Y2500 Z2500 ; set axis driver currents M92 X20 Y20 Z6400 ; configure steps per mm M208 X0 Y0 Z0 S1 ; set minimum axis limits M208 X1110 Y1110 Z2005 S0 ; set maximum axis limits M566 X1200 Y1200 Z200 ; set maximum instantaneous speed changes (mm/min) M203 X12000 Y12000 Z300 ; set maximum speeds (mm/min) M201 X1500 Y1500 Z300 ; set accelerations (mm/s^2) M557 X50:1060 Y50:1060 S60 ; define mesh grid for compensation ; Extruders M584 E121.0 ; set extruder mapping M350 E16 I1 ; configure microstepping with interpolation M906 E800 I30; set extruder driver current M92 E420 ; configure steps per mm M566 E120 ; set maximum instantaneous speed changes (mm/min) M203 E3600 ; set maximum speeds (mm/min) M201 E250 ; set accelerations (mm/s^2) ; Probes M558 K0 P9 C"^121.io0.in" H5 F120 T6000 A5 S0.02 ; configure BLTouch probe G31 P500 X0 Y0 Z0.7 ; set Z probe trigger value, offset and trigger height M950 S0 C"121.io0.out" ; create servo for BLtouch ; Endstops M574 X1 P"121.io1.in" S1 ; configure X endstop M574 Y1 P"io0.in" S1 ; configure Y endstop M574 Z1 S2 ; configure Z endstop ; Sensors M308 S1 P"121.temp0" Y"pt1000" A"Nozzle" ; configure nozzle sensor M308 S2 P"temp0" Y"pt1000" A"Heated Bed1" ; configure bed sensor 1 M308 S3 P"temp1" Y"pt1000" A"Heated Bed2" ; configure bed sensor 2 M308 S4 Y"mavg" A"Average Bed Temp" S"1:2" ; حساب المتوسط بين الحساس S1 و S2 ; Heaters M950 H0 C"out1" T4 ; create heater 0 for bed M140 H0 ; assign bed to heater 0 M143 H0 S140 ; configure heater monitor for heater 0 M307 H0 R2.43 D5.5 E1.35 K0.56 B1 ; configure heater model M950 H1 C"121.out0" T1 ; create heater 1 for extruder M143 H1 S285 ; configure heater monitor for heater 1 M307 H1 R2.43 D5.5 E1.35 K0.56 B0 ; configure heater model ; Fans M950 F0 C"121.out1" ; create fan 0 M106 P0 C"Tool Fan" S0 B0.1 H1 T50 ; configure tool fan M950 F1 C"121.out2" ; create fan 1 M106 P1 C"Part Fan" S0 L0 X1 B0.1 ; configure part fan ; Tools M563 P0 S"Tool 0" D0 H1 F0 ; create tool 0 G10 P0 X0 Y0 Z0 ; set tool offsets G10 P0 R0 S0 ; set tool temperatures ; Miscellaneous T0 ; select tool 0 M591 D0 P1 C"121.io2.in" S1 ; custom setting
file calculate_average.g
var temp1 = sensors.analog[2].lastReading var temp2 = sensors.analog[3].lastReading var avgTemp = (var.temp1 + var.temp2) / 2 echo "Bed Temp Average:", var.avgTemp M568 P0 S{var.avgTemp}
-
@meki05 said in Calculating average temperature using 2 pt1000 sensors:
Error in start-up file macro line 78: Unknown sensor type name "mavg".
@meki05 said in Calculating average temperature using 2 pt1000 sensors:
M308 S4 Y"mavg" A"Average Bed Temp" S"1:2"
mavg is not a valid type of sensor for the Y parameter.
https://docs.duet3d.com/en/User_manual/Reference/Gcodes#m308-set-or-report-sensor-parameters
You can create the sensors independently and take the average as you are doing and use that in other calculations, but you can't feed that back into the config as another sensor itself. You'd have to use some custom logic in daemon.g to deal with that average value as needed.
-
@meki05 if you don't want to read those sensors independently then you could connect both in parallel to a single temperature sensor input, and set the R parameter in the M308 command to double the standard value to compensate for that. The standard value is 2200 on Duet 3 boards.