Quit command not behaving as expected

Hi,
I’m trying to write a script that executes 3 subroutines once and then stops. According to a previous forum post, I put the quit command before the repeat in the loop as this is supposed to make the script run only once. However, this makes only the last subroutine be executed. Any ideas why that is? This is the script:

# vowels
begin
  10 6000 6003 7295 7314 5592 4692
  4946 6453 4476 4692 7491 7138
  7158 5475 7334 6708 0 0 frame_0..17 # /i;/
  10 6473 5651 6258 6806 6238 7099
  6786 4927 3968 5005 6825 6258
  6121 6081 8000 7256 frame_0..15 # /I/
  10 6845 4927 5044 6140 6375 6297
  6512 5279 4379 5533 6023 5572
  5846 7296 6784 frame_0..13_15 # /E/
  quit
repeat

sub frame_0..17
  17 servo
  16 servo
  15 servo
  14 servo
  13 servo
  12 servo
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..15
  15 servo
  14 servo
  13 servo
  12 servo
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

sub frame_0..13_15
  15 servo
  13 servo
  12 servo
  11 servo
  10 servo
  9 servo
  8 servo
  7 servo
  6 servo
  5 servo
  4 servo
  3 servo
  2 servo
  1 servo
  0 servo
  delay
  return

Hello.

That script will run through all three subroutines, but it will not wait for the servos to reach each commanded position before continuing. So I suspect it is happening so fast that you are not able to see any affects from the first two, and are just left with the results of the last one.

With the way the subroutines are written, the first number in the string of numbers before calling the subroutine sets the delay time in milliseconds. In this case, they are all 10, which means the entire script is done in roughly 30ms. Just to verify it is working, you might try changing those to something much larger like 5000, which will cause the Maestro to wait 5 seconds between each subroutine.

Brandon

Hi Brandon,
Thanks for your response, increasing the time did work! How would I change it so that the servos reach each commanded position before continuing please?

The easiest way to do that would be to use the GET_MOVING_STATE command, which returns true if any servos are still moving and false otherwise. However, please note that the Maestro does not have access to the servo’s feedback information, so for this command to work properly, the servo must be limited by speed or acceleration settings (the Maestro essentially compares the target position to the current position it’s commanding). So, if you have non-zero speed or acceleration settings for your servos, you could use a while statement like this after each subroutine to wait for the servos to reach their target position:

begin get_moving_state while
repeat

Additionally, please note that when the Maestro first starts up, it will not have a target for any of the servo channels by default, and the GET_MOVING_STATE will not work correctly since it relies on that information. So, the first time you run the script, it will look like the first subroutine was skipped. You can fix this by either setting starting positions for them in the “Channel Settings” tab, under the “On startup or error” column or by giving them initial positions at the start of your script. Please note that the starting positions must be different from the ones in your first subroutine or the Maestro will think the servo is already there and immediately move on to the next subroutine.

Brandon

Thanks I’ll do that! Is there a maximum number of lines that can be in the script?

The Maestro script is stored on your computer, so there is practically no limit to the number of lines you can have in your script. You can add whitespace and comments without taking up memory on your Maestro. However, each value and command does occupy some of the Maestro’s limited memory. The Micro Maestro has 1 KB available for holding the compiled form of your script, while the Mini Maestros have 8 KB. If the size of your script (which is displayed for you near the top of the “Script” tab) becomes an issue for you, the “Compressing the sequence” subsection of the “Example Scripts” section of the Maestro user’s guide could be helpful.

Brandon