Can I run a rectified audio signal (the output of the headphone jack on a laptop, for example) into one of the ABCD inputs, and read the analog voltage without damaging the SSC-32?
I plan on using the basic envelope detector circuit below to condition the signal; A Schottky bridge rectifier to rectify the audio AC signal and an RC circuit to smooth it out.
The output will go to pin A and I will read it with the VA command. Since I really need to detect 2-3 different levels, it seems to me as if it will work.
Laptop audio is 1.55V peak. With a .2V drop in the Schottky diode, that gives me a positive signal of 0-1.25V, which is about a range of 0-75 from the analog input. The RC circuit may need tuning…
Additionally, the audio input to this filter will be half of a stereo signal of a mono sound source. The second channel will have a 20KHz tone at full volume imposed over the desired peaks of the original sound on the first channel; hence, the input signal will be strong.
I was most concerned about harming the SSC-32. If it doesn’t hurt, I can experiment.
FYI, I found a free electronics simulation tool – LTSPICE – that I was able to use to simulate this circuit and tune the RC network.
Running a simulation, below is what I expect the SSC-32 analog inputs to return to my program based on the amplitude (volume) of the signal.
Depending on the amplitude, I can open/close the mouth of my animatronic.
The same idea can be used with the Bot Board II.
Add some personality to your 'bot!
A full wave bridge rectifier circuit introduces 2 diodes into the signal path, resulting in a voltage drop of 0.4V
While this still is a range of 0-1.1V, it does compress the range to 85% of that available with this standard envelope follower circuit. That’s why I like this one better …
I researched a more robust circuit that used an OpAmp to scale/amplify the signal to 0-4V before processing by the envelope follower and simulated it as well. It worked great, but eventually I decided that the range of the raw signal was sufficient enough and did not justify the additional complexity of the scaling/amplification circuit. Plus I couldn’t understand why the ratio of R2/R1 produced these results; it was counter intuitive to what was explained to me, that the amplification factor was [1+r2/r1]. (I thought it would scale the signal 143% instead of the 245% I am seeing in the simulation). Don’t like using things I cannot understand. Edit: Updated the schematic. The circuit also shows terminating the unsued op amp and an amplifier circuit using an LM386]
Well, it looks like you’ve got a good handle on it. Full wave seems to be used in synchronous detectors, not needed here.
The op-amp (instrument amp) method is what I’ve always resorted to.
I had a thought about using a lower A/C reference voltage to better cover the input range, but you’re going into the SSC-32, which doesn’t as far as i know offer a set up to take an external reference.
Besides reading voltage levels, what’s the goal of this circuit? Did you plan to make something happen in your code if the level reaches a certain point? have it do something with in a specified range?
I have done something similar using a simple microphone circuit.
You may want to drop back to a more simple circuit that just detects electrical activity on the audio line. The timing of analog reading on the ssc-32 may be somewhat slow for generating detailed mouth movements. I’d look at using the audio feed to operate the base of an NPN transistor which is connected between the ssc-32 +5v power and an RC circuit that would produce a voltage more measurable by the ssc-32 analog input.
As long as I can detect peaks, I am fine. Reading back in my posts, I am using a stereo signal.
From my initial test with the mouth(no analog control; see my YouTube post), as long as I can determine 3 levels (closed, halfway open and full open), the appearance is fine. Anything more than that, the detail is lost.
My simulation shows a linear relationship between 0-1.55V to 0-70 returned by reading the analog input.
0-20 means mouth closed
21-45 means mouth half open
46-70 means mouth wide open…and these can be tuned.
The idea is based on a circuit from my Halloween animated prop days from “Scary Terry”. His simply detected full volume and got decent results, which were enhanced by the use of the two channel approach. For unscripted audio, the base circuit and two levels will work fine. This is what prop builders did with Scary Terry’s basic circuit. His built-up device is ~$40; This envelope follower requires 3 components, a header and stereo audo jack.
I found out why the more “robust” solution I was considering was behaving differently than I expected. The gain calculation is valid for an ideal op amp; the LT1013 I have in the circuit has built-in protection diodes, which result in a little voltage shifting before the op amp sees the audio signal. When my friend included a diode similar to the LT1013’s protection diode, his simulation matched my results.
Hence, I am going with the op amp amplifying the signal before the envelope follower circuit converts the AC audio to a DC envelope. Also, I have replaced the resistors R1 and R2 with a trim pot, for adjusting the gain. This was a useful addition, because if I power the circuit from VL instead of +5VDC, I can get the full range of 0-5VDC instead of 0-3.8VDC.
I have the parts on hand; I am waiting to order the PCB. Will post the results.
It’s been a while since I’ve posted my project results to this thread, but tonight I have made some significant progress.
I had custom PCB boards made using the schematic shown above and built the circuit. I modified a 6" servo cable to connect power and the a/d pin of the SSC-32 to my board. I also added an amplifier to the circuit board to drive a speaker in Peter Penguin’s mouth. You can see a picture of my hookup below:
I tested it tonight and got good results. The picture below shows the waveform of the audio input file. and the graph of values received from the A/D pin of the SSC-32. I’ve tried to manually line up the scales of the graphs, but I can see a correlation of the value to the original audio input. The peaks are clearly visible as well as intermediate values which roughly correspond to the waveform.
SO, Peter Penguin will talk soon! I am still working on rebuilding the torso, arms and head of something more solid that foam-core board and hope to post a video of Peter in the Projects section soon.
By the way, it is important when testing, such as after mounting in the bot itself, to ensure the volume of the audio signal is the same as it was when testing. When you turn the volume way down in the sound program - you begin to think that you’ve broken the circuit…