Improving the sound detection circuit

JezWeston

New Member
I'm working on using a 28X1 to control a bunch of LEDs for a rave toy. Hence I want these LEDs to be sound-responsive. So I built the sound detection circuit as described at:
www.rev-ed.co.uk/docs/picaxe_sound.pdf

Changed the holding capacitor C4 to a much smaller value (470nF to 22nF) so that the output voltage is only held for a few tens of milliseconds, code up a volume bar graph in software, running 8 LEDs on a breadboard. All well and good, it looks pretty and that's what I'm aiming for.

However, two questions:
1) The minimum sensitivity is pretty poor. The sound level has to be pretty high before the circuit registers anything, even with the sensitivity of RV1 set to a maximum. This is okay if you're just wanting to trigger something with a clap, but I'm keen to have this respond to music without being jammed up against the speaker.

What could be done to make circuit more sensitive?

2) The volume range is pretty poor. I want this to be able to cope with a range of music volumes, from quiet to apocalyptic. Changing the RV1 trimpot does this, but requires fiddling with it.

Has anyone used a digital potentiometer so that the Picaxe can adjust the sensitivity to match the ambient volume range of the music? Did this work and do you have any tips?

Thanks in advance for any help.
 

Dippy

Moderator
Get yourself an SSM2167 compressor pre-amp from Analogue Devices.

Think of it as an AGC block. And its built for mics.

It's fiddly MSOP smd but it is brilliant. The only addition I had to make was op-amp buffering on in and out, but I suspect that it will probabaly work out-of-the-box for your app.

Get yourself a looksee at the Data Sheet first
<A href='http://docs-europe.electrocomponents.com/webdocs/077f/0900766b8077feba.pdf' Target=_Blank>External Web Link</a>

I'm sure it'll do what you want.
 

boriz

Senior Member
Forget that circuit. Use an op-amp. I&#8217;d use an LM358. Dead simple. You know how, or do you want a circuit diagram?

Rave toy = thing with flashing lights and colours that can be wielded by a dancer at a rave to emphasise movements, gestures and attract attention.
 

manuka

Senior Member
At their most basic level &quot;ravetoyz&quot; are just glow in the dark goodies. However, at their more advanced level,your &quot;gap&quot; will mean you probably will NOT want to know more details...
 

JezWeston

New Member
Hmm... the compressor pre-amp looks particularly fancy, although I think it might challenge my soldering skills. A circuit based around op-amp might be a better plan. Would a circuit based around op-amps still be able to hold an output voltage for the tens of milliseconds that it might take for the Picaxe to get around to reading it?

A circuit diagram would be a wonderful thing, my electronics education being limited to pretty much just following the instructions (and then when it doesn't work, reading through them again to find out where I didn't read carefully enough in the first place).

This particular rave toy is a transparent staff for spinning, with a heap of RGB LEDs along its centre. So here's the fun part - all this gubbins has to fit inside a 25 mm tube. This makes life interesting, but I'm continually impressed by how much a little Picaxe can do. This project wouldn't be feasible without.
 

hippy

Senior Member
<i>Would a circuit based around op-amps still be able to hold an output voltage for the tens of milliseconds that it might take for the Picaxe to get around to reading it? </i>

