Author Topic: Audio bar graph. Small!  (Read 9605 times)

0 Members and 1 Guest are viewing this topic.

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4202
  • Country: gb
Re: Audio bar graph. Small!
« Reply #50 on: April 01, 2018, 10:47:09 am »
I had a crack with a peak detector circuit, bare bones of course.

First time I've used my signal gen in anger. 

Everything was looking like a win until I muted the input.   :( A 300mV offset on the output.  So a muted channel will read VGnd+300mV which is pants.  (Yes I shorted the cap to be sure, even removed it)

I suspect I need to use a different opamp, the NE5532 comes nowhere near close enough to it's rails.  Depending on how you read the datasheet it could be as poor at 2-3V off the rails.  I dropped the VGnd to 1V as I'm only concerned with the top half of the signal.  This was due to the NE5532 reaching it's upper limit around 3.4V (on a 5V single supply).

I don't want to give the opamp feeding the ADC a rail higher than the ADC input.

Thus I will need to see if I have any closer to rail-to-rail opamps lying around and maybe spec one for the project.  Doesn't need to be "good", but does need to be rail-to-rail.

I also found on the breadboard the caps discharge a lot faster than I expected with only the scope impedance and the diode leakage as a load I had to go up to at least 1uF to get a hold on 100Hz and 10uF to get a hold on a 10Hz SyncPulse.  Of course then I hit the opamp current limit and it can't charge the cap fast enough, so I don't get the absolute proper peaks.  I can hopefully assume a lot of the leakage can be removed with a better diode, an output buffer amp and not building things on the breadboard.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4202
  • Country: gb
Re: Audio bar graph. Small!
« Reply #51 on: April 01, 2018, 02:06:23 pm »
Right I went through a handful of different opamps I had.

LM358 sort of tracked okay at lower frequencies, but went nuts in higher frequencies and by 20kHz was reading practically zero.
TLE2142 Always seemed to read high, also seemed to have a very high input impedance as the cap didn't discharge very quickly at all.  However it suffered from a DC offset at lower levels and lack of tracking at higher frequencies.
LM741... just no.

So I came back to my trusted NE5532 and gave it a higher rail, 9V.  It definately drains the cap faster, but I think a 1uF MLCC is enough if I'm sampling at 100Hz as the peak detect is near perfect with only about 50mV droop at 20Hz.  Above 10Khz it introduces a small artefact at the peak which seems like the opamp lags behind and then spikes to catch up, then oscillates, but it's a very minimal number of mV.

I was hoping to keep the rails 5V so the peak detect circuit would clip anything the ADC would not like. 

Can anyone suggest a decent RRIO opamp for this purpose, given that the LM358 is supposed to be pretty close to RRIO but didn't work and the TLE2142 goes to Vcc- +0.1V and it produced a DC offset at low levels.

Beyond that the wider project will have the higher rails for the NE5532 and I can clip the output of the peak detect circuit other ways if needs be.
« Last Edit: April 01, 2018, 02:08:49 pm by paulca »
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Online BrianHG

  • Super Contributor
  • ***
  • Posts: 7992
  • Country: ca
Re: Audio bar graph. Small!
« Reply #52 on: April 01, 2018, 02:43:00 pm »
Just power your opamps from you +/-15v supply.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19807
  • Country: gb
  • 0999
Re: Audio bar graph. Small!
« Reply #53 on: April 01, 2018, 07:46:46 pm »
Also, no matter what system you choose, when feeding audio from your pre-amp to your digital PCB, if you will be using series resistors for noise isolation, place those resistors on your pre-amp board.

The 1/2 vdd v-ref bias resistors go on your digital pcb.  (Note, the ADC in the MCU is configured to go from GND to VDD, I would place the 100k on your preamp board near the audio connector leading to the digital VU meter board.  That resistor prevents backward noise and protects the input of your micro's ADC.)

vdd ------------------------
                                 |
                             1meg
                                 |
 audio-100k --- 1uf ----*------ adc pin
                                 |
                             1meg
                                 |
gnd -----------------------
You could use a virtual earth/ground IC, such as the TLE2426, or if there's a spare op-amp, that could be used to buffer a potential divider, then you only need one 1M bias resistor per input,
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4202
  • Country: gb
Re: Audio bar graph. Small!
« Reply #54 on: April 01, 2018, 08:02:14 pm »
I've decided to go with the peak detector circuit, so I don't need the virtual ground as the peak detect (in simple form) is half rectifying anyway.

I did get a prototype working.  With a number of caveats.

Using the NE5532 as it worked best I can't approach the lower rail, so I added a virtual ground to add a DC offset of about 1.8V and ran the opamp on a 9V rail.  This meant i could only measure about 3.2Vpk due to the 5V limit on the ADC.

I didn't implement the multiplexer to reset the peak hold yet.

When I coded it up, subtracted the offset and turned it on it is very convincing.  It will need calibrated and the code ironed out a little.

The Arduino ADC pulls the peak hold cap down fast, even with a 100k resistor in series.  So I might need to go up a few cap sizes.  In the prototype I'm only sampling one channel, so it's fine, but sampling 8 channels I need the peak to hold longer.

For the actual project I am going to take Brian's suggestion and just power the peak detect opamps from the +-15V rail to avoid issues and clip the output at 5V, or maybe 5.5V so as to ensure I get the full ADC but don't upset it too much accidentally dumping a spike of +15V into it at power up/down.  Clipping via diodes or LEDs with an DC offset from a trimmer.

I have so many building blocks in this project, most of them progressing, I am getting more and more concerned about how to systems engineer it all together at the end.  I suppose that's the point though.  Set a challenge and chip away at the details until all is left is to put it all together.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4202
  • Country: gb
Re: Audio bar graph. Small!
« Reply #55 on: April 01, 2018, 08:19:07 pm »
Excuse the horrible audio recording, but it does work!  Based on the peak voltages the LEDs are fairly close to expected too.

Oh and a set of Pixel LEDS was so much easier than wiring up a 10 segment bar LED.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 
The following users thanked this post: BrianHG

Offline Audioguru

  • Super Contributor
  • ***
  • Posts: 1507
  • Country: ca
Re: Audio bar graph. Small!
« Reply #56 on: April 01, 2018, 10:54:36 pm »
Paul, in your first post you mentioned the obsolete LM3914 that is a linear voltmeter. An LM3915 is a logarithmic audio level meter circuit with 3dB steps and a range of 30dB for its 10 outputs. They can be cascaded for a range of 60dB or 90dB. Many shops and kits still have some LM3915 ICs in the DIL package. Its datasheet has schematics of average and peak detectors.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4202
  • Country: gb
Re: Audio bar graph. Small!
« Reply #57 on: April 02, 2018, 05:43:15 pm »
I'm just wondering if I can make it smaller.  I would need 8 x LM3915s. 

It's still an option though.

I looked at making the 8 x 10 segment display with an MCU and after hitting a few dead ends, I came up with this:


Requires only 3 MCU pins.  Allows up to 50mA per LED block, 5mA per LED. 

My first attempt was with 5 LED drivers and a non-multiplexed display, which would be fine and take a lot of the burden off the MCU while it samples the ADC, however the peak current consumption could be as high as 160mA even if only 2mA per LED is used.  The power supply for the whole project is 200mA and I'm already concerned about it, so unless I power the meter board separately, 160mA is too much.

My second attempt was to use two LED drivers to multiplex, but that was quickly aborted as all LED drivers are current sinks, not current sources.

My third attempt was with the 4067 multiplexer and that limited me to 25mA per 10 digit block, due to the 25mA per pin limit on the 4067.  I did consider attaching each 10 segment to two pins, then realised that's blond as the multiplexer only has one active output.

So... adding a high side mosfet onto the multiplexer gets me the higher current for each 10 segment block.

I'm not sure it's correct of it will work.

It "should" be smaller.  An 2xSSOP-24s + 1xQFP-32  + a couple of quad op amps/capacitors on the front end. That I would need with the LM3915s anyway.  That should be fittable on a board not much larger than the LED bars, athough the bars are through hole which might lead to some interesting layout shenanigans.

Besides doing it with an MCU means I can do cooler things with the LEDs as well... and output two channels for strips of NeoPixel LEDs and drive the master levels into half meter LED strips up the back sides of my monitor.... might be cool.  Stuff like that.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline paulcaTopic starter

  • Super Contributor
  • ***
  • Posts: 4202
  • Country: gb
Re: Audio bar graph. Small!
« Reply #58 on: April 02, 2018, 05:52:59 pm »
Acutally I'm not entirely sure the S0-S2 lines to the multiplexer will work with pull ups into constant current sink ports of the LED driver.

The 5V is coming through 10k.  So 0.5mA.  I could make them 100k and make it 50uA.  When the LED driver opens that drain it will attempt to pull the current set by iREF, which is going to be orders of magnitude higher than the 50uA, so if that theory is correct, yes it will pull the S lines low.
"What could possibly go wrong?"
Current Open Projects:  STM32F411RE+ESP32+TFT for home IoT (NoT) projects.  Child's advent xmas countdown toy.  Digital audio routing board.
 

Offline schmitt trigger

  • Super Contributor
  • ***
  • Posts: 2307
  • Country: mx
Re: Audio bar graph. Small!
« Reply #59 on: April 02, 2018, 09:02:52 pm »
Acutally I'm not entirely sure the S0-S2 lines to the multiplexer will work with pull ups into constant current sink ports of the LED driver.

The 5V is coming through 10k.  So 0.5mA.  I could make them 100k and make it 50uA.  When the LED driver opens that drain it will attempt to pull the current set by iREF, which is going to be orders of magnitude higher than the 50uA, so if that theory is correct, yes it will pull the S lines low.

I believe your reasoning is correct.
The only thing I would do is to double-check the datasheet Ioh leakage current, (if any) just to ensure that S0 thru S2 will be pulled high with your chosen pullup resistor values.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf