Project: Converting Audio to 0-4VDC Signal for Animatronics

Thread Starter

djsfantasi

Joined Apr 11, 2010
9,156
I have been building an animatronic figure and wanted to synchronize its mouth movements to an audio signal. The mouth is operated by a servo motor controlled by a Lynxmotion SSC-32 controller. The SSC-32 has an onboard A/D converter.

I am an electronics hobbyist with no formal training. I have been able to construct some digital designs, but this is my first foray into the world of analog. I searched the web for relevant circuit designs and with the assistance of this and other electronics forums, and simulation using LTSPICE, was able to develop my circuit, which I call the AAEF (Audio Amplifier & Envelope Follower).

My design objective was to input an audio signal, scale it to the supply voltage of the controller (which is also the reference voltage of the A/D converter), and process it through an envelope follower producing a 0-4+VDC signal that mapped to the amplitude of the original signal. Refer to the circuit below.

The first part of the evelope follower portion of the circuit is the scaling of the signal, using an op amp. I used a trim pot to adjust the gain, as different sources were observed to have different ranges; the use of line versus headphone sources required adjustments. It is also sensitive to the volume settings of the source (naturally).

The op amp output is sent to an envelope follower which is a simple RC circuit to smooth out the remaining audio oscillations. I used a Schottky diode to minimize DC signal loss.

There is also an audio amplifier circuit based on the old standby LM386 on the board as well.

Additionally, I planned on using the two separate channels of a stereo signal. The right channel is sent to a speaker in the animatronic's head; the left channel is sent to the envelope follower portion of the circuit. This allows me to "tweak" the amplitude of the original circuit to provide an exaggerated envelope and thus more mouth detail. Also, the output of this circuit and subsequent A/D conversion are processed by software, introducing a barely noticeable lag. I can delay the audio portion to match the controlling signal with an audio editting program. I used Audacity.

Below are two graphs, comparing the original audio signal to the values returned by the software (written in FreeBASIC) after processing through the circuit and the controller.

The software analyzes the returned digital values and sends signals to the servo to move the mouth in synchronization.
Here is my test setup.


Here is a link to the circuit in action on my animatronic penguin (named Peter) AAEF in Action
 

Thread Starter

djsfantasi

Joined Apr 11, 2010
9,156
So, Ive been upgrading this animatronic and getting ready to produce them in mass The prototype had and Arduino Mega and a MP3/SD shield, plus several additional boards wired and fit into the body wherever possible. I'm improving the design and the run-time module so that all functions fit on two shields.

In doing this, I revisited the AAEF It has worked reliably for me going on 10+ years. But there are some design elements that do not fall into best practices.

The schematic and simulation below represents the changes. In short, I made the following modifications:
  • The 1MΩ resistor has been replaced with another Schottky diode in series with a 20Ω resistor. This does two things.
  • It minimizes the delay incurred by the circuit and the need to manually shift the two audio tracks up to 0.3s
  • Secondly, the input to the op amp never goes below ground, since it is a single supply op amp, this shouldnt occur.
  • The voltage range of the input changed. So the feedback resistors to set gain were recalculated.
  • AAEF2_Schematic.JPG

You can look at the simulation results below. These are more accurate than the original post, so you can see more detail.
AAEF2_Sim.JPG
 

Audioguru

Joined Dec 20, 2007
11,248
Your oscilloscope shows the audio severely clipping. Is that what you want?
Why not make an active envelope detector that has no voltage loss instead of your simple passive one that has a voltage loss.
 

Thread Starter

djsfantasi

Joined Apr 11, 2010
9,156
Your oscilloscope shows the audio severely clipping. Is that what you want?
Why not make an active envelope detector that has no voltage loss instead of your simple passive one that has a voltage loss.
Which trace has the severe clipping? The green one? That’s the audio file and the waveform was processed with Audacity. The clipping is intentional and not the result of the circuit.

Or is it one of the other two traces?

I guess this is not your typical envelope detector. It’s function is to amplify a 1.2V signal (line out audio) to something with a maximum near 5V or the maximum voltage allowed by an Arduino (or other microprocessor). This expanded signal is then sent to an onboard ADV. The ADC value is used to map to a servo control signal within a 60° sweep.

Relative levels are what’s important. The applications does not require a precise envelope.
 

KeithWalker

Joined Jul 10, 2017
3,063
I guess this is not your typical envelope detector. It’s function is to amplify a 1.2V signal (line out audio) to something with a maximum near 5V or the maximum voltage allowed by an Arduino (or other microprocessor). This expanded signal is then sent to an onboard ADV. The ADC value is used to map to a servo control signal within a 60° sweep.
Have you actually tried this with a servo? You will need to use a super-fast servo to follow that envelope. Standard R/C servos are usually about 0.5 seconds for 60 degrees of movement but fast ones are available (much more expensive) that can move 60 degrees in 0.1 second or less. Even at that speed, it will not follow the envelope very closely. The speed is also dependent on the load.
 
Last edited:

Audioguru

Joined Dec 20, 2007
11,248
When the audio is clipping then many amplitude fluctuations will be missing and your robot's mouth will appear to be frozen.
Your simple passive envelope detector's voltage loss also covers up minor amplitude fluctuations that would be fixed by using an ACTIVE envelope detector (the diode's voltage loss is cancelled because the diode is inside the negative feedback loop of the opamp).
 

Wolframore

Joined Jan 21, 2019
2,609
It should work fine, there will be a little transition delay, you will have to play with it to get it to look realistic. I see no issues with the severely compressed areas. The mouth will be open for what looks like 200-300mS. It would be nice to clean it up even move so it’s just an averaged vector so you don’t get jitters. Play with averaging and filtering.

Would be interesting if you wrote what it’s saying under the waveforms.

Hopefully there are no other audio captured on that channel that triggers the mouth.
 

Thread Starter

djsfantasi

Joined Apr 11, 2010
9,156
Here’s a link to the final result. You can hear the audio, which is the same as what’s shown in the graph.

The software performs a rolling average of the circuit output so there’s no need to implement that in hardware.

 
Top