Maker Pro
Maker Pro

Cascading digital gain op amps - Decibel measurement

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Hello all

I am working on an op amp circuit, for high resolution decibel measurement. But I have been having some trouble getting the wanted behavior.

I want to use digi pots to control the gains on the cascading op amps and to measure the amplitude. The final signal will be feed into an micro, where I will scan through the gains to find the most relevant range. Later on I intend to add an analog multiplexer so i can sample multiple microphones, but I don’t think that will make much of a difference to this part of the circuit.

I’m currently using a single power rail and I aim to make the most of my ADC hence a rectifier. My other reason for using a rectifier was to avoid problems of instability only using a single supply. But that might be worthy as most of the resolution comes from the gain control?

Here are the things I have tried and the problems found
  • I couldn't put the super diode before any amplification, because even super diodes need to saturate i suppose

  • It didn't work when I did it the other way around; the output static and a square wave after the first amp. I tried to follow the circuit suggested here, maybe its just the specific amp?
UFnB_YY43DNEPx3G2f30_RA-w-R31tFWXG5BzNCnaIRvcJ4ojsGzT5q7Gm7D5Nxw2fM1dPIlhTY-Ncvlu4f70KzOzDoxELWyx3Syf_jx_wv5E89hyPDGnI_oel5W3Fy2eA


In simulation a combination of an inverting amp and super diode worked, but only with a negative supply. In this case using a 9v battery; in practice the voltage follower didn’t work (using LM324), it gave +3.92v while the voltage divider was altered to -.35&8.76 vs 4.5&-4.5 without being connected. Showing final signal below

Ldr0rHevN-YLm9o0Fy7DEd_5N_wP21QWWb0__OpdOHphqHNStaIDHZDpgIQDqRgKHTT4wOQtTy_dzL3ySc-tAEBCROTpZ1xo1u3BQwHQKWJWdykzHDuZJx3v8Sf67DEc0w
.

I half tried the two batteries in series trick, hence a battery grounded on the high side. The backwards battery quickly heated up the op amp! I don’t see how a second battery on the positive side would make a difference. could add MAX232 but they are expensive. Creating negative voltages


2n9ooSJgECZ9zcxBQGWJJkjEL3jrNywk-Y40Hc9klHWcOwSfLIHwCTnht9B58XHRyWRTcZa-k2JYZIMHnL5DI5YldMsti4smLfrIwyp4_kxZ53xI_1Smlhh-JBOWNQFRBw


Probably the most successful circuit I tried was the following, even though it half works for all the wrong reasons. Practically the signal ended up being a little in the negatives, I assume this is because i’m using the op amps outside of their intended use. Trying to see the ADC readings over serial I saw a wave form, but the scope was a mess from the serial communication, I lost sight of any waveform .The output didn’t change when i turned the input signal off, which is never a good sign.

YfeR5XzBv5mPFoCmKhUletlCD5RYv8mG0ZBTFFeTmABz-UPVgMsUlxQ3byOkqVYzRYOYAJEKaSDfbrnS-tKBQKlI3QB0O7Np1gsE_GD9NACDzLQZWrsNA-LYulYccTh1gA



I don’t have a lot of experience with op amps, so any advice is welcome. Hopefully I can get through this before mid semester break is over. Thanks
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
There are several issues:

  1. Your "super diode" is a bad design. For a negative ouput there is no feedback and the opamp will saturate. A much improved design is here.
  2. U2 has a reference potential of 2.5V at the "+" input. This puts the outputa at 2.5V for 0V input signal. U2 has a gain of -1 for the input signal, which is 1V (peak).. Therefore the output of U2 is 2.5V+-1V which is always positive and the "super diode" will always be passing the signal. No rectifiying occurs with respect to the 0V reference of the input signal.
  3. If you use a single supply, you need rail-2-rail opamps. The LM324 definitey isn't one.

I suggest:

  1. Use a dual supply (e.g. 2*9V batteries using your "batteries in series trick" as shown in your post with the 2*AAs).
  2. Use a good "super diode" (see my link).
  3. Use rail-2-rail opamps or use LM324, but be aware that you are limited to approx. +-5V output with a +-9V supply.

See this simplified example:

bla-png.14819
 

Attachments

  • bla.png
    bla.png
    202.8 KB · Views: 398

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Thanks for the help Harald

Yes I get that that first diode circuit it a lesser option, I was just trying to replicate the circuit here. So I could then add the extra amp to get the larger gain range. That diode circuit doesn't handle larger frequencies I heard.

I'll give using two batteries a go soon. I have been using the better diode circuit as I show in the second simulation, which is what I will test the double battery set up with.

LM324s:
Rail to rail isn't a big deal I don't think, unless pushing those limits are a problem.(which I intend to do)
limited to +-5?, why is that? Not that its a problem at all for my application because I only want a positive input. I'm only going for the negative supply because I haven't been able to get it working on a single supply.
 
Last edited:

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
Jan 21, 2010
25,510
Joined
Jan 21, 2010
Messages
25,510
That diode circuit doesn't handle larger frequencies I heard.

This is often caused by the op-amp saturating and requiring a long time to recover. Harald's suggestion to prevent saturation will have the benefit of improving speed.

limited to +-5?, why is that?

because a non rail to rail output can't swing all the way to the supply rails. Check the datasheet to be sure, but Harald is suggesting that the particular op-amp cant swing closer than about 4V to the supply rail. These limits are dependent on current too, so they get worse if anything (including your feedback loop) places a load on the output of the op-amp.
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
I have tested my second circuit with the double battery setup and its giving a mostly positive result. The only thing is that for some reason the signal ins't sitting on gnd? I'm lost on why that could be. Is it the diodes i'm using (1N4148i)? I don't think I will have a fun time feeding that into a micro.
0
0
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Images are not visible, please upload them.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
I can't, for the life of me, decipher your circuit from the photo. Please show us the circuit diagram and indicate where you measure which signal.
 
