calling globals within macros, bad Idea?
-
@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