It would. It would be a peak-level detector which can be implemented by taking the op-amp output through a diode and resistor to a capacitor which is then read by the PICAXE. The diode stops the capacitor being discharged when not being charged up by the op-amp. It will slowly discharge by itself. The non op-amp circuit probably does a similar thing ( I haven't looked ).

You can build multiple channels of these op-amp detectors each tuned for specific frequency bands ( &quot;Lo, Mid, Hi&quot; or &quot;Lo, Mid-Lo, Mid-Hi&quot; and Hi are common ) and you can then do more complex sound-to-light processing, beat detection etc.

There are numerous effects you could create from traditional volume-to-light-level, though bar-graphs to beat stepping light chases. Multiple effects can be combined and cycled through.

A 'disco in a stick' ( sorry - 'rave toy' ) is an excellent project with plenty of scope for experimentation and expansion. A forum search should turn up previous discussion on sound to light and input filtering.
 

demonicpicaxeguy

Senior Member
ah yes i get it now.. you're talking about what a lot of them refer to as &quot;glowies&quot; only
when the word &quot;toy&quot; was used i thought it was somthing else.......... -_-
 

boriz

Senior Member
Try this: http://img223.imageshack.us/my.php?image=audiosensorob2.gif

None of the components are too critical. C2*R6 time constant controls the peak hold delay, R5 controls the gain, R3+R4 control the zero point (R4 should be about 1/5th of R3, use a preset for R4, it will only need to be used for setup), C1*R2 control the frequency response. Do you have an oscilloscope?


Edited by - boriz on 13/06/2007 13:46:43
 

MiB1986

Member
I dunno if its any interest, but i have used LM3915 and LM3914 bar graph drivers before to drive LEDS and an input into a picaxe using ADC. obviously you will need to calibrate your output reading, ie 0 to 10 volts or 0 to 20 volts, simply use a potential divider to break it down to 0 to 5. as thats the maximum a picaxe can take, but the PICAXE 08M will be just perfect.

Kind Regards &amp; Goodluck with your project

 
 

Dippy

Moderator
boriz's circuit looks nice and simple, though I would put R6 across the diode to give better decay control. I would be tempted to put another small R in series with diode to prevent teeny/tiny transients charging C after all you don't want it flashing when your ice cubes in your Pimms are rattling.

You will have to play with values of R and C depending on whether you want boom/booomph/titty reposnse.

My only comment with fixed gain amps is that you may have to twiddle and when you ravers put your head in the PA your lights may be permanently on - with a level of AGC you will get a better performance over a wider dynamic range.

This may not matter after you've put your head in the PA...

Good luck.
 

boriz

Senior Member
I want a 'boom/booomph/titty reposnse.' Is it legal?

R6 across the diode?? I don't understand ??

The average signal level at the op-amp output is determined by the R3/R4 divider. The peak-to-peak amplitude of the signal is determined by R5. No series resistor is needed between the diode and the cap because the op-amp has it&#8217;s own current limiting to 50mA. C2 charges through the diode and discharges through R6.



Edited by - boriz on 13/06/2007 14:26:25
 

Dippy

Moderator
By having diode across diode your discharge only happens on a 'low' from op-amp (assuming push-pull as I was generalising). R6 where it is draining all the time.

Lower values of R when in //Diode allow faster decay times with large transients without compromising Vpeak on cap.
Check it out on 'scope.
 

Michael 2727

Senior Member
This works as a sort of peak detector it will work from a finger click at 1 meter up
to a jack hammer sound level.
And the same goes as above re: cap / resistor to change the discharge rate.
Code:
              o         o   5V       o
              |         |            |
              |         |            |
             .-.       .-.           |
             | | 22K   | | 1Meg      |
             | |       | |           |
             '-'       '-'           |
              |         |            |8
              |         |         3|\| LM358 1/2        22K
              o--------------------|+\                  ___        OUT
              |         |          |  >----->|------o--|___|--o----o
              |         |      .---|-/ 1    1N4148  |         |
              |         o      |  2|/|              |         |
              |         |      |     |4             |         |
         _    |         |      |     |              |         |
      | / \---o        .-.     |     |          1µF |        .-.
      |(Mic)           | |<----'     |             ---       | |47K
      | \_/---o        | |           |             ---       | |
              |        '-' 100K      |              |        '-'
              |         |            |              |         |
              |         |            |              |         |
              |         |            |              |         |
              o         o   0V       o              o         o



(created by AACircuit v1.28.6 beta 04/19/05 www.tech-chat.de)
The 1uF is an Electro +pos ^ top.
Somewhere around 2/3 Pot rotation will make
the O/P on full.


Edited by - Michael 2727 on 13/06/2007 15:31:54
 
Last edited by a moderator:

hippy

Senior Member
Also have a look around for &quot;Light Organ&quot; and &quot;Color Organ&quot; circuits. Most will be similar to that which Boriz posted, and can be adopted for PICAXE use. There's always a degree of experimentation needed to get what one feels is right as an end result post-processing.

Many multi-band units can be built using a single IC, for example - <A href='http://www3.telus.net/chemelec/Projects/Color-Organ/Color-Organ-2.jpg' Target=_Blank>External Web Link</a>

I'll agree with Dippy about AGC being a good thing. Anything beyond LED intensity being related to sound level is more based upon what frequencies there are present and relative to each other than how much of each. One of the big problems is low volume and hardly nothing lights, too much and everything is on full. The SL6270 VOGAD ( <A href='http://www.elenota.pl/pdf/Zarlink_Semiconductor/zarlink_sl6270c_jan_1999.pdf' Target=_Blank>External Web Link</a> ) used to do a good job but not sure if it's still available.
 

Dippy

Moderator
Yes, it was the good old vogad I was looking for (without luck) when I found the SSM2167 which is easily available in ones in UK. It really is very good.
An SMM2167 plus discretes all in sm could be a tiddly pcb and nothing to twiddle.
 

boriz

Senior Member
Dippy.

&quot;By having diode across diode your discharge only happens on a 'low' from op-amp (assuming push-pull as I was generalising). R6 where it is draining all the time.&quot;

Yes. That's how the peak detector works.

I'm still not clear on what you mean by &#8220;large transients&#8221;. The only output from the op-amp should be the sound signal. If low-pass filtering is required, then I would suggest a small capacitor across R5.

Happyinmotion.

In fact, now I come to consider it, since this device is supposed to respond to dance music beats, then I would definitely recommend a capacitor across R5 to reduce the gain for signals over 100Hz or so. Experiment with values. R5 should be about 40 times the value of R2 for a maximum gain of 40.
 

Dippy

Moderator
Well, I don't want to get into a long boring discussion on this, but Happymotion wants to detect boomph-boomph-boomph yes? At varying ambient amplitudes (volume levels), I would assume. And produce flash-flash-flash or something like that, yes? The circuit you gave does not track the signal so your 'peak' is a simple threshold detection, so, if you don't disippate that cap fast enough (post-boomph) the ADCing (threshold) will probably have the LEDs on nearly full-time, hardly the effect he wants eh? (Especially if you don't use AGC.) the parallel res allows a much lower value of R so that post-big-transient low(er) V will discharge the cap quicker, still far from good. None of this is as good as a true peak meter as your cicruit will indicate a peak for a duration proportional to the amplitude and duration of the pulse (assuming cap doesn't reach fullcharge), in fact it could stay high most of the time , which is not how a true peakmeter works and can be as simple as a dual op-amp plus discretes.

Compare the differences on a 'scope, I'll say no more otherwise this could drivel on ad nauseum.

Aftethought: Maybe you could use that circuit and change your threshold on PICAXE ADC to 'track' - just a thought... that would keep everyone happy perhaps?

Edited by - dippy on 13/06/2007 19:24:39
 

moxhamj

New Member
This is getting into op-amps rather than picaxe, but the boom-boom is a low pass filter. The AGC can be done with a quite clever op amp circuit using two 914 diodes. One goes from the negative to the output and the other from the output to the negative. The positive goes to ground (or 1/2 volts if using a virtual ground). The input is a resistor to the negative, something 1k to 10k. The output tends to stay a constant +/- about 0.6V with large variations in input voltages eg 1mV to 5V. The gain works over a larger range with a 1k than with a 10k resistor.
 

boriz

Senior Member
&quot;if you don't disippate that cap fast enough (post-boomph) the ADCing (threshold) will probably have the LEDs on nearly full-time&quot;

Yes of course. Second sentence in my original post. &quot;C2*R6 time constant controls the peak hold delay&quot;.

With low C2 and low R6, you get low peak hold delay.

That's just based upon my limited understanding of CR constants. If I'm wrong, then I'm very sorry.
 

JezWeston

New Member
One advantage of living in NZ is that I can ask a question, sleep a night and wake up to a heap of helpful answers. So thanks already, you&amp;#8217;ve all been most useful.

I&amp;#8217;m wanting to go beyond just picking up peaks and have volume bars that respond to the sound signal in a variety of ways. Having had a look at some of the datasheets and circuits that people have pointed to has helped me think about how this might work. Given that I&amp;#8217;ve got the Picaxe there, then I can happily use that to do the signal processing and automatically adjust thresholds for lights based on the volume range that it&amp;#8217;s seeing. This seems feasible given that my volume bar only needs 16 steps for this to work, and the ADC input will give me 256.

So my first preference will be for a circuit with what I think would be called high sensitivity but fairly low gain. Apologies for not knowing the correct terminology, but I&amp;#8217;d like a circuit that starts to produce an output at a low volume level, but doesn&amp;#8217;t max out until the biggest hits whilst standing inside the speakers. (And if the output was log, not linear with volume, that&amp;#8217;d be dandy.) At any given distance from the speakers, the music might be causing a signal to wibble along between, say 40-90 on the ADC. Then the max and min points can adjust in software to give full range on the volume bars.

I&amp;#8217;ll buy an op-amp or two and have an investigate on the breadboard this weekend, along with copious reading about light organ circuits. Are there any hints or pitfalls that I should know about first? I don&amp;#8217;t have an oscilloscope, but a Picaxe and 16 LEDs does the job well enough.

Once I&amp;#8217;ve got that working, I&amp;#8217;ll try including a second output in a simple LPF to another of the ADCs to read, so that I can have some choice about which frequency bands the thing is responding to. As I&amp;#8217;m using RGB LEDs, it seems theoretically possible to have volume bars for bass, mid &amp; treble off the same set of LEDs. Whether this would look any good, I don&amp;#8217;t know, but I think its worth trying. And then we&amp;#8217;ll have it going up, down, in from the ends, out from the centre, whatever combinations I can think of.
 

boriz

Senior Member
The circuit I offered is guaranteed to be untested. It is a basic starting point for an audio-pic interface. Breadboard it and experiment with component values.

AGC is another matter&#8230;
 

hippy

Senior Member
Getting sound amplified so you can detect an ant stomping but not go deaf next to a jet aircraft is the role of AGC / ALC / VOGAD / Compressor / Compander, that gives the 'log' effect you noted.

One way to go ( which suits your tube design ) is to build modular and chain bits together. You can then change bits at will, add extra filters in and so on.

You can also think laterally in ways where volume level isn't that important. For a good light show you want the lights peaking at full on and full off for maximum impact plus a very dynamic effect. Without AGC, lights can just 'dribble along' looking fairly dull and uninteresting if the volume is too low or too high.

What's key to good aesthetics I feel is dynamics closely coupled to the sound ( or appearing so ). If your rave toy has a run of LED's, you can step a LED along on bass beats, and you don't need to know their intensity, that there is a beat can be as simple as the level being greater than last time. You can use the intensity if you have it to determine how far or how fast to move the LED, or both. Step the LED, bringing it full on, then fade it away, and you get something very dynamic.

What I found was that it's often better and more impressive to create a trigger from the sound and do something interesting with that than do something which reflects what the sound is. A bit like tapping along to a drum beat and throwing one's own paradiddles in; it adds to rather than replicates what's going on in the sound. People can spot what's driven by sound and may see it as run-of-the-mill, when they see something interesting and synched it becomes much more visually attention grabbing.

The real test for sound to light I'd say is Michael Jackson's <i>Thriller </i> . Crack that and most else will follow. I spent weeks listening to that ( and as 5 second samples ) while watching a scope to tune the STL I was working on. There are some very interesting double drum-hits in there which you don't normally hear but can throw a curve ball to any processing algorithm.
 

premelec

Senior Member
I'm not entirely following all this but suggest you look at the National LP3954 chip
&quot;Advanced Lighting Management Unit&quot; with audio synchronization features built in - very small and versatile - PICAXE could be additional driver....
 

boriz

Senior Member
&quot;paradiddle&quot;

I used to play guitar in a rock band. The only time I ever heard that particular word was when a drummer gave me a lesson. You have brought back some great memories. Thanks!

I guess you are a drummer. So I&#8217;m going to tell you my best musician joke:-

What do you call someone who hangs around with &#8230;&#8230;

Nooo, not that one!





A drummer decides to try a different instrument. He goes shopping&#8230;

Guy: &#8220;I&#8217;d like to try a new instrument. A guitar maybe. Can you show me a selection?&#8221;

Shopkeeper: &#8220;You&#8217;re a drummer aren&#8217;t you.&#8221;

Guy: &#8220;WOW! Yes. How did you know?&#8221;

Shopkeeper: &#8220;This is a butchers shop.&#8221;
 

hippy

Senior Member
I'm actually tone deaf and can't keep a beat, but that does have its advantages - even bad music sounds good ! I have spent a lot of time around musicians though.
 

manuka

Senior Member
Andrew&quot; Brightspark&quot; down here in NZ has (coincidently) just tamed a Picaxe sound sensor that uses just a cheap piezo &amp; NPNs. He'll no doubt be open to arm twisting, but see a layout <A href='http://www.picaxe.orcon.net.nz/sound.jpg' Target=_Blank>External Web Link</a>
 
<A href='http://picasaweb.google.com/Andrew.Hornblow/PICAXE' Target=_Blank>External Web Link</a>

This worked quite well. An olden day approach using those old low noise three legged silicon triodes. This is very experimental and some experimentation will be required to &#8220;chase out&#8221; noise effects when working around digital circuits. See below.

I have tried an engineered approach but stumbled on this and it seems to work quite well. The last C and 4M7 and the clamp diode just inside the 08M forms a rectifier and RC time constant of a few 10's of mS.

* Single stage it works as a clap-o-meter.

* Dual stage it works as a VU meter.

* 2 x simple bias NPN (any type I used BC337)

* Piezo element makes a FAB microphone (and accelerometer for those rave dancing)

* Add a business card or plastic lid to design your own mike and resonant frequency of choice. A whistle frequency sweep will show this up quite well.

* &quot;De Bug&quot; the audio circuitry with a crystal earpiece. You will hear clicks of LED's being switched etc and serial upload byte-buzz cross talk

* Using suitably CSV formatted serial data stream into the F9 data logger screen you get a VU trace from a radio playing near by. I generated a simple averaging algorithm with a 111mS sample time and 10 x average to create a second averaged data variable.

- Andrew
 

Rickharris

Senior Member
Why not go cheap and put a selection of tactile switches on the tube then you can tap out your own light pattern.

Or pre-select some appropriately picaxe controlled patterns and provide the beat via a switch?
 

JezWeston

New Member
Couldn't get on with playing with op-amps this weekend, I spent too much of today getting stitched up in casualty after a hockey match.

Triggering events off the vibration of me grabbing the stick is a great idea. I'd been mainly thinking on how to isolate the microphone from those vibrations so that it just picked up the music, but adding another sensor, mounted rigidly to the casing could make this even more fun. Now, I just have to build the things, and work out how to fit all this gear into a rather constrained volume.
 

BrendanP

Senior Member
Have a look at accelerometers, theyd be good in your app. Spin it on the horizontal axis it would light one colour, spin on vertical it would go another, spin slow it would be a diffrent color than fast, as you moved through diffrent axis it would slowly change colour if you used tri colour leds.

The acclerometers are easy to use with picaxe. Your fellow kiwi Andrew has done a lot with acclerometers.

A few disco biscuits and a picaxe driven light staff and you'll go off with more heat than a napalm strike.

&#160;

Edited by - BrendanP on 17/06/2007 11:04:51
 

Michael 2727

Senior Member
Andrew have you tried any FETs instead of the BJT, they should work a lot better.
I worked on an industrial vibration sensor,
now patented, a few years back.
We used a standard piezo element for the pickup.
The hard part will be finding a device that is commonly available worldwide or equivalents thereof for picaxe users.
 

boriz

Senior Member
Simple inertial switch. Piece of springy wire, like steel guitar string, about 4 CM long, soldered at one end to PICAXE input and passing through a hoop at the other end. They do not make contact when at rest, but when moved around the springy wire bends and touches the sides of the hoop.
 

D n T

Senior Member
HappyinMotion. I like hard core too and had a &quot;toy&quot; here like a staff. I built it a few years ago using a hacked sound sensor form a sound sensitive neon in an automotive accessory.

Anyway 25mm acrylic rod( sound familiar) two thin enamelled wires running end to end suoper glued in place (invisible from about 2 feet) mounted in each end is a laser pointing down the tube toward the other end. The two lasers ( one red $15.00, one green $150.00) are slightlty out of alignment so they don't shine into each other.

Now the really flash bit. I cut and punched a disc( or donut) out of a piece of a CD so that the outer diameter was about 13 mm and the internal daimeter was 2mm larger than the output tube on the laser. Behind the mirror I glued a light spring that slid down around the laser ouput tube and was glued to the base.
This meant that the lasers would flash to the beat and because they were mis aligned they would hit the mirrors. these mirrors are spring mounted so they woble, flashing the light everywhere around the tube. The light that escaped the tube was much less intense than the initial laser source. The batteries were in each end behind the lasers,

If went &quot;right off&quot;.

But security didn't like it much because it was four feet long and I used to get a bit of a spin up with it, never hit anyone though.
I sold it to a D.J. for $350 dollars.

Just a though and perhaps a source of ideas.
 
Top