Combining routine and Pots control

hi guys,
im using a few maestro controllers for my project (getting closer to 50 servos all together).
im building some robots, in which the servos are controlled by the maestro, and an arduino board responsible for calling the maestro for sequences. the arduino will comunicate with another one on a remote control via Xbee moduls.
now, the remote control will have 2 main features: one is a keypad from which the sequences will be choosen, and potentiometers for direct control of the servos. the idea is to combine direct pot control with sequences for dynamic control.
here is my idea:
if i could create a kind of “enable / disable” switch, that will allow the servo to take part of the routine, and if it dosn’t, to allow it to be controlled by the analog input of the pots.
i hope im clear, and would be very thankful to hear your insights and advice about the best way to get this done.
thanks!
A

Hello,

That is a big project, but it sounds like you have a plan, so I am not sure what kind of help you want. Do you already know how to connect pots, switches, an Xbee, and Maestros to your Arduino? Can you ask something more specific?

-Paul

yes, i had a successful process of controlling each of the elements via Arduino. now the challenge is to combine all…
the main thing im trying to understand:
i will send a call from the arduino to the maestro for running subroutines. but the potentiometers will be set on the arduino and not the maestro (since its a remote control). so i want to be able to work on 2 modes:
mode 1: calling subroutines
mode 2: controlling each servo directly from pot on a remote arduino.

to achieve that, i need to be able to read the analog in value from the maestro. this will happened obviously with serial communication, and then conditioning the analog in values to the servo position (the way it works with arduino).
but if a subroutine is running, the servo get position and speed from the subroutine block of code. how can i create a switching method that will disable the control from the subroutine and get the servo position from the analog in value?
eventually i want to be able to run a subroutine but “pull” some servos out of it for a direct control.
i guess that at the moment im asking for advice of strategy rather then a specific solution.
thanks!

Hello.

You can edit your script so that it doesn’t set the targets of certain servo channels. If you’re using the sequencer in the Maestro Control Center, you can temporarily configure those channels as inputs: then when you copy your sequence to a script, it will not include any code for setting those servos. This could give you multiple versions of the same subroutine, and the only difference would be which servo targets get set. That would be the simplest way to do something similar to what you want, but it sounds like you might want something more general.

If you want something more general, here’s an idea: use an extra channel on your Maestro (configured as a servo or output) that contains some bits that specify which servo channels are currently controlled by the script and which are currently controlled by the subroutine. The Arduino can set the target of this channel with a serial command when it wants to acquire or release a channel. The script will need to be programmed to check the bits in this channel before setting a target, so that it doesn’t set targets for servos that it is not supposed to control. Does this make sense? Do you understand how you would modify your Maestro script to make this work?

–David

Hello,

Have you considered just putting the Arduino in control of all of the servos directly, and not using Maestro scripts? I think you are making this a lot more complicated than necessary.

-Paul

you are right that the arduino is very simple for direct control, but the maestro is so much easier when its about building sequence for many channels and using speed control.
that is the main issue here - how to use the 2 modes togethers (sequencing and direct control).
david’s idea sound intresting, i would apreciate if you could explain more about it, i dont understand how to do it.
thanks!

Hello,

Do you have any specific questions about what David suggested?

-Paul

i have a few, but lets start from basic…
david suggested: “use an extra channel on your Maestro (configured as a servo or output) that contains some bits that specify which servo channels are currently controlled by the script and which are currently controlled by the subroutine”

how do i do that in the script?

I agree with Paul that it would be more elegant to do this in your Arduino. But here’s how you would implement my idea:

  1. Configure your extra channel as a Servo. Set it to have smallest Minimum and largest Maximum possible. Set it to have no speed or acceleration limits.
  2. Your Arduino can set the Target and Position of this channel by sending Set Target commands. The Target value must be at least 256 (64 us) for it to work. Therefore, to do bitwise things properly, you need to add 256 to the number on your Arduino before sending it, and in your script subtract 256 from the number before reading the bits.
  3. Decide which bits will correspond to which servos and what the encoding is. For example, bit 0 can be assigned to servo channel 0, and a value of 0 in that bit means “script control” while a value of 1 in that bit means “Arduino control”.
  4. In your script, instead of just calling the “servo” command to set the target of a servo, you need to write your own function which will read the value of your channel using “get_position”, subtract 256, and use the bits in the resulting number to determine whether or not to call the “servo” command to actually set the value of the servo.

The last step will probably be the hardest for you.

–David

i will try it and let you know how it goes.
thanks so much!
A