Limit switch for continuously rotating servo

I’m helping a friend write a script to implement a limit switch for controlling a continuously rotating servo on a meastro 24. I’m a novice to the meastor and having a problem with the script structure. I’m using the fallowing code;

2_Bird_House  # sequence built via the control center
3 4 acceleration   # set the acceleration parameter for servo 4
10 4 speed   # set speed parameter for servo 4
2000 4 servo   # start the servo
wrench_lower_limit_pulse         # sub for detecting the limit switch activation
500 delay   # only want to check the limit switch status every 500 msec
0000 4 servo  # stop the  servo after limit switch is detected
4_worker # sequence built via the control center
sub wrench_lower_limit_pulse # returns 0 if no pulse detected & 1 if pulse detected
17 get_position 500 less_than   # channel 17 has a pullup resister on it copy of example sub

The compiler complains that the stack is empty. If I comment out the while loop everything is OK. I’m entering this query on a Mac and do not have the code listing available - but above is a accurate copy of it. I think wrench_lower_limit_pulse seeds the while loop but apparently this is not the case. Any help would be greatly appreciated


When you use the REPEAT command, there must be a corresponding BEGIN command for the script to go back to. In this case, you will likely want to put that BEGIN command just before the call to wrench_lower_limit_pulse. This will cause the script to go back through the subroutine before reaching the WHILE command.

If you try doing this and it does not fix the problem, can you copy and paste your actual code? Alternatively, you can attach your Maestro settings file.


Thank You for your response. Lack of the Begin was the issue. Looked at it for the longest time and didn’t catch the missing Begin. Thank You again

1 Like