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

Discussion in 'The Completed Projects Collection' started by djsfantasi, Oct 26, 2010.

  1. djsfantasi

    Thread Starter AAC Fanatic!

    Apr 11, 2010
    5,105
    1,942
    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.
    [​IMG]
    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.
    [​IMG]
    The software analyzes the returned digital values and sends signals to the servo to move the mouth in synchronization.
    Here is my test setup.
    [​IMG]

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

    Thread Starter AAC Fanatic!

    Apr 11, 2010
    5,105
    1,942
    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
     
  3. Audioguru

    Expert

    Dec 20, 2007
    11,103
    1,295
    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.
     
  4. djsfantasi

    Thread Starter AAC Fanatic!

    Apr 11, 2010
    5,105
    1,942
    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.
     
  5. KeithWalker

    Member

    Jul 10, 2017
    266
    83
    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: Jun 19, 2019
  6. djsfantasi

    Thread Starter AAC Fanatic!

    Apr 11, 2010
    5,105
    1,942
  7. Audioguru

    Expert

    Dec 20, 2007
    11,103
    1,295
    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).
     
  8. KeithWalker

    Member

    Jul 10, 2017
    266
    83
    My point is: Have you tried it? Will it follow the envelope well enough for what you are trying to achieve?
     
  9. djsfantasi

    Thread Starter AAC Fanatic!

    Apr 11, 2010
    5,105
    1,942
    Last edited by a moderator: Jun 30, 2019
Loading...