We have a NC Switch connected to input on channel 5, with a 1K pull up resistor connected to 5v . When the button is pressed (switch opens), we see the target value/position change from 0 to 255.
We want the script to run one time, each time the button is pressed.
I moved your post to the “Servo controllers and servos” section of the forum since it seems more appropriate.
It looks like your script is very close to doing what you described, except right now it ends when it reaches the QUIT command, so the Maestro will need to be power cycled or told to restart the script before you can push the button again. Also, it would probably be simpler to use an IF statement instead of a while loop to check your button.
It looks like you could get the whole thing working the way you want by just replacing your WHILE command with an IF command and your QUIT command with ENDIF.
Thanks. With the present code, we could not get the script to run even once, so there may be more here before we get to the quit command
Can you please post edits to the code that I posted with an example of the IF statement implementation. We’ve tried but get no response to the button press.
You are correct; the code in your first post would result in an error because of the way the WHILE command was implemented. The code would exit the WHILE loop and continue on to run your first subroutine, then when it reaches the RETURN statement in that subroutine, it would cause an error. To correctly implement the WHILE loop, you would need to put it inside of another BEGIN/REPEAT loop. This is why I suggested that it would be simpler to use an IF statement, which would only require your code to have a single loop.
If you tried replacing your WHILE command with IF and the QUIT command with ENDIF and it is still not working, could you post a copy of your settings file? You can save your settings file by selecting the “Save settings file” option under the “File” drop-down menu with the Maestro connected. Also, could you describe what happens when you try to run your script (e.g. are you getting any errors and if so which ones)?
Yes, I changed the statements as you suggested, and either we have made an error or there is another underlying issue. No errors, the script just doesn’t execute.
Thank you for posting your settings. I tried loading them onto a Maestro to reproduce your problem, but it seemed to be working fine for me. Are you sure your button is being registered correctly by the Maestro? Can you still see the target slider for channel 5 change from 0 to 255 in the “Status” tab when you press the button? This might sound silly, but are you sure the script is running (e.g. is the “Stop Script” button in the “Script” tab colored red or is it grayed out)?
Yes, The button is being registered in the software. This was checked repeatedly. I did not look to see if the script was stopped before I left the office. It could be that simple, but I don’t think it’s silly. I won’t be back until Tuesday, but I’ll see if I can get someone else to test.
I do know that it was not executing when it was powered up and not connected via USB
We never tried to run the script while the Maestro was connected via USB to the Control Center. I had one of my team connect to the controller to see if we had stopped the script as you suggested.
The issue was that we did not have the option checked for “run at startup”, so when we disconnected USB to run the controller off of the external power supply, the script was not running. He checked that option, applied the settings and then started the controller off of an eternal power supply.