calling globals within macros, bad Idea?
-
@wayneosdias
sorry let me redo w the commands inline w the macro and not in the console
this is all I see in the eventlog2023-01-25 14:41:05 [info] Event logging started at level warn 2023-01-25 14:41:05 [info] Running: Duet 3 Mini5plus WiFi: 3.4.5 (2022-11-30 19:41:16) 2023-01-25 15:00:51 [info] Event logging stopped 2023-01-25 17:22:07 [info] Event logging started at level debug 2023-01-25 17:22:07 [info] Running: Duet 3 Mini5plus WiFi: 3.4.5 (2022-11-30 19:41:16) 2023-01-25 17:26:53 [info] Event logging stopped 2023-01-25 17:26:53 [info] Event logging started at level debug 2023-01-25 17:26:53 [info] Running: Duet 3 Mini5plus WiFi: 3.4.5 (2022-11-30 19:41:16) 2023-01-25 17:32:11 [info] Event logging stopped 2023-01-25 17:32:11 [info] Event logging started at level debug 2023-01-25 17:32:11 [info] Running: Duet 3 Mini5plus WiFi: 3.4.5 (2022-11-30 19:41:16) 2023-01-25 17:32:40 [info] Event logging stopped
-
@wayneosdias
Are you running just the macro that sets the globals, or the movement one as well?
I was expecting to see G1 commands ETS in the log, but I could be wrong. Haven't tried logging for a while. -
@OwenD Heres what Im running is exactly what Im running
M929 P"eventlogGlobal.txt" S3 ; ;USB_H2_Dispense ;Get head out of way G54 G0 U46 V46 ;Set offset to H2 for the Case G58 M280 P1 S{global.Servo2_90};70; ;1st Point of USB G0 X3.8 Y13.5 G0 V1 ;trigger on G4 P200 G1 V5 F200 ;trigger off G0 X10.5 Y20.7 G0 V1 ;Trigger on G4 P200 G1 X3.8 Y13.5 F600 G1 X10.5 Y20.7 V1.5 G1 X3.8 Y13.5 V2.5 G1 X10.5 Y20.7 V3.5 G1 X3.8 Y13.5 V4.5 G1 X10.5 Y20.7 V5 ;Trigger off G0 V10 M280 P1 S{global.Servo2_180};130; G0 X50 Y14 G0 V1 ;trigger on G4 P200 G1 V5 F200 ;trigger off G0 X44.3 Y22 G0 V1.5 ;trigger on G1 X50 Y14 F600 G1 X43.3 Y22 V1.5 G1 X50 Y14 V2.5 G1 X43.3 Y22 V3.5 G1 X50 Y14 V4.5 G1 X43.3 Y22 V5 ;trigger off G0 V10 M280 P1 S{global.Servo2_135};100; G0 X35.5 Y11.5 G0 V2 ;trigger on G1 X18.5 Y11.5 F600 G1 X35.5 Y11.5 V2.5 G1 X18.5 Y11.5 V3.5 G1 X35.5 Y11.5 V4.5 G1 X18.5 Y11.5 V5 ;trigger off G54 G0 U46 V46 M929 S0 ;
Im executing it via
M98 P"/macros/USB_H2_Dispense"
In the console
-
@wayneosdias
Ok.
I thought debug level gave more than that.
I wasted your time on that one sorry.
The only time I've had the codes appear to execute out of order was when there were errors
Have you got the latest firmware build for the mini 5?
There was an error with an incorrect file a little while back if you didn't use the zip bundleOutside that I'm a bit stumped.
-
@wayneosdias
Heres what Im doing https://youtu.be/FzovkhonvkI
In the vid is correct movment using constants, changing the constants to globals as the above posted macro the 2nd and 3rd rotation trigger 3 movements early. I can take another video, but it wont have tray loaded because it crashes... -
@OwenD
No I think youre right. I have and HC6 in a pick and place machine and debug reports everything... Im not sure why the mini 5 is not... -
@wayneosdias said in calling globals within macros, bad Idea?:
When I use a global for M280 it executes M280 3-4 steps early.
When you don't use a global in the M280 command, the command is put in the deferred command queue and executed after all previous movement commands have completed. When you use a global in the M280 command, it isn't put in the deferred command queue, because the variables you refer to may not be available in that context, and in any case they might change before the command is executed. So the M280 command is executed immediately.
If you put a M400 command before the M280 command, it will wait for motion to complete before the M280 command is executed.
-
@dc42 Yes, M400 resolves the issue. Thank you
-
-
-
@dc42 said in calling globals within macros, bad Idea?:
@wayneosdias said in calling globals within macros, bad Idea?:
When I use a global for M280 it executes M280 3-4 steps early.
When you use a global in the M280 command, it isn't put in the deferred command queue, because the variables you refer to may not be available in that context, and in any case they might change before the command is executed. So the M280 command is executed immediately.
@dc42
That's very interesting.
Are there other command in particular that would behave this way if a global variable was used as one of the parameters? -
@OwenD yes some other commands such as M106 M42 M300 and M150 will behave in this way.
-
@dc42 Hmm, So what is best pratice for the following end use;
I have 2 Servos and 4 selonoid(2ch pos/vac pneumatic control);
;Servos M950 S0 C"io1.out" ;"Servo1" M950 S1 C"io3.out" ;"Servo2" M950 P2 C"out1" ;"Valve_Mstr" M950 P3 C"out2" ;"Valve_Ch_Slct" M950 P3 C"out3" ;"Valve_Ch1_Vac" M950 P3 C"out4" ;"Valve_Ch2_Vac"
Im empirically generating my own tool paths and attempting to trigger timed valve sequences and things gets very confusing/later unreadable using the following syntax;
G1 Xmove Ymove M280 P0 S100; Spin servo1 90deg M42 P2 S1; +Pressurize Ch1. G4 P200 ; Dwell stabilize. G1 Xmove Ymove M42 P4 S1; Retract G4 P200 ; Dwell stabilize. M42 P2 S0; Depressurize.
Since I cant find a way to use/call tool names in gcode created via M563 Im creating globals for literals to replace tool indexes and using in a const manner.
global Servo1=0 global Servo2=1 global Valve_Mstr=2 global Valve_Ch_Slct=3 global Valve_Ch1_Vac=4 global Valve_Ch2_Vac=5
Which is much make macro more readable as;
G1 Xmove Ymove M280 P{global.Servo1} S{global.Servo1_90}; Spin servo1 90deg M42 P{global.Valve_Mstr} S1; +Pressurize. G4 P200 ; Dwell stabilize. G1 Xmove Ymove M42 P{global.Valve_Ch_Slct} S1; Retract G4 P200 ; Dwell stabilize. M42 P{global.Valve_Ch1_Vac} S; Depressurize.
But doing the above every M280 or M42 will require a M400 command preceeding it? Am I going about this completely wrong? What is best practice to accomplish this?
-
@wayneosdias ideally RRF would evaluate all expressions in the command, then put the command in the deferred command queue with those expressions replaced by values. I'll add this to the RRF work list.
-
@dc42 said in calling globals within macros, bad Idea?:
@wayneosdias ideally RRF would evaluate all expressions in the command, then put the command in the deferred command queue with those expressions replaced by values. I'll add this to the RRF work list.
@dc42 - this will be extremely beneficial to our workflow. Has it been captured to implement? Thanks
-
@oozeBot yes it has been captured.
-
-
-
@dc42 wanted to follow-up on this issue to see if it will make 3.5? I couldn't find the issue on github.. Thanks