Help Please! Mesuring peak AC voltage using ADC

dragon616Wales

New Member
Hi Guys,

This is my first post on picaxe forum so go easy on me please. I've made several PICAXE circuits previously using PICAXE 8 and 18's successfully. My current project is for my A-Level exams which are unbelievably close!

Basically I have a NSC LM1875T 20W amplifier which I want to connect to a set of speakers and a 10-bar LED display. I'm aware that the ADC on PICAXE chips can't read AC so the sound wave obviously needs converting to DC. I've done a bit of research into this already but can't seem to find a circuit specifically for my needs; the only ones I can find use input from an electret microphone, not directly from an amplifier.

Output from the amplifier is between 0.2 and 2.1 Volts AC, does this require further amplification?

Is the 'buffer' or capacitor essential?

What capacitor should I use?

Is 0.5second discharge too long?

Can someone help me either design a circuit (basic preferred) or at least point me in the right direction.

Much Thanks
 

alband

Senior Member
Hi, Welcome! :)

I would have thought you would need the capacitor to buffer it, but I am clueless as to the size and type (though others in the forum will DEFINATELY know :eek:). I would have thought that just a diode in series will sort out the AC/DC problem and the capacitor should "spreed out the gaps".

As you can see though, I'm not sure of the above. My main point is that to drive a bar graph, it is probably going to be easier to use a dedicated bar graph driver like this one. It is feed by a analogue voltage and increments bars (or sends a "line" up, see the datasheet), which I think is just what you're looking for, just without the need for coding.

Hope this helps,
David.
 

dragon616Wales

New Member
Thanks for the prompt reply!

I thought a diode would be enough just to get the posative peaks, still dunno about the size of the capacitor though. Anyone you can recommend asking?

Ideally I would prefer to use a dedicated driver however I need to add more functions to the project (like a bar graph as an equalizer) for the A grade I need. I'll definately have a look at that driver though! Currently I've got the following:

FM Receiver and MP3 input (via 3.5mm jack) feed directly into the 20W Amplifier. Amplifier is connected to a pair of speakers (mono). The heatsink on the amplifier has a fan from a graphics card which is activated by a thermistor connected to an adc on a PICAXE. I've been told I need something else if I'm to gain an A grade. As I'm already using sound in the project I thought a little graphic equalizer would be the obvious choice, not as straight forward as I thought though!

Cheers,
Phil
 

SilentScreamer

Senior Member
The cap will be needed at ADC is not instant it takes time (I think its around 250us I depending on which PICAXE and other things). If you want a faster refresh rate from the equaliser then you want a smaller value capacitor however it would be harder to read the value correctly. Perhaps take 3 or more readings and only display the highest?
 

sleazyd

New Member
An idea

To be accurate, you don't need "DC" you need a singal-sided signal that varies between .6-4.4 volts, or so. Last time I had to do this, I created a precision absolute value circuit, and fed it into a buffer circuit with a long time constant (About .5sec). The uC would then sample whenever it did, then activate a FET/resistor for a millisecond to discharge the buffer cap. The point of this circuit was to detect spikes that were filtered out by a 6th order LPF.

In any event, you may be better served with a segment driver, as Alband said. If you want to do it, you shouldn't need to amplify any more. The 9 bits of precision will be plenty to drive a 10-segment display. Half-wave rectify it, feed it to a buffer with about a .2 sec discharge, but be willing to play with it if the graph is too jumpy.

On the attached circuit, the input cap should be about as big as you can get on a non-polarized cap, about 1uF. The hold cap can be polarized and as big as needed. Vary the resistor to set the discharge time. I'd start with a 1uF cap and 470K resistor for the .5 sec RC constant you wanted, but you might like it faster. The output buffer can be any crappy op-amp, or omitted entirely for easy of building. I'm just worried that the sampling might put a little drain on the circuit and give inconsistent results.

It's simplistic and off-the cuff, but it's where I'd start. The only issue might be getting a Shottkey diode if you don't have them handy. If you don't, you might want to whip up a precision half wave rectifier circuit (google it) in its place, but those do generally require a negative power supply.
 

Attachments

alband

Senior Member
I think, in general you would use an electrolytic capacitor. Negative to GND, and positive to the output of the diode/input of the Dirver/PICAXE, but as I say, I'm not sure, and somone will tell you soon.

If you have multiple aplications for the Bar graph you could consider reading the analogue level using the PICAXE, then sending an edited version of it out to a bar graph driver using PWM (PICAXE manual 2 p137+). This would mean you only need a small PICAXE whereas is you tryed to drive the bargraph from the PICAXE you would need a PICAXE with 10 outputs.

Edit: Ah, I've been beaten to it!
 

vttom

Senior Member
Here's what I've done to achieve nearly the same thing:

Take a whole bunch (ie 100) samples of the waveform from the ADC, one right after the other in a tight loop. Inside the loop, use variables to store the minimum and maximum ADC values over that period.

Then, after the period is over, subtract the min value from the max value and that gives you a pretty good idea of the dynamic range (or volume) of the incoming signal over that period of time.

At ~100 samples per period, you can get 10 or so such sampling "session" per second. That's plenty of granularity for driving a bar graph.
 

hippy

Ex-Staff (retired)
Have a read at this App Note from Microchip on Interfacting to AC power lines.
That's not really going to be a lot of help in determining peak voltages and I would recommend everyone steers well clear of following the mechanics of that Application Note if they don't know what they are doing.

For PICAXE users the main message to take away from that document is that voltages much higher or more negative than supply rails can be connected to a PICAXE with suitable current limiting.

Something like sleazyd suggests is what I'd recommend. Effectively a peak tracking sample and hold with a suitable decay time.

At 2V1 peak, a diode and capacitor may be all that's needed for some experimenting though it would be preferable to add a resistor in series with the diode so the signal is driving a load and that load doesn't affect the signal.

2V1 is about half the PICAXE supply at 5V and that gives at least 64 steps of resolution and should be suitable for further processing.
 

dragon616Wales

New Member
Hey guys,

Thanks for all your replies they're much appreciated! I've decided to use the LM1875T for the amp, LM3914 for the bar graph display and just a potential divider ciruit to activate a fan on the common heatsink.

Thanks again though, you've given me plenty to talk about in my evaluation! I hope to be back here again soon with my next project, hopefully involving a PICAXE.

Phil
 

inglewoodpete

Senior Member
The LM3915 would be more suitable for showing audio levels. It should be available in most places that sell the LM3914. The LM3915 is almost identical to the '14, except it uses an exponential voltage reference series, more suited to audio power and the ear.
 
Top