Cannot use M291 input as variable in loop
-
@chrishamm,
Yes, I am running the 6Hc in SBC. I will try it next wednesday (possible tuesday) when I get back to work.Indeed I want to break the loop if it input is yes, and if input is yes I want to execute G1and to give the prompt another time.
-
@SanderLPFRG
In addition to what @chrishamm has pointed out, you will need to wait for the moves to complete before showing the next messageG91 ; relative movements G92 Z50 ; set current Z=50 M291 R"Autoload filament" P"Is the right color filament coming out of the nozzle?" S4 K{"yes","no"} ; Display user prompt ; start loop while true if input = "yes" ; If answer is yes --> break ; Filament load successful, so skip to end of loop G1 Z5 F300 ; Move Z by 5mm, normally this would be an extra purge. M400 ; end loop M117 "Filament autoload successful" ; Display success message
-
Hi @chrishamm,
I've tried the code of @OwenD, which adopts the changes you've mentioned, but it does not work..
It looks like the variables are not named the same as the name of the button, if I press "yes" (first button) the 'echo' reported "0" if I pressed "no" (second button) it reported "1".
Therefore it looks like the variables are "0" instead of "yes", and "1" instead of "no".
See;29-3-2023 09:14:18 echo input answer; 1 29-3-2023 09:14:13 M291 R"Autoload filament" P"Is the right color filament coming out of the nozzle?" S4 K{"yes","no"} ; Display user prompt 29-3-2023 09:14:03 echo input answer; 0 29-3-2023 09:13:59 M291 R"Autoload filament" P"Is the right color filament coming out of the nozzle?" S4 K{"yes","no"} ; Display user prompt
Therefore I adapted the code, but it now gives the error;
"Error: in file Macro filament load line 11: cannot convert operands to same type"This is my latest code;
any ideas?G91 ; relative movements G92 Z50 ; set current Z=50 M291 R"Autoload filament" P"Is the right color filament coming out of the nozzle?" S4 K{"yes","no"} ; Display user prompt ; start loop while true if input = "0" ; If answer is yes --> break ; Filament load successful, so skip to end of loop G1 Z5 F300 ; Move Z by 5mm, normally this would be an extra purge. M400 ; end loop M117 "Filament autoload successfull"
I hope to hear from you,
Kind regards,
Sander -
@SanderLPFRG I think @dc42 will have a look at this error message.
-
@SanderLPFRG
The "input" is a pointer to an array
Therefore it will return 0, 1etc (an integer)
In your code you have enclosed it in double quotes so you are comparing against a stringI didn't notice this before
Change it to
if input = 0 ; do stuff
-
@OwenD Also tried that, did not work..
-
@chrishamm Thanks, I'll wait patiently
-
Works for me
; M291 test maacro M291 R"Choose" P"Select yes or no" S4 K{"yes","no",} if input = 0 echo "yes pressed" if input = 1 echo "no pressed" echo input
-
@OwenD
This works for me to. However, I think the loop is causing the issue
Line 11 is the break command, which gives the error -
Your M291 is outside your loop, so the input value isn't going to change.
Try thisG91 ; relative movements G92 Z50 ; set current Z=50 ; start loop while true M291 R"Autoload filament" P"Is the right color filament coming out of the nozzle?" S4 K{"Yes","No",} ; Display user prompt if input = 0 ; If answer is yes --> break ; Filament load successful, so skip to end of loop G1 Z5 F300 ; Move Z by 5mm, normally this would be an extra purge. M400 ; end loop M117 "Filament autoload successfull"
-
@OwenD Damn, this did the trick. Thank you so much owen! also thanks @chrishamm
-
-