Maestro

I have configured the 6 ch maestro with a simple sequence to drive 2 servos. Servo1,Servo2. Now would like collect analog input from a Audio source connected to Input1,Input2.
Would like to have: Input1 drive Servo1 and Input2 Drive Servo2

Need the analog signal behavior to drive the Servo clockwise or counter-clockwise bases on the audio signal. Would like to use either amplitude or Passed 100hz frequency of the input audio signal to drive the servo’s rotation.

Hello.

I moved your post to the “Servo controllers and servos” section of the forum since it was more appropriate.

We have an example script for the Maestro to control a servo from an analog input. You can find it under the “Using an analog input to control servos” heading of the “Example Scripts” section of the Maestro user’s guide. You should be able to essentially duplicate lines 3-5 of that code and change the channel numbers to add the second analog input and servo pair.

Please note that the Maestro can read a 0-5V analog input, but it would not be practical to measure the frequency input signals using a Maestro.

Brandon

input will be the ch use, now l and r stereo get connected to chan signal pin and ground from stereo goes to grd of chn correct. I did that but input was showing a rapid voltage display so i was unable to determine upper and lower limit for the script

It sounds like you might be using some kind of raw audio signal and the Maestro is reading it correctly. If you want to turn the signal into some kind of smooth movements, you might need to do some additional processing to it.

Brandon

Great Idea. I added an audio amplifier but think you may mean some sort of audio signal processor. Any suggestions?
Thanks
Joe

In modular synthesis there’s something called an “envelope follower”. It outputs a varying DC signal that reflects the instantaneous volume of the audio signal. You can search for example circuits. Just make sure the output range matches the 0 - 5V limit of the Maestro–most synth circuits output 0 - 10V.

The below works to control 1 servo What is needed(Script,sequence, complied code to have the input control 4 servo?
I’m using the hysteresis code provided by Pololu.

Script

# Set the servo to 4000, 6000, or 8000 depending on an analog input, with hysteresis.
begin
  4000 0 433 servo_range
  6000 0 433 servo_range
  8000 0 433 servo_range
repeat
 
# usage: <pos> <low> <high> servo_range
# If the pot is in the range specified by low and high,
# keeps servo 0 at pos until the pot moves out of this
# range, with hysteresis.
sub servo_range
  pot 2 pick less_than logical_not    # >= low
  pot 2 pick greater_than logical_not # <= high
  logical_and
  if
    begin
      pot 2 pick 10 minus less_than logical_not   # >= low - 10
      pot 2 pick 10 plus greater_than logical_not # <= high + 10
      logical_and
    while
      2 pick 0 servo

    repeat
  endif
  drop drop drop
  return
 
sub pot
  1 get_position
  return

Compiled Code

000:                      -- # Set the servo to 4000, 6000, or 8000 depending on an analog input, with hysteresis.
0000:                      -- begin
0000: 0306A00F0000B10180   --   4000 0 433 servo_range
0009: 030670170000B10180   --   6000 0 433 servo_range
0012: 0306401F0000B10180   --   8000 0 433 servo_range
001B: 060000               -- repeat
001E:                      --  
001E:                      -- # usage: <pos> <low> <high> servo_range
001E:                      -- # If the pot is in the range specified by low and high,
001E:                      -- # keeps servo 0 at pos until the pot moves out of this
001E:                      -- # range, with hysteresis.
001E:                      -- sub servo_range
001E: 8102020E2818         --   pot 2 pick less_than logical_not    # >= low
0024: 8102020E2918         --   pot 2 pick greater_than logical_not # <= high
002A: 19                   --   logical_and
002B: 074D00               --   if
002E:                      --     begin
002E: 8102020E020A1D2818   --       pot 2 pick 10 minus less_than logical_not   # >= low - 10
0037: 8102020E020A1C2918   --       pot 2 pick 10 plus greater_than logical_not # <= high + 10
0040: 19                   --       logical_and
0041: 074D00               --     while
0044: 02020E02002A         --       2 pick 0 servo
004A:                      --
004A: 062E00               --     repeat
004D:                      --   endif
004D: 0B0B0B               --   drop drop drop
0050: 05                   --   return
0051:                      --  
0051:                      -- sub pot
0051: 02012E               --   1 get_position
0054: 05                   --   return

Subroutines:
Hex Decimal Address Name
00  000     001E    SERVO_RANGE
01  001     0051    POT

Channel Settings
image.png

Status 10 second video attached

If you want to send the same signals to all 4 servos, you could use splitter cables to connect them all to the same Maestro channel. If you want them to have their own connection to the Maestro, you can modify your while loop to duplicate the target position value in your script and set all of the servos to that value, like this:

    while
      2 pick dup 0 servo #add 'dup' here to duplicate the target position before setting servo channel 1

      dup 2 servo #duplicate the target value and set servo channel 2 to the same position
      dup 3 servo #duplicate the target value and set servo channel 3 to the same position
      4 servo #set servo channel 4 to the duplicated position

    repeat

I noticed you emailed about this as well and it sounded like you had some sort of robot with 2 servos on each side. If that is the case, you might need to remap the target position to invert the motion before sending it to the 2 servos on the opposite side.

Brandon

Brandon See below code after the ## . Will this code work where 1 analog input controls all 4 wheels on a RC Truck. Its ok if front and back move up and down together

# Set the servo to 4000, 6000, or 8000 depending on an analog input, with hysteresis.
begin
  4000 0 433 servo_range
  6000 0 433 servo_range
  8000 0 433 servo_range
repeat
 
# usage: <pos> <low> <high> servo_range
# If the pot is in the range specified by low and high,
# keeps servo 0 at pos until the pot moves out of this
# range, with hysteresis.
sub servo_range
  pot 2 pick less_than logical_not    # >= low
  pot 2 pick greater_than logical_not # <= high
  logical_and
  if
    begin
      pot 2 pick 10 minus less_than logical_not   # >= low - 10
      pot 2 pick 10 plus greater_than logical_not # <= high + 10
      logical_and

## Brandon Supplied Code - Does this code use ch1 as input Then uses ch1 input to control (servo1 through servo4)??------ 
while
      2 pick dup 0 servo #add 'dup' here to duplicate the target position before setting servo channel 1

      dup 2 servo #duplicate the target value and set servo channel 2 to the same position
      dup 3 servo #duplicate the target value and set servo channel 3 to the same position
      4 servo #set servo channel 4 to the duplicated position

    repeat
	
## Question for Brandon = Will this work ion a 4 wheel RC Truck with 4 wheels LR wheel RR wheel LF wheel RF wheel- ----------------------------------- 
  
  endif
  drop drop drop
  return
 
sub pot
  1 get_position
  return

I combined your post with your previous thread, since it is still about the same topic.

That code should work to send the same signal to all 4 servos, but as I mentioned in my previous post, you might need to invert or remap the signals depending on how your servos are physically set up in your RC truck. If you do need to invert them, let me know, and I can help show you how to do that.

Separately, it looks like you are not using that servo_range subroutine as intended. It is intended to be used to split the 0-1023 range of your analog input into multiple smaller regions that map to the specified target position, but you have the range set to 0-433 on all 3 of your target positions. For example, if you want the 3 different positions to map to 3 roughly equal ranges on your potentiometer (which is how the unmodified example from the Maestro user’s guide does it), it would look like this:

  4000 0 300 servo_range 
  6000 300 600 servo_range 
  8000 600 1023 servo_range

Brandon

That’s great Brandon. TY. Please show me how to invert them as this may be needed. See the below link on my google cloud. Servo are located on each wheel hub.
Servo’s for Dancing Car

Thank You

Joe

The position in the code right now can only be 3 values: 4000, 6000, or 8000. If you need two of the servo positions to invert, you can check what the target value is and if it is 8000, change it to 4000 and if it is 4000 change it to 8000. If it is 6000, you can ignore it since that’s right in the middle.

2 pick dup 0 servo   #get the target position from the 2nd value down on the stack, and set channel 0 to it
dup 2 servo          #duplicate the target position and set channel 2 to it.

dup 4000 equals if       #duplicate the target position and see if it equals 4000
    drop 8000            #if it does, drop the target position (4000) on the stack and replace it with 8000
else dup 8000 equals if  #otherwise, duplicate the target position again and see if it equals 8000               
    drop 4000            #if it does, drop the target position (8000) on the stack and replace it with 4000
    endif
endif

dup 3 servo     #duplicate the new target position and set channel 3 to it
4 servo         #set servo channel 4 to the same position

Pleas note that in this snippet of code, the position sent to channels 3 and 4 are inverted. If you need to change which ones are inverted, you can change the number before the servo command.

Brandon

Wonderful Thanks. So adding your code here is the full script. Please advise if you see an issue.
Again many thanks!!

# Set the servo to 4000, 6000, or 8000 depending on an analog input, with hysteresis.
begin
  4000 0 433 servo_range
  6000 0 433 servo_range
  8000 0 433 servo_range
repeat
 
# usage: <pos> <low> <high> servo_range
# If the pot is in the range specified by low and high,
# keeps servo 0 at pos until the pot moves out of this
# range, with hysteresis.
sub servo_range
  pot 2 pick less_than logical_not    # >= low
  pot 2 pick greater_than logical_not # <= high
  logical_and
  if
    begin
      pot 2 pick 10 minus less_than logical_not   # >= low - 10
      pot 2 pick 10 plus greater_than logical_not # <= high + 10
      logical_and

#Brandon Supplied Code------------------
while
     2 pick dup 0 servo   #get the target position from the 2nd value down on the stack, and set channel 0 to it

dup 2 servo          #duplicate the target position and set channel 2 to it.



dup 4000 equals if       #duplicate the target position and see if it equals 4000

    drop 8000            #if it does, drop the target position (4000) on the stack and replace it with 8000

else dup 8000 equals if  #otherwise, duplicate the target position again and see if it equals 8000               

    drop 4000            #if it does, drop the target position (8000) on the stack and replace it with 4000

    endif

endif



dup 3 servo     #duplicate the new target position and set channel 3 to it

4 servo         #set servo channel 4 to the same position

#Brandon Supplied Code---------------------------------
  endif
  drop drop drop
  return
 
sub pot
  1 get_position
  return

Problem… Constantly getting connection to #00267779 lost. I reset the micro maestro and loaded the initial settings but no joy. Happens when I try to select servo1 in status or any other channel.
I have ch1 as input.

Whenever to connection lost is fixed: See and review the final script code her:

# Set the servo to 4000, 6000, or 8000 depending on an analog input, with hysteresis.
begin
  4000 0 433 servo_range
  6000 0 433 servo_range
  8000 0 433 servo_range
repeat
 
# usage: <pos> <low> <high> servo_range
# If the pot is in the range specified by low and high,
# keeps servo 0 at pos until the pot moves out of this
# range, with hysteresis.
sub servo_range
  pot 2 pick less_than logical_not    # >= low
  pot 2 pick greater_than logical_not # <= high
  logical_and
  if
    begin
      pot 2 pick 10 minus less_than logical_not   # >= low - 10
      pot 2 pick 10 plus greater_than logical_not # <= high + 10
      logical_and
     
 while 
 2 pick dup 0 servo   #get the target position from the 2nd value down on the stack, and set channel 0 to it
dup 2 servo          #duplicate the target position and set channel 2 to it.

dup 4000 equals if       #duplicate the target position and see if it equals 4000
    drop 8000            #if it does, drop the target position (4000) on the stack and replace it with 8000
else dup 8000 equals if  #otherwise, duplicate the target position again and see if it equals 8000               
    drop 4000            #if it does, drop the target position (8000) on the stack and replace it with 4000
    endif
endif

dup 3 servo     #duplicate the new target position and set channel 3 to it
4 servo         #set servo channel 4 to the same position
 repeat
  endif
  drop drop drop
  return
  
sub pot
 1 get_position
return

It sounds like your connection issue is fixed, but if you are still having trouble with it please let me know.

As far as your code, it looks like you are still using 0-433 for the range on all three of your positions, so I do not expect it to work how you want. If you want to separate the range into 3 equal ranges (one for each position), you will probably want to change it how I mentioned in my previous post.

Brandon

Still having trouble with connection even with a hard reset,

Could you be more specific about what you are doing when the disconnect happens? Could you try a different USB cable and USB ports on your computer? Also, could you post pictures of your setup that show all of your connections?

Brandon

Brandon

Specifically what creates the connect is everything,=.
1-Select any servo in the Status tab. Pololu immediately disconnects. This is after a hard reset and Script area is blank. My take is that the board is kaput.

Joe

More on this topic.

Current Micro Maestro with connection issues I added fix to tap power to drive the servos. It worked fine before. 2) Connected a different micro maestro. No issues - same usb cable- same usb port, same all, 1-Please send me a replacement as soon as possible to support Goodwill.

2-Please send your version of the (entire settings and script) for one input drives 4 servos.
I’ll add that back into the second Micro Maestro and provide feedback on the results.

Joe