Hi, my name is Adolfo from Mexico and I have been using the micro maestro in a work project.
Everything it’s ok.
I have no mistakes at using a microcontroller to send serial commands to the maestro.
Except when I try to use a certain command:
"Restart Script at Subroutine".
When I send the compact protocol 0xAA,0x00 (I want start at the first subroutine of the script) The script doesn’t work and give me the error code 0x0040 of Stack overflow/underflow.
I read in the guide that “Subroutines used this way should not end with the
RETURN command, since there is no place to return to — instead, they should contain infinite loops or end with a QUIT command.”
I Only want to know what I need to do to start the maestro at the first subroutine using the serial command; I can use the RST pin to start and stop the maestro but I don’t like this way.
Here I leave the scrip that the control center generate when I push the “Copy Sequence to Script” button.
# Sequence 0
500 6218 0 7236 5122 0 6825 frame_0..5 # Frame 0
500 4046 5690 6923 7530 frame_0_2_3_5 # Frame 1
500 6864 6688 6081 7902 frame_0_2_3_5 # Frame 2
500 5005 5181 4516 4692 frame_0_2_3_5 # Frame 3
500 6708 7275 5494 5220 frame_0_2_3_5 # Frame 4
500 4770 frame_0 # Frame 5
And Here I leave the result that give me the button “View compiled code”.
0000: -- # Sequence 0
0000: -- begin
0000: 030EF4014A180000441C02140000A91A80 -- 500 6218 0 7236 5122 0 6825 frame_0..5 # Frame 0
0011: 030AF401CE0F3A160B1B6A1D81 -- 500 4046 5690 6923 7530 frame_0_2_3_5 # Frame 1
001E: 030AF401D01A201AC117DE1E81 -- 500 6864 6688 6081 7902 frame_0_2_3_5 # Frame 2
002B: 030AF4018D133D14A411541281 -- 500 5005 5181 4516 4692 frame_0_2_3_5 # Frame 3
0038: 030AF401341A6B1C7615641481 -- 500 6708 7275 5494 5220 frame_0_2_3_5 # Frame 4
0045: 0304F401A21282 -- 500 4770 frame_0 # Frame 5
004C: 060000 -- repeat
004F: -- sub frame_0..5
004F: 02052A -- 5 servo
0052: 02042A -- 4 servo
0055: 02032A -- 3 servo
0058: 02022A -- 2 servo
005B: 02012A -- 1 servo
005E: 02002A -- 0 servo
0061: 08 -- delay
0062: 05 -- return
0063: -- sub frame_0_2_3_5
0063: 02052A -- 5 servo
0066: 02032A -- 3 servo
0069: 02022A -- 2 servo
006C: 02002A -- 0 servo
006F: 08 -- delay
0070: 05 -- return
0071: -- sub frame_0
0071: 02002A -- 0 servo
0074: 08 -- delay
0075: 05 -- return
Hex Decimal Address Name
00 000 004F FRAME_0..5
01 001 0063 FRAME_0_2_3_5
02 002 0071 FRAME_0
Could somebody help me?
Thank you for including your Maestro script. It looks like what you actually want to do is start the script at the beginning, instead of the first subroutine. In the script you posted, sending the “Restart Script at Subroutine” serial command will start the script at
sub frame_0..5. One easy way to fix this would be to add
sub start before
begin. This would make your first subroutine contain the BEGIN…REPEAT loop.
One way to stop the loop in the script after you send the serial command to start it would be to use the “Stop Script” serial command, which you can find in the “Serial Script Commands” section of the Maestro user’s guide. Alternatively, if you only want the sequence to run once instead of looping, you can add
By the way, I noticed that the command byte you said you were using for “Restart Script at Subroutine” does not match either of the protocols listed in the Maestro user’s guide. The serial bytes for restarting the script at the first subroutine should match one of the following protocols:
Compact protocol: 0xA7, 0x00
Pololu protocol: 0xAA, 0x0C, 0x27, 0x00
Hi Brandon good morning.
I put the
sub start before
begin and the command of “Restart Script at Subroutine” worked successfully. I tried too add a
quit before the
repeat (only for play).
I’m not familiarized with the Pololu’s script, but with your help now I’m able to stop and restart a script with serial commands, and chose the subroutine which I want to start.
Don’t you think that the buttons of
Copy sequence to script and
Copy all sequences to script should put that into the script automatically?.
Anyway, it’s ok, my project works jeje.
Yea jeje sorry the compact protocol was 0xA7,0x00; I made the mistake when I wrote the post.
Now I can understand; a subroutine is a sequence in the script, I thought that a subroutine was a frame, although I didn’t see if this was specified in the guide.
Thanks for everything sr.
It was Piece of cake. Gracias!
I am glad those suggestions helped and you were able to get it working. Thank you for letting us know.
By the way, those lines of the script are not added when you use the “Copy all sequences to script” or “Copy sequence to script” buttons because they are not necessary for the Maestro to run the script as a stand-alone device. In general, these buttons are intended to be used as a broader tool to transition more easily from a sequence to a script.
Exist a serial command that let me control the moment to enable or disable the Pololu Maestro Control Center?
In other words, I want that the user of my project can’t use the Pololu Maestro Control Center all the time, only in a certain moment (I would like control that with my microcontroller).
I don’t know, maybe something like the instruction that the interface use to connect or disconnect with the micro maestro.
Or a serial command that let me control that the micro maestro not follow instructions from the Pololu Maestro Control Center.
There is not a serial command that can enable or disable the use of the Maestro Control Center. That kind of functionality is not a feature of the Maestro Control Center. If you wrote your own software, you could probably do something like that by using a dummy channel on the Maestro to indicate the state of the “lock”. If you are interested in something like that, you might look at the Pololu USB Software Development Kit.
Thanks Brandon, I’ll see that.