Having trouble getting a script working on one Maestro 24 to read a potentiometer setting on Channel 2 of a second Maestro 24. They are hooked together TX to RX and RX to TX. They are powered jointly using the servo power and the vsrv=vin jumper. I have set them to run using UART at 9600. The first Maestro is set to the default ID of 12, and the second one at 1.
There is a small script sample at the bottom of this page https://www.pololu.com/docs/0J40/6.c showing setting a servo to a particular position.
I need Get Position on a channel. Don’t see anything that says there is a mini ssc command for that. Trying the pololu protocol. I think the script for testing should be something like:
0x01 0x10 0x02 send_to_maestro13 # device number, get position, channel #
0xAA serial_send_byte serial_send_byte serial_send_byte
Not getting a value back. Expecting the pot value on the stack. What is wrong with the above?
The Maestro scripting feature is not capable of directly reading bytes sent to its serial interface; you can use a script to send bytes out on the Mini Maestro’s TX line (to command other Maestros) but not receive.
It is possible to get your potentiometer’s value from the other Maestro, but I think the easiest and simplest way is to connect your potentiometer to an input channel on both your Maestros.
I have to read about 16 potentiometers total. Since one Maestro only has 12 analog inputs, I am trying to add more by reading from a second Maestro. From what you say, this is not possible using the scripting feature. So the only way to read a value of an analog input is from code running on a Microcontroller or an RPi using the Pololu protocol or the compact protocol?
I do have extra servo channels on each Maestro. What would happen if you connected a servo up to both Maestros but only sent a signal from one at a time? I don’t see a way in script to turn off a servo channel or have it transmit nothing…
No; it is possible (but difficult) to do bidirectional communication between two Maestro scripts if each Maestro is in UART mode and has a dummy channel. The Maestros can set the value of the dummy channel on another Maestro, and set and read the value of their own dummy channel, so you could devise your own protocol to determine if the dummy channel’s value was set by the other Maestro or not. However, if you are already using a Raspberry Pi in your system, it is more sensible to have the Raspberry Pi read and control both your Maestros via serial or USB, and you would not need to use any Maestro scripts.
As for your recent post, you can disable the output of a servo channel by setting the target position to 0 using the Set Target command. However, the channel signal pin would still be driving low, and you probably shouldn’t be shorting two channels together. If you can tell me more about what you are trying to do, I might be able to offer some suggestions.
I think I have already described what I am trying to do.
I have 16 analog inputs connected to potentiometers that bring in a set of parameters, and I have 6 servo channels connected to ESCs driving 6 motors, and 2 servo channels connected to 2 servos, and then 3 buttons (on channels 18, 19 and 20) which essentially time the running of the motors and servos.
I have it working running a script on a Maestro 24, but I am not getting all of the parameters set since I am short the four other analog inputs for the four other potentiometer settings.
The Maestro guide says you can chain the Maestros to get additional channels, but it wasn’t clear that this doesn’t really work through scripting except to send a servo command to the second Maestro.
Adding in an RPi simply to get four potentiometer settings seems a bit much…
So I am now looking for a different way to get all 16 potentiometer settings, and run some simple code that uses those settings to set the speeds on 6 motors, and to position the two servos.
I was referring to your third post, asking for more details on what exactly you were trying to accomplish by having both your Maestros controlling a single servo. You could use an RC servo multiplexer (like this one) to control a servo from both your Maestros without having to worry about shorting two channels together if you think it’ll help. Do you really need to read all 16 potentiometers in order to determine the next target position for each servo? If not, you could try connecting the more important ones to both Maestros without needing to communicate their values between Maestros.
By the way, you could use an Arduino or an Arduino-compatible board like our A-Star 32U4 controllers instead of a Raspberry Pi.
I guess I could use the multiplexer, but it looks like it would take 6 of them since I have 4 RC controlled ESCs, and 2 servos.
What if I control the ESCs and Servos from Maestro #2, and then I send Servo settings from Maestro #1 that alternate with Servo settings from the script on Maestro #2 – can a script still run on both? Can the channels on Maestro #2 be controlled in-turn by a script and then by serial, looping between the two?
It sounds like you are asking if it is possible to alternate between using a script and sending Set Target commands via serial to control a servo channel on one Maestro. If so, then yes. Like I said in my second post, you would need to create some kind of protocol so that the servo’s target position is not being simultaneously set by the script and the other Maestro.