@gloomyandy said in Possible bug with local variables use in config.g?:
@Mr-Yod Sorry I don't see the full config.g file, just excerpts from it. There may be other parts of the file that are messing with your settings (or possibly causing the config.g to abort early), without seeing the full details it is hard to be sure. It also makes it much easier for anyone trying to reproduce a problem to have the full file.
It's that I usually write a WoT by myself (that few read) to describe the problem, I don't want to overwhelm with other 2 pages of unrelated WoT.
Besides the last row initializes global variables, so I can be quite certain it doesn't abort before reaching the end.
But, if you insist:
Working properly
; General preferences
G90 ; send absolute coordinates...
M83 ; ...but relative extruder moves
M550 P"HevORT" ; set printer name
M669 K1 ; select CoreXY mode
; Network
M552 P192.168.1.3 S1 ; enable network and set IP address
M553 P255.255.255.0 ; set netmask
M554 P192.168.1.1 ; set gateway
M586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0 ; disable Telnet
; Drives
G4 S2 ; wait for expansion boards to start
M671 X-8.86:167.349:343.558 Y-10.411:317.799:-10.411 S50 ; leadscrews at front left, rear middle and front right See https://miragec79.github.io/HevORT/firmwaresettings.html#5-configure-triple-z-axis
M569 P0.0 S1 D2 ; physical drive 0.0 goes forwards Spreadcycle
M569 P0.1 S1 D2 ; physical drive 0.1 goes forwards Spreadcycle
M569 P0.2 S1 D2 ; physical drive 0.2 goes forwards Spreadcycle
M569 P0.3 S1 D2 ; physical drive 0.3 goes forwards Spreadcycle
M569 P0.4 S1 D2 ; physical drive 0.4 goes forwards Spreadcycle
M569 P0.5 S1 D2 ; physical drive 0.5 goes forwards Spreadcycle
M569 P1.0 S1 D2 ; physical drive 1.0 goes forwards Spreadcycle
M569 P1.1 S1 D2 ; physical drive 1.1 goes forwards Spreadcycle
M569 P1.2 S1 D2 ; physical drive 1.2 goes forwards Spreadcycle
M584 X0.0 Y0.1 Z1.0:1.1:1.2 E0.5 ; set drive mapping
M350 X32 Y32 Z16 E16 I1 ; configure microstepping with interpolation
M92 X320.00 Y320.00 Z800.00 E390.00 ; set steps per mm (E409 @ 16 steps, in teoria... forse E390)
M566 X1200.00 Y1200.00 Z30.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
M203 X18000.00 Y18000.00 Z1800.00 E1200.00 ; set maximum speeds (mm/min)
M201 X1600.00 Y1600.00 Z100.00 E250.00 ; set accelerations (mm/s^2)
M906 X1000 Y1000 Z1200 E800 I30 ; set motor currents (mA) and motor idle factor in per cent
M593 F34.2 ; cancel ringing at 34.2Hz
M84 S30 ; Set idle timeout
; Axis Limits
M208 X20 Y-46 Z0 S1 ; set axis minima Y-113
M208 X335 Y335 Z260 S0 ; set axis maxima
; Endstops
M574 X1 S1 P"io0.in" ; configure switch-type (e.g. microswitch) endstop for low end on X via pin io0.in
M574 Y1 S1 P"io1.in" ; configure switch-type (e.g. microswitch) endstop for low end on Y via pin io1.in
M574 Z1 S2 ; configure Z-probe endstop for low end on Z
; Z-Probe
M950 S0 C"io5.out" ; create servo pin 0 for BLTouch
M558 P9 C"io5.in" H10 F500:120 T9000 A3 S0.015 ; set Z probe type to bltouch and the dive height + speeds (primo test veloce + secondo lento), tre test tolleranza 0.015mm
G31 P500 X0 Y-66 Z1.00 ; set Z probe trigger value, offset and trigger height
M557 X20:270 Y20:270 S50 ; define mesh grid
; Heaters
M308 S0 P"temp0" Y"thermistor" T100000 B4138 A"Piatto" ; 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
M307 H0 B0 S1.00 ; disable bang-bang mode for the bed heater and set PWM limit
M140 H0 ; map heated bed to heater 0
M143 H0 S120 ; set temperature limit for heater 0 to 120C
M308 S1 P"temp1" Y"thermistor" T100000 B4725 C7.06e-8 A"Hemera" ; configure sensor 1 as thermistor on pin temp1
M950 H1 C"out1" T1 ; create nozzle heater output on out1 and map it to sensor 1
M307 H1 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
M143 H1 S280 ; set temperature limit for heater 1 to 280C
; Board Sensors
M308 S10 Y"drivers" A"Drivers 6HC" ; configure sensor 10 as 6HC drivers temperature warning and overheat flags
M308 S11 Y"mcu-temp" A"Processore 6HC" ; configure sensor 11 as 6HC on-chip MCU temperature sensor
M308 S12 Y"drivertemp" P"1.dummy" A"Drivers 3HC" ; configure sensor 12 as 3HC drivers temperature warning and overheat flags
M308 S13 Y"mcu-temp" P"1.dummy" A"Processore 3HC" ; configure sensor 13 as 3HC on-chip 3HC MCU temperature sensor
M912 P0 S-3.15 ; calibrate MCU sensor
; Fans
M950 F0 C"out4" Q25000 ; create fan 0 on pin out4 and set its frequency
M106 P0 S1 H1 T45 C"Hemera" ; set fan 0 value. Thermostatic control is turned on
M950 F1 C"out9" Q65535 ; create fan 1 on pin out9 and set its frequency
M106 P1 S0 H-1 C"CPAP" L32 X85 ; set fan 1 value. Thermostatic control is turned off. L0.125 X0.3 (min 12.5% max 30%)
; Tools
M563 P0 S"Hemera" D0 H1 F1 ; define tool 0
G10 P0 X-31.25 Y-34 Z0 ; set tool 0 axis offsets, X-31.25 Y-14.85 in teoria...
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
M563 P2 S"Laser" H2 F-1 ; define tool 2
G10 P2 X0 Y0 Z0 ; set tool 2 axis offsets
G10 P2 R0 S0 ; set initial tool 2 active and standby temperatures to 0C
M563 P5 S"BLTouch" F-1 ; define tool 4
G10 P5 X0 Y-66 Z0 ; set tool 5 axis offsets
G10 P5 R0 S0 ; set initial tool 5 active and standby temperatures to 0C
; Miscellaneous
M501 ; load saved parameters from non-volatile memory
M911 S20 R21 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
T0 ; select first tool
M98 P"0:/macros/GlobalVar.g" ; inizializza le variabili globali
Not working properly
; General preferences
G90 ; send absolute coordinates...
M83 ; ...but relative extruder moves
M550 P"HevORT" ; set printer name
M669 K1 ; select CoreXY mode
; Network
M552 P192.168.1.3 S1 ; enable network and set IP address
M553 P255.255.255.0 ; set netmask
M554 P192.168.1.1 ; set gateway
M586 P0 S1 ; enable HTTP
M586 P1 S0 ; disable FTP
M586 P2 S0 ; disable Telnet
; Drives
G4 S2 ; wait for expansion boards to start
M671 X-8.86:167.349:343.558 Y-10.411:317.799:-10.411 S50 ; leadscrews at front left, rear middle and front right See https://miragec79.github.io/HevORT/firmwaresettings.html#5-configure-triple-z-axis
M569 P0.0 S1 D2 ; physical drive 0.0 goes forwards Spreadcycle
M569 P0.1 S1 D2 ; physical drive 0.1 goes forwards Spreadcycle
M569 P0.2 S1 D2 ; physical drive 0.2 goes forwards Spreadcycle
M569 P0.3 S1 D2 ; physical drive 0.3 goes forwards Spreadcycle
M569 P0.4 S1 D2 ; physical drive 0.4 goes forwards Spreadcycle
M569 P0.5 S1 D2 ; physical drive 0.5 goes forwards Spreadcycle
M569 P1.0 S1 D2 ; physical drive 1.0 goes forwards Spreadcycle
M569 P1.1 S1 D2 ; physical drive 1.1 goes forwards Spreadcycle
M569 P1.2 S1 D2 ; physical drive 1.2 goes forwards Spreadcycle
M584 X0.0 Y0.1 Z1.0:1.1:1.2 E0.5 ; set drive mapping
M350 X32 Y32 Z16 E16 I1 ; configure microstepping with interpolation
M92 X320.00 Y320.00 Z800.00 E390.00 ; set steps per mm (E409 @ 16 steps, in teoria... forse E390)
M566 X1200.00 Y1200.00 Z30.00 E120.00 ; set maximum instantaneous speed changes (mm/min)
M203 X18000.00 Y18000.00 Z1800.00 E1200.00 ; set maximum speeds (mm/min)
M201 X1600.00 Y1600.00 Z100.00 E250.00 ; set accelerations (mm/s^2)
M906 X1000 Y1000 Z1200 E800 I30 ; set motor currents (mA) and motor idle factor in per cent
M593 F34.2 ; cancel ringing at 34.2Hz
M84 S30 ; Set idle timeout
; Axis Limits
M208 X20 Y-46 Z0 S1 ; set axis minima Y-113
M208 X335 Y335 Z260 S0 ; set axis maxima
; Endstops
M574 X1 S1 P"io0.in" ; configure switch-type (e.g. microswitch) endstop for low end on X via pin io0.in
M574 Y1 S1 P"io1.in" ; configure switch-type (e.g. microswitch) endstop for low end on Y via pin io1.in
M574 Z1 S2 ; configure Z-probe endstop for low end on Z
; Z-Probe
var BLoffsetX = 0 ; offset X BLTouch
var BLoffsetY = -66 ; offset Y BLTouch
var BLoffsetZ = 1.00 ; offset Z BLTouch; valore basso per il piatto piรน distante, valore alto per piatto piรน vicino
M950 S0 C"io5.out" ; create servo pin 0 for BLTouch
M558 P9 C"io5.in" H10 F500:120 T9000 A3 S0.015 ; set Z probe type to bltouch and the dive height + speeds (primo test veloce + secondo lento), tre test tolleranza 0.015mm
G31 P500 X{BLoffsetX} Y{BLoffsetY} Z{BLoffsetZ} ; set Z probe trigger value, offset and trigger height
M557 X20:270 Y20:270 S50 ; define mesh grid
; Heaters
M308 S0 P"temp0" Y"thermistor" T100000 B4138 A"Piatto" ; 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
M307 H0 B0 S1.00 ; disable bang-bang mode for the bed heater and set PWM limit
M140 H0 ; map heated bed to heater 0
M143 H0 S120 ; set temperature limit for heater 0 to 120C
M308 S1 P"temp1" Y"thermistor" T100000 B4725 C7.06e-8 A"Hemera" ; configure sensor 1 as thermistor on pin temp1
M950 H1 C"out1" T1 ; create nozzle heater output on out1 and map it to sensor 1
M307 H1 B0 S1.00 ; disable bang-bang mode for heater and set PWM limit
M143 H1 S280 ; set temperature limit for heater 1 to 280C
; Board Sensors
M308 S10 Y"drivers" A"Drivers 6HC" ; configure sensor 10 as 6HC drivers temperature warning and overheat flags
M308 S11 Y"mcu-temp" A"Processore 6HC" ; configure sensor 11 as 6HC on-chip MCU temperature sensor
M308 S12 Y"drivertemp" P"1.dummy" A"Drivers 3HC" ; configure sensor 12 as 3HC drivers temperature warning and overheat flags
M308 S13 Y"mcu-temp" P"1.dummy" A"Processore 3HC" ; configure sensor 13 as 3HC on-chip 3HC MCU temperature sensor
M912 P0 S-3.15 ; calibrate MCU sensor
; Fans
M950 F0 C"out4" Q25000 ; create fan 0 on pin out4 and set its frequency
M106 P0 S1 H1 T45 C"Hemera" ; set fan 0 value. Thermostatic control is turned on
M950 F1 C"out9" Q65535 ; create fan 1 on pin out9 and set its frequency
M106 P1 S0 H-1 C"CPAP" L32 X85 ; set fan 1 value. Thermostatic control is turned off. L0.125 X0.3 (min 12.5% max 30%)
; Tools
M563 P0 S"Hemera" D0 H1 F1 ; define tool 0
G10 P0 X-31.25 Y-34 Z0 ; set tool 0 axis offsets, X-31.25 Y-14.85 in teoria...
G10 P0 R0 S0 ; set initial tool 0 active and standby temperatures to 0C
M563 P2 S"Laser" H2 F-1 ; define tool 2
G10 P2 X0 Y0 Z0 ; set tool 2 axis offsets
G10 P2 R0 S0 ; set initial tool 2 active and standby temperatures to 0C
M563 P5 S"BLTouch" F-1 ; define tool 4
G10 P5 X{BLoffsetX} Y{BLoffsetY} Z{BLoffsetZ} ; set tool 5 axis offsets
G10 P5 R0 S0 ; set initial tool 5 active and standby temperatures to 0C
; Miscellaneous
M501 ; load saved parameters from non-volatile memory
M911 S20 R21 P"M913 X0 Y0 G91 M83 G1 Z3 E-5 F1000" ; set voltage thresholds and actions to run on power loss
T0 ; select first tool
M98 P"0:/macros/GlobalVar.g" ; inizializza le variabili globali
Also please provide the details as to what you are doing to test the probing point, again without that folks can't easily try and reproduce your problem.
You mean "so that I can probe at the center of the bed just by using G1 X150 Y150 (I switch to T5 with T5 P0)"?
var tool = state.currentTool ; salva il tool attivo prima di passare al BLTouch
T0 P0 ; Hemera senza attivare il ToolChange
G1 X150 Y150
T{var.tool} P0 ; riattiva il tool attivo
That's for the Hemera, for BLTouch it's the same, but with T5 P0 instead of T0 P0
var tool = state.currentTool ; salva il tool attivo prima di passare al BLTouch
T{global.BLTouch} P0 ; attiva il BLTouch
G1 X150 Y150
T{var.tool} P0 ; riattiva il tool attivo
global.BLTouch is initialized at 5
Both work no problem (with both config.g, what changes are the coordinates, that are wrong in the second one)
Oh and T0 being at X118.8 Y116 may be correct, that is simply 150 - 31.25 and 150 - 34 which are the tool offsets you have defined in:
G10 P0 X-31.25 Y-34 Z0
Except it's not?
If I go to X150 Y150 with T5, then T0 should be at the difference between the offsets of T5 and T0, not T0 and no tool.
Everything works: when T5 is at X150 Y150, T0 is at X118.8 Y182, and that makes sense (it's the difference between the offsets)
And there's the part "but now when T5 is at X150 Y150 (it's actually not anymore)"
EDIT: modified a copy-paste error