Audio Input Servo Position Controller

I have the Mini Maestro and I’m looking to control the Jaw movement on a skeleton model. I’ve seen a lot of discussion on this topic, but the answer seems to be another software program to control the movement. I believe this will solve the issue.

Since the control signal will be audio, the volume of the audio will control the opening of the jaw; the louder the signal, the wider the jaw, the softer the signal, the narrower the jaw. To make this happen, I will be using an audio VU meter. The VU meter runs off 5 volts, the same as the power to the Mini Maestro. There are 5 LED’s in the meter. As the volume gets louder it turns on each one of the LED’s (they continue to stay on until the volume lowers below that channel’s threshold). I want to use the signals from these 5 separate channels as inputs to five of the input channels in the Mini Maestro. For example, they can be interpreted as:
LED 1= 10% jaw opening
LED 2= 25% jaw opening
LED 3= 50% jaw opening
LED 4= 70% jaw opening
LED 5= 95% jaw opening

I don’t know how to write the code to make this happen and I’m seeking help. Also, I read in one of the posts to add hysteresis to reduce the servo from chattering and I don’t know if this will need it or not but it if does, your help would be greatly appreciated.
I appreciate your help. Thank you.

Hello.

It is not entirely clear to me what kind of interface your audio board is using, but from your description, it sounds like it essentially has 5 digital outputs that are subsequently driven high for louder sounds (i.e. for the loudest sound, all 5 will be high and for the softest sound only the first one will be high). If that is the case, you should be able to use 5 channels on the Maestro to read those inputs like you described. A series of chained IF statements is probably the easiest way to handle that, for example:

#this code is for a servo on Maestro channel 0 and inputs on Maestro channels 1-5

begin

  5 get_position 512 if 8000 #if input 5 is high, put 8000 on the stack
    else if 4 get_position 512 if 7600 #otherwise, if input 4 is high put 7600 on the stack. . .
      else if 3 get_position 512 if 7200
        else if 2 get_position 512 if 6800
          else if 1 get_position 512 if 6400
            else 6000 #no inputs are high, put 6000 on the stack
          endif
        endif
      endif
    endif
  endif
  
  0 servo #set target position for channel 0 to value on stack

repeat

You will likely need to adjust the servo positions at each loudness level, but that code should give you something to get started with.

Brandon

Hi Brandon, thank you for your help, I really appreciate it. Since I’m a total noob, in the first line, 512 if 8000, does the “8000” mean the radial location for the servo?

This is the VU meter, the output is analog, but it’s basically going full on for each channel.
https://www.amazon.com/dp/B0BLGK7YYD?ref=ppx_yo2ov_dt_b_fed_asin_title

Thank you

8000 is the target position being sent to the servo. The servo command in the Maestro script uses units of quarter-microseconds, so sending a target position of 8000 corresponds to a pulse width of 2000 µs.

Unfortunately, I do not see any datasheet or explanation of how the board works on that Amazon page, but if you get it working with the Maestro I would be interested in seeing your results!

Brandon

Thank you for the fast reply Brandon. I will indeed share it with you. I looked over the forum and this is a common question. I’d like to get a really good solution for this as there are many looking to solve this.

If there is erratic or jerky movement, is there a way to add acceleration or deceleration to the code to smooth the response for the servo?

You can set an acceleration and speed limit for the servo channel in the “Channel Settings” tab of the Maestro Control Center. You can learn more about the Speed and Acceleration settings in the “Channel Settings” section of the Maestro user’s guide.

Alternatively, you can set a temporary speed or acceleration limit using the SPEED and ACCELERATION commands in your script. If you do it this way, please note that all subsequent movements on the specified servo channel will use the new speed and acceleration limit until it is reset or power cycled.

By the way, erratic jerky movement can often be a sign of a power issue (i.e. an inadequate power supply) or an underpowered servo. So, if it continues even after introducing speed and acceleration limits, you might try looking into that further.

Brandon

Thank you Brandon. I will be working on it this weekend.
The reason why I mentioned ‘jerky’ movement is because when a servo moves from one point to another, it does it very quickly and appears ‘jerky’ to say a jaw, head or limb. In animation or ‘real life movement’ there are acceleration and deceleration curves that smoothes out the movement making it more natural. In animation, they use bezier curves to smooth in and out the movements.

Are there any kind of equations that can be used in the code that can do some sort of exponential function that can possibly be put into these movements to simulate a bezier curve?
This can be used in a number of applications, not just animatronics, making robotics look more realistic. Just thinking out loud…

1 Like

Unfortunately, the Maestro does not have any special support exponential speed profiles like that. With an acceleration limit set it will essentially use a trapezoidal profile.

Brandon

Thank you Brandon, I appreciate your time. I’ll check in with you about my progress.

1 Like