Solved 3.5.0 beta 3+, M98: Call Macro/Subprogram in config.g
-
After upgrading to 3.5.0 beta 3 then to 3+, I have noticed that the M98 command in config.g can only be called once. In summary config.g will execute multiple .g files to check whether stated variables exist.
config.g
; Configuration file for ToolChanger 2 Tools (firmware version 3.5.0) ; General preferences M575 P1 S1 B115200 ; enable support for PanelDue G90 ; use absolute coordinates M83 ; use relative extruder moves M550 P"ToolChanger" ; set printer name M669 K1 ; select CoreXY mode ; Wait a moment for the CAN expansion boards to start G4 S2 ; Unselect all Tools T-1 P0 ; Network M552 S1 ; enable network M586 P0 S1 ; enable HTTP M586 P1 S0 ; disable FTP M586 P2 S0 ; disable Telnet ; Drives M569 P0.0 S0 D2 ; X drive map 0.0 (SpreadCycle) M569 P0.1 S0 D2 ; Y drive map 0.1 (SpreadCycle) M569 P0.2 S1 D2 ; Z1 drive map 0.2 (SpreadCycle) M569 P0.3 S1 D2 ; Z2 drive map 0.3 (SpreadCycle) M569 P0.4 S0 D2 ; COUPLER drive map 0.4 (SpreadCycle) M569 P20.0 S1 D2 ; TOOL 0 EXTRUDER drive map 20.0 (SpreadCycle) M569 P21.0 S1 D2 ; TOOL 1 EXTRUDER drive map 20.0 (SpreadCycle) M584 X0.0 Y0.1 Z0.2:0.3 C0.4 E20.0:21.0 ; set drive mapping M350 X16 Y16 C16 E16:16 I1 ; configure XYCE M350 Z16 I1 ; configure Z M92 X80.00 Y80.00 Z1600.00 C91 E335:335 ; set steps per mm M566 X800.00 Y800.00 Z30.00 C2 E3000:3000 ; set maximum instantaneous speed changes (mm/min) M203 X30000.00 Y30000.00 Z800.00 C25000.0 E6000:6000 ; set maximum speeds (mm/min) M201 X3000.00 Y3000.00 Z500.00 C800.00 E5000:5000 ; set accelerations (mm/s^2) M906 X1600 Y1600 Z1200 C450 E1050:1050 I40 ; set motor currents (mA) and motor idle factor in per cent M84 S30 ; Set idle timeout ; Default Pressure Advance M572 D0:1 S0.024 ; Axis Limits M208 X0 Y0 Z0 C0 S1 ; set axis minima M208 X358 Y360 Z340 C280 S0 ; set axis maxima ; Endstops M574 X1 S1 P"io2.in" ; configure switch-type (e.g. microswitch) endstop for low end on X via pin io2.in M574 Y1 S1 P"io3.in" ; configure sensorless endstop for low end on Y M574 Z1 S2 ; configure Z-probe endstop for low end on Z M574 C1 S3 ; C-Axis Sensorless Homing ;M915 C S50 F0 R0 ; Sensors M308 S50 P"20.temp1" Y"thermistor" T100000 B3950 A"Tool 0 Heatsink" ; create a sensor (50) for Tool 0 heatsink temperature M308 S51 P"20.mcu" Y"mcu-temp" A"Tool 0 MCU" ; create a sensor (51) for Tool 0 MCU temperature M308 S52 P"21.temp1" Y"thermistor" T100000 B3950 A"Tool 1 Heatsink" ; create a sensor (52) for Tool 1 heatsink temperature M308 S53 P"21.mcu" Y"mcu-temp" A"Tool 1 MCU" ; create a sensor (53) for Tool 1 MCU temperature M308 S54 P"temp1" Y"thermistor" T100000 B3950 A"Chamber" ; create a sensor (55) for Chamber ; Z-Probe M558 P5 C"^io5.in" H1 F60 T30000 ; set Z probe type to switch and the dive height + speeds G31 P500 X0 Y0 Z1 ; set Z probe trigger value, offset and trigger height M557 X40:318 Y70:340 P7 ; define mesh grid M376 H5 ; set set bed compensation taper to 5mm ; Bed pivot point M671 X-20:378 Y200:200 S10 ; ; Bed Heater M308 S0 P"temp0" Y"thermistor" T100000 B3950 A"Bed Heater" ; configure sensor 0 as thermistor on pin temp0 M950 H0 C"out0" T0 ; create bed heater output on out0 and map it to sensor 0 M140 H0 ; map heated bed to heater 0 M143 H0 S105 ; set temperature limit for heater 0 to 105C ; Tool Heater M308 S1 P"20.temp0" Y"thermistor" T100000 B4725 C7.06e-8 A"Tool 0" ; configure PT1000 as thermistor on pin 20.temp0 M950 H1 C"20.out0" T1 ; create nozzle heater output on 20.out0 and map it to sensor 1 M143 H1 S300 ; set temperature limit for heater 1 to 280C M308 S2 P"21.temp0" Y"thermistor" T100000 B4725 C7.06e-8 A"Tool 1" ; configure sensor 2 as thermistor on pin 21.temp0 M950 H2 C"21.out0" T2 ; create nozzle heater output on 21.out0 and map it to sensor 2 M143 H2 S300 ; set temperature limit for heater 2 to 300C ;M308 S3 P"22.temp0" Y"thermistor" T100000 B4725 C7.06e-8 ; configure sensor 3 as thermistor on pin 22.temp0 ;M950 H3 C"22.out0" T3 ; create nozzle heater output on 22.out0 and map it to sensor 3 ;M307 H3 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit ;M143 H3 S300 ; set temperature limit for heater 3 to 300C ; Chamber Heater ;M308 S5 P"temp1" Y"thermistor" T100000 B3950 A"Heater" ; configure sensor 1 as chamber thermistor ;M950 H5 C"out2" T5 ; create chamber heater output on out4 and map it to sensor 2 ;M141 H5 ; map chamber to heater 2 ;M307 H5 B1 ; bang-bang mode for the chamber heater ;M143 H5 S65 ; set temperature limit for heater 2 to 60C ; Accelerometers M955 P20.0 I10 ; specify orientation of accelerometer on Toolboard 1LC with CAN address 20.0 M955 P21.0 I10 ; specify orientation of accelerometer on Toolboard 1LC with CAN address 21.0 ; Input Shaping Parameters ;M593 P"ei3" F43 S0.05 ; Dock Switches M950 J0 C"20.!^io3.in" ; tool 0 dock switch M950 J1 C"21.!^io3.in" ; tool 1 dock switch ;M950 J2 C"22.!^io3.in" ; tool 2 dock switch ;M950 J3 C"23.!^io3.in" ; tool 3 dock switch ;Chassis Fans M950 F2 C"out4" ; create fan 2 on pin out5 and set its frequency M106 P2 C"Exhaust Fan" S0 H-1 ; set fan 2 value. Thermostatic control is turned off ;Tools Fans M950 F3 C"20.out2+out2.tach" ; tool 0 hotend fan M106 P3 S255 H1 T50 ; tool 0 hotend fan set to thermostatic, turns on at 50C at full speed M950 F4 C"!20.out1+out1.tach" ; tool 0 part cooling fan (PWM) M106 P4 C"T0 Fan" S0 H-1 ; tool 0 part cooling fan M950 F5 C"21.out2+out2.tach" ; tool 1 hotend fan M106 P5 S255 H2 T50 ; tool 1 hotend fan set to thermostatic, turns on at 50C at full speed M950 F6 C"!21.out1+out1.tach" ; tool 1 part cooling fan (PWM) M106 P6 C"T1 Fan" S0 H-1 ; tool 1 part cooling fan ;M950 F7 C"22.out2+out2.tach" ; tool 2 hotend fan ;M106 P7 S255 H3 T50 ; tool 2 hotend fan set to thermostatic, turns on at 50C at full speed ;M950 F8 C"!22.out1+out1.tach" ; tool 2 part cooling fan (PWM) ;M106 P8 C"Tool 2 Fan" S0 H-1 ; tool 2 part cooling fan ;LED M950 F20 C"out5" Q500 ; LED 1 M106 P20 L5 X60 B0 C"LED 1" S0 H-1 ; set LED 1 off on startup M950 F21 C"out6" Q500 ; LED 2 M106 P21 L5 X60 B0 C"LED 2" S0 H-1 ; set LED 2 off on startup ;Buzzer M950 P30 C"out3" Q500 ; configure buzzer ; Tools M563 P0 S"HT-Tool" D0 H1 F3:4 ; define tool 0 G10 P0 X21.4 Y42.5 Z-7.83 ; set tool 0 axis offsets G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C M563 P1 S"STD-Tool" D1 H2 F5:6 ; define tool 1 G10 P1 X22.8 Y42.4 Z-6.43 ; set tool 1 axis offsets [more positive indicates lower nozzle] G10 P1 R0 S0 ; set initial tool 1 active and standby temperatures to 0C ;M563 P2 S"STD-Tool" D2 H4 F7:8 ; define tool 2 ;G10 P2 X23 Y41 Z-5.8 ; set tool 2 axis offsets ;G10 P2 R0 S0 ; set initial tool 2 active and standby temperatures to 0C ; Power Panic M911 S20 R23 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss ; Execute Global Variables global alert = 0 global warning = 0 M98 P"dock-offsets.g" M98 P"tool-cal-temp.g" ; Read from config-overide.g M501 ; System Startup Self-Check M98 P"startup.g"
dock-offsets.g
global dock0_X = 29.775 global dock0_Y = 399.212 global dock1_X = 325.200 global dock1_Y = 398.388
tool-cal-temp.g
global tool0_cal_temp = 190 global tool1_cal_temp = 190
startup.g
; Startup check for 2-tool ToolChanger ; Check for dock variables if exists(global.dock0_X) = false || exists(global.dock0_Y) = false || exists(global.dock1_X) = false || exists(global.dock1_Y) = false M291 P"Dock location unknown, the printer will now run Dock calibration wizard. Click OK to continue." R"Startup Self-Check" S2 M98 P"dock-calibration.g" else echo "Dock variables found." ; Check for tool Z calibration if exists(global.tool0_cal_temp) = false || exists(global.tool1_cal_temp) = false M291 P"Tool Z height is not calibrated, the printer will now run Tool Z Height calibration wizard. Click OK to continue." R"Startup Self-Check" S2 else echo "Tool Z height calibrated." echo "System self-check complete."
During fresh boot, sometimes RRF will execute dock-offsets.g then startup.g skipping tool-cal-temp.g. At other times it will just run dock-offsets.g then ignoring the rest below it. I would like to know is this a intended feature, a bug or there are better ways to do it.
-
@presto i would suggest always creating global variables using an exists check e.g.
if !exists(global.slicerBedTemp) global slicerBedTemp = 0
rather than just creating it.
Rerunning a file that tries to create a global that already exists will create an error -
-
@jay_s_uk Thanks! A simple fix indeed.
-