while loop doesn't end
-
-
@mher
What firmware version are you running?
Someone else was having similar issues here
https://forum.duet3d.com/topic/29070/weird-macro-behaviour?_=1668050444951 -
@OwenD
I'm running 3.4.0 currently so maybe there is a issue in there as well.
For now I've worked around it by doing the if check in the while loop which works it's just not that clean. -
@mher that's odd, please try this and tell me if it works for you (it works for me):
while iterations < 4 echo iterations G4 S1
-
@dc42
Yeah I already created a macro like that to perform the same test and it was working as expected.Just did the same for the code you shared just to be sured and again it worked like expected.
-
@OwenD said in while loop doesn't end:
I suspect when the main calls your klicky macro, which in turn calls another, then the local variables in the original are lost.
That shouldn't be the case, but of course there may be bugs in the implementation.
@mher said in while loop doesn't end:
Maybe @Phaedrux or @dc42 can comment about what the limit of the macros is, if there is such a thing and if that could be the cause of the while loop not exiting correctly.
There is a limit of 10 nested stack pushes. A macro call (whether explicit or implicit) counts as a push, so does using M120. Within each stack push there is also a block nesting limit of 10, so while- and if-else bodies can't be nested more than 10 deep.
@mher if you can identify what it is that you are doing in your macro that causes the while-loop to misbehave, I will look into it.
-
As far as I can see really quickly i'm max nesting 5 pushes. However lets say i'm inside a while inside an if statement and I call a macro in this if statement and inside the macro itself there are additional if statements. Do they get counted towards the max bodies deep you can nest? If so that might be an issue
I'm also assuming that there isn't a max of how many macros you can call in 1 macro?
So if i would call M98 30 times in succession it should be fine? -
@mher said in while loop doesn't end:
G1 X{var.centerX - sensors.probes[0].offsets[0]} Y{var.centerY - sensors.probes[0].offsets[1]} F99999
It may be unrelated but...
Just as a matter of interest, what happens when you send a command likeG1 X100 Y100 F99999
?
It will no doubt be restricted by the max speed you set with M203, but if that speed is causing an error condition it may be a factor.I think you're going to have to heavily lace your code with echo commands so you can see where in the scheme of things your issue is appearing.
-
@OwenD As far as I understood it it will execute the command and the speed will be capped at the max you set in the firmware. So max speed for x is currently 10800 (for me atleast). So setting it to F999999 will make sure that when I share this in the vcore3 group (I'm running a vcore3) other people can use it with the speeds they have set on their setup.
I've been adding echo's the thing is that it just seems to fail on the "while iterations" check.
Because I've got it working now by just doing a check inside the while to break the code.I even setup a testing file with a while loop and loading/unloading the probe which works as expected.
-
@dc42
Alright it seems like i figured out what is causing the issue.I created a new macro and started adding things one by one.
Everything went fine until I added this line:G91 G1 H2 Z7 G90 ; Set to relative positioning, move Z up 5mm, change back to absolute positioning
after adding this the while loop kept on running. After removing it everything ran as expected again
EDIT:
just confirmed it by creating the following macro. This would just keep running the while loop infinite.G91 G1 Z5 G90 ;Removed H2 to be sure this wasn't the cause while iterations < 4 echo "iteration: " ^ iterations
Then I split the G91/G90 command from single line to multi line and it started working as expected. So it seems there is an issue with the single line implementation for relative/absolute.
Which I read here we should be able to do the way I did
https://forum.duet3d.com/topic/11662/treat-g90-g91-and-m82-m83-like-g53/3