Last edited:

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Its the second circuit I posted originally and I show the out put signal. I didn't put the bread board in to communicate the design, I just thought i might as well. For clarification its the circuit below, Sorry for the confusion. Note the real circuit uses a microphone, It gives a amplitude of around 1mv I think. 1.5v would hit the roof hard.
TShOUJV0EoH885C9x1GymhoLoS3PFXw_cfQZeB_ZwA4wOoA8MPxl7lRlRxXLFW-DvZhKhbFz9rZZuCvjPRfbPZCT045qrLe05RoJdrRE_Nooa3OZU1dg9KsCh_yAfcGN2Q
 
Last edited:

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
The circuit has a gain of 100. 1V offset at the output is easily generated by only 10mv offset at the input. measure the dc level at the input and at the cathode of D2 for a nominal 0V input (short circuit V3). The LM324 has an input offset voltage of up to 4mV plus a bias current of up to 200nA, the latter will provide an additional offset voltage of 2mV at 10kΩ input resistance. You can compensate the offset e.g. by connecting R5 not to GND but to a small potential through a potentiometer (poti to adjust the offset, e.g. use a 1k potentiometer which is connected to +9V and -9V by a 10kΩ fixed resistor on each side).
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Ohhh yes I see! all of the simulation must be making me think like a physicist ;) Its because the circuit is sensitive with the large gain and no component is perfect of course.

I'll give your suggestion a go tomorrow and tell report back how it goes, thanks Harald!
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
How much of a difference does it make if the two batteries have different voltages? Yesterday the circuit was working fine and today as I go to add the voltage offset, every output is flat lined. One of my batteries is brand new @9v+ and the other has now dropped from about 7 yesterday to 4.5v today. Is that really killing the output, or have I pulled out a lead I can't see? Not that its a big deal to get another battery, I'm still curious to why if it is causing the problem. Thanks
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
How much of a difference does it make if the two batteries have different voltages?
It is no big deal as long as the voltages are high enough for the ampifiers (so. e.g. 7V /9V could still work).
In your case, however, a 9V battery showing only 4.5V is flat, it will not deliver usable current. Plus the LM324 needs a supply voltage that is ~4V above the max. output voltage (se above discussion on rail-2-rail opamps). With only 4.5V to work from it will not work.

Note also that my suggested way of trimming the offset relies on equal (better even: stable) supply voltages. If the voltages vary and specially if they vary differently (like e.g. 7V/9V), the trimming must be repeated. In that case you may be better off by
1) using low-offset opamps
2) first amplifying the AC signal and using AC-coupling (capacitor) to the rectifier stage. This will at least eliminate the offset from the first gain stage.
3) increase the gain of the first stage, use AC-coupling and reduce the gain of the second stage (super diode) to further reduce offset.
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Thanks for the suggestions Harald, sorry for the late reply.

How does one choose the right capacitor for AC-coupling? Its just choosing the correct RC constant is it not? What frequency would I want to aim for, somewhere just below my expected range?

Do u think that there is any reason why a digital potentiometer will not work in place of fixed value resistors? With fixed value resistors my circuit (as shown in the last picture I posted) switching to the digipots flat lines my output. I don't see why the digital pot would make much of a difference? I have had gain control working with the digipots before, but those circuits were wrong in other ways.
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
The capacitor is part of a high-pass filter, as you recognized.The corner frequency of the filter is chosen such that the pass band is well within the range of frequencies you want to pass - that's why it is called pass-band :)

Gigital potentiometers may work in this circuit. If they don't you haave misses some specs of the digital potentiometers. Which ones are you using and how are they connected into the circuit?
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Oh yeah so it is a pass filter, how will that change the voltage offset? Ohh well I guess interference from mains could appear like an offset depending how i'm looking at it.

I'm using the DS1804: connected from the high side to the wiper, for the variable resistor as needed. I also have to pull the chip select low to keep the communications integrity, but apart from that its just straight to the mirco from communication and then the power rails and +5v and gnd. They are replacing R1 & R4 in my last circuit posted.

Thanks
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Offset is DC and will be blocked by a high pass filter.

The DS1804 is a 5V part. Voltages at the H, l and W terminals must not be higher than Vcc (5V) or lower than GND (0V). You operate the digital pot outside its specification, therefore no wonder it doesn't work as expected.
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
Oh yes I see, because only voltages above the set frequency will make it through.

Oops that's a bit embarrassing, seems I was thinking to discrete. Now the question is what will be easier to find and order, batteries within the range or digipots with a larger range. I have some 3.75v batteries, but that might be a waste of the ADC. Do u think I would have fried the 5v digipots? They might have some internal protect, bypassing or something.

Thanks Harald
 

Harald Kapp

Moderator
Moderator
Nov 17, 2011
13,700
Joined
Nov 17, 2011
Messages
13,700
Lok for an audio potentiometer. A quick search turned up this one. It is suitable for signals up to +-7V which I think fits your range (as the op amps are not going to the full +-9V rail), It also features a logarithmic characteristic, which may come in handy for db measurements. Otherwise look for a similar one with linear characteristic.
 

Quwat

May 31, 2013
37
Joined
May 31, 2013
Messages
37
The 5v range of the digipots I current have shouldn't be causing a problem, the signal isn't amplified to above 5 before going through the pots. Does that rule out the 5v limit causing my problem? I will never need it to be larger than 5v either way because the ADC range is 5v as well. Yes a pot with log characteristics would be a good idea, I will look into that more once the basics are going. Thanks
 
Top