Making one Maestro control another

Hello,

…and yes I’m a newbie.

I have been trying to get a Maestro 24 set to all inputs to control another Maestro 24 set to all servos.
The basic idea is to have pots or 3 position switches on all the inputs of one Maestro connected through a wireless UART to control another Maestro with all servos. Hopefully with little lag time. This would make a nice addition to my RC transmitter and receiver that has UART’s built in.

I have been able to get the two boards talking with your Serial Output Example Script through wire but it doesn’t tell me much. The example only sends a command to move one servo back and forth. I need to move all 24 based on the positions of the pots and switches on another board. I tried inserting get_position commands in the script but with no luck.

Is there an easy way to do this? Can you point me to other examples? Making the electrical connections is not a problem. it’s the programming that is twisting my brain.

Any help would be greatly appreciated.

Thanks,

Leonard

Hello, Leonard.

I am sorry you are having problems with your Maestro script. We do not have any examples that do specifically what you mentioned, but you might look at the “Using an analog input to control servos” and “Serial output” examples in the “Example Scripts” section of the Maestro controller’s user’s guide. Understanding those scripts should help you make a script that takes analog inputs and converts them to MiniSSC serial commands. However, please note that only channels 0-11 are capable of being analog inputs; channels 12 and up are digital. Since you are new to the Maestro’s scripting language, I would recommend starting with only one input controlling one servo and building up to more. Also, using the blue “Step Script” button at the bottom of the “Script” tab of the Maestro Control Center is a great way to move through the script at your own pace or troubleshoot potential problems.

If you try writing a script that takes an analog input from one channel and converts it to a serial output and run into problems, you can post what you have so far, and I would be glad to take a look.

-Brandon

Thanks for the suggestions Brandon.

I’ll do the research and get back with a post once I have a rough script put together. I’m surprised there is no example. I would have thought it to be one of the most common uses for this board.

If anyone out there has solved a similar problem please post a comment so I have a head start.

Thanks,

-Leonard

Hi Brandon,

Here is what I have come up with to date. Before I tried a serial connection between two boards I wanted to run a test on one board to make sure the general idea would run as planed. I came up with the following script using the few examples I could find in the users guide. It uses “get_position” commands to get the position of 6 pots, scale the value and place it on the stack. It then uses a subrutine “apples” to set each servo in descending order. Each servo command taking a value off the top of the stack until none are left at which point a return command starts the process over again. Here is the script:

[code]begin
0 get_position #get position of pot #0, place on stack
4 times 4000 plus #scale it to 4000-8092, approximately 1-2 ms

1 get_position #get position of pot #1, place on stack
4 times 4000 plus #scale

2 get_position #get position of pot #2, place on stack
4 times 4000 plus #scale

3 get_position #get position of pot #3, place on stack
4 times 4000 plus #scale

4 get_position #get position of pot #4, place on stack
4 times 4000 plus #scale

5 get_position #get position of pot #5, place on stack
4 times 4000 plus #scale
apples #goto subrutine apples
repeat

sub apples
11 servo #set servo #11 taking number from top of stack
10 servo #set servo #10
9 servo #set servo #9
8 servo #set servo #8
7 servo #set servo #7
6 servo #set servo #6

return #go to the beginning and start over again[/code]

The script runs very smooth. I can turn multiple pots at the same time with no lag or errors. The servos also run very smooth. I don’t see any problem expanding its range to 12 pots and 12 switches controlling 24 servos on a second board.

My next step was to to connect two boards together through their serial UART.
TX on one board to RX on the next. Then RX on the first Board to TX on the second. OK, here is what I came up with. Remember I’m a product designer not a programmer so bear with me. As in the first script the “get_position” command, “times” command and “plus” command gets the pot position scales it and places it on the stack for all 6 pots. Subroutine “mini_ssc” then jumps to my list of servos that are on the second board. As it goes down the list of values another subroutine “send” uses the serial servo command “0xFF” to set target which uses the servo number in the list along with the pot position from the stack. This repeats for each “send” command until there are none left at which point a “return” command starts the process over again from the top. At least that is what I want to happen. It doesn’t quite work. I can step through the script and it flows through each line and appears to function. The servos even move a bit but when I “Run Script” all the servos on the second board just flutter. Here is the script:

[code]100 delay

begin
0 get_position #get position of pot #0 and place on stack
4 times 4000 plus #scale it to 400-8092, approximately 1-2 ms

1 get_position #get position of next pot #1, place on stack
4 times 4000 plus #scale

2 get_position #get position of next pot #2, place on stack
4 times 4000 plus #scale

3 get_position #get position of next pot #3, place on stack
4 times 4000 plus #scale

4 get_position #get position of next pot #4, place on stack
4 times 4000 plus #scale

5 get_position #get position of next pot #5, place on stack
4 times 4000 plus #scale
mini_ssc #goto subroutine mini_ssc
repeat

sub mini_ssc #Subroutine, take servo positions of the top of the stack
5 send #send servo position #5 to through serial UART to Maestro board 2 using ssc command
4 send #send servo position #4
3 send #send servo position #3
2 send #send servo position #2
1 send #send servo position #1
0 send #send servo position #0
return

sub send
0xFF serial_send_byte serial_send_byte serial_send_byte #serial servo command to set target
return[/code]

What am I doing wrong? I feel I’m close. Is it the wrong serial servo command? Am I scaling when i don’t need to?
Please give me an example and don’t send me back to the user guide. The guide is written by programmers for programmers. When you refer a person like me to the users guide its like tying my hands behind my back and dropping me in the ocean. If I’m near the beach I might land on my feet and keep my head above water. Your the lifeguard standing on the shore line with a life preserver/example in one hand. When you send me to the users guide it’s like asking me to go deeper. If the water gets above my head I wont return. If you throw me the life preserver/example I can put it on and make my way to shore. Your guide should be full of examples. It’s what makes Arduino’s so popular, examples everywhere. Give me examples and I can slowly put the pieces together to get to where I need to. After all the ultimate goal of this forum is to teach people how to use Maestro boards so you sell more product. That’s what pays the bills. If I reach my goal I will buy much more of your product to put in mine. Please don’t make it too hard for me the only programming I have had was a little Basic back in the early 80’s. I had to know it to use my first computer which was a TRS80 from Radio Shack. Back when it was an electronic store and not the junk store it is now. But then your probably not old enough to remember that.

Your all doing a great job but stop apologizing and help people by writing more examples.

Thanks,
Leonard

Hello, Leonard.

It looks like your script is very close to working. However, your scaling values are off. The 4000 to 8000 range in your first code works since it is using the SERVO script command, but since your second code uses the Mini-SSC protocol, you should be scaling the values to 0 to 254 instead. The GET_POSITION command should return 0-1023 when used with a channel configured as an analog input, so something like 4 divide might work instead of 4 times 4000 plus.

If your code still gives you the same behavior, you might double check that both boards are set to “UART, fixed baud rate” (and using the same baud rate) under the “Serial Settings” tab of the Maestro Control Center.

Also, the script you have now looks good, but you could make it less repetitive (and save space) by putting commands that are called multiple times into their own subroutine. For example, you could put get_position 4 divide in a subroutine then just specify the channel number when you call this subroutine. It might looks something like:

sub read_and_scale
  get_position
  4 divide
return

With this read_and_scale subroutine, your main BEGIN…REPEAT loop could be simplified to something like:

begin

0 read_and_scale
1 read_and_scale
2 read_and_scale
3 read_and_scale
4 read_and_scale
5 read_and_scale

mini_ssc

repeat

By the way, I understand how having more examples can help. We try to keep the examples in our user’s guides simple and purposeful (e.g. how to make a sequence of servo movements using the servo command), which sometimes means we will not have an example that includes all of the desired functionality for a particular case. The examples in the guide are intended to be used to learn how different commands work with the Maestro scripting language, instead of accomplishing a task. We would love to have many more examples for the Maestro, and (just like Arduino) many sample scripts are user created and can be found by searching this forum. If you cannot find a good example relevant to your project on the forum (like in your case), we are glad to help, and hopefully it can also be used as a sample script for someone else in the future.

-Brandon

Hi Brandon,

Just the type of help I was looking for. I think it might be time for your first book
"Maestro for dummies." In it you can list all the different commands and how to use each to solve a range of different tasks. I would buy it and so would the other 142 people that have already taken a look at this post hoping to walk away with a solution to the task they need to solve.

I will take a good look at the examples you gave me and try to piece it all together. I will also post it here so others can use it.

Thanks,

Leonard