What is DC Offset for?

Audioguru

Joined Dec 20, 2007
11,248
Another possible problem is that the output of the opamp averages +6V and needs a coupling capacitor to feed another circuit to block the +6VDC.
 

MrChips

Joined Oct 2, 2009
30,821
Another possible problem is that the output of the opamp averages +6V and needs a coupling capacitor to feed another circuit to block the +6VDC.
That is correct. However, this application calls for a microphone amplifier in order to detect the presence of a signal using the internal ADC of a MCU powered from a single voltage supply.

As an aside, from the onset, I questioned why do we need to offset the signal in the first place. If we simply amplify the AC signal with the opamp inputs referenced to GND we would be amplifying one half of the signal and clip the other half. Do we really care if all we need is the presence or envelope of the sound signal?

My multi-post explanation is meant to show the TS why we have to offset the opamp inputs when going from a dual supply opamp circuit to a single supply circuit.
 

ebp

Joined Feb 8, 2018
2,332
"... why do we need to offset the signal in the first place"

I thought the same thing, but there is a hook that really comes down to the characteristics of the op amp chosen.
The most appropriate amp here is one specified as "rail-to-rail", but you have to read the fine print carefully. There are two aspects to rail-to-rail - input and output.

An amp with rail-to-rail input ability will handle any signal between its negative and positive power supply "rails", so for an amp running with a single supply at 5 volts, anything between 0 V and 5 V.
An amp with r-r output ability can produce an output that swings from rail-to-rail.
Many op amps can't handle inputs close to the rails (due to current mirrors that need some headroom & other bits) and can't swing very close to the output rails due to things like common-emitter stages. Amps designed to run with very low supply voltage must be r-r or they'd be useless.
Some so-called r-r amps are r-r at the output, but not at the input, and none are truly r-r - they get close, but where millivolts are important there can still be problems. An output may swing to the positive rail but only be able to source a tiny sniff of current.

If the output from the mic were in the range of just a few millivolts, some small offset might be necessary to avoid losing almost all of the signal. It really depends on the exact characteristics of the amp. But you still wouldn't need more than just the highest peaks for this circuit.
 

Thread Starter

Jean SP

Joined Feb 11, 2018
13
The problem is the +6V offset on the bottom side of the sinewave generator. Usually, any signal generator is referenced to GND.

Consider what happens when we turn the amplitude of the sinewave output down to 0V amplitude. The DC voltage of the inverting input of the opamp is at +6V. The voltage at the non-inverting input is also at +6V because of the voltage divider. In other words, the two inputs are at the same voltage. In general, any opamp circuit with proper negative feedback resistor will always have the inverting and non-inverting inputs at the same voltage. Any voltage difference would be amplified by the opamp's open-loop gain and the output of the opamp would hit the supply voltage rail (either V+ or V-). In our example shown, the output is at +6V, regardless of the circuit gain -R2/R1.

In order to reference the signal generator back to 0V, we have to break the DC path. We do this by "AC coupling" the signal generator to the inverting input of the opamp using a capacitor.

View attachment 145850

With the capacitor in place, the signal generator can be referenced to any voltage. The voltage at the inverting input is still +6V.

Why?

That is because the role of the feedback resistor and very high open-loop gain of the opamp means that the output of the opamp has to reach a voltage to force the difference voltage at the two inputs to zero.

Now, does this circuit resemble your microphone amplifier circuit?
Thanks for spending time explaining to me ! Really appreciate it. Hope you can enlighten my doubt.
When you say that when the sine wave amplitude is bring down to 0V the inverting will be at 6V ? I thought there is a feedback resistor R2 and the voltage will be divided through R1 and R2. I also not quite sure why the output will be 6V regardless of the gain -r2/r1. Is it because the non inverting is at 6v so the inverting will follow 6v (ideal opamp). I do understand that the capacitor is to block the dc voltage. But what do you mean by reference to any voltage? Also in the video what is the reason to bring the DC offset to 2.5v . Thank you so much !
 

AnalogKid

Joined Aug 1, 2013
11,055
late to the party ...

Without knowing anything about the code running in the uC and what it expects the A/D to see in terms of input voltage, the only reason for the DC offset in the post #1 circuit is what AG pointed out - the 5534 is the wrong part for the job. When powered by a single 5 V rail, it's input common mode voltage range is almost nothing, and is offset way above GND. The LM358 fixes this problem, because its input range includes its own negative rail (GND in this case). If that were the only problem, the 358 would solve it AND without any offset. It would act as a half-wave rectifier with gain, exactly what a clap circuit needs But it isn't the only problem.

Again, the 5534 output stage is terrible in a 5 V circuit. The 358 output stage is much better going down to its negative power pin, but cannot swing very close to its positive rail. Neither can the 5534, so this might not be a problem for the uC code. But a better solution is to find an opamp specified to run on a single 5 V supply with near rail-to-rail inputs and outputs. TI makes many.

ak
 

MrChips

Joined Oct 2, 2009
30,821
Thanks for spending time explaining to me ! Really appreciate it. Hope you can enlighten my doubt.
When you say that when the sine wave amplitude is bring down to 0V the inverting will be at 6V ? I thought there is a feedback resistor R2 and the voltage will be divided through R1 and R2. I also not quite sure why the output will be 6V regardless of the gain -r2/r1. Is it because the non inverting is at 6v so the inverting will follow 6v (ideal opamp). I do understand that the capacitor is to block the dc voltage. But what do you mean by reference to any voltage? Also in the video what is the reason to bring the DC offset to 2.5v . Thank you so much !
Is it because the non inverting is at 6v so the inverting will follow 6v (ideal opamp).
Yes. That is the correct answer. The value of R2 is not important. Let us take, as an example, R2 = 0Ω. The opamp will amplify the difference between Vin+ and Vin- by its open loop gain which can be as high as 100,000. Suppose the difference is 10μV. The output would be 10μV x 100,000 = 1V. But that is not going to happen because the output is fed back to the inverting input. This is negative feedback. In other words, the system self-stabilizes until (Vin+ - Vin-) = 0V.

Hence, Vin+ = Vin-. It does not matter what is the gain factor, R2/R1.

But what do you mean by reference to any voltage?
The capacitor C1, in essence, is a high pass filter. Any signal at 0Hz is rejected. Only frequencies above 0Hz are allowed through. This means it does not matter what is the value of the DC voltage (within some maximum limitation). Your microphone is biased with 12VDC. This is not seen at the Vin- input of the opamp.

Also in the video what is the reason to bring the DC offset to 2.5v .
I have already explained this in tremendous detail and with substantial effort. This is the entire purpose of this thread which has been dragged out to 26 posts. Instead of repeating the same question, how about you expand on what it is that you do not understand.
 

MrChips

Joined Oct 2, 2009
30,821
Also, as discussed elsewhere, you do not need to provide a 2.5V offset for your application. You do not need a 12V power supply. What you need is a rail-to-rail opamp which will run on a single +5V supply. For your application, it would be better to use the opamp in non-inverting mode. Since the LM358 is a dual opamp, use both opamps with moderate gain each. Then rectify and integrate the output to give you an envelope of the sound signal received.
 

ebp

Joined Feb 8, 2018
2,332
Mr.Chips, your circuity is pfttt (an expression a Scottish guy I knew used, pronounced "sir-QUE-i-tree is fut", which isn't really true here since the smoke is still inside)

Your circuit at 18 is biasing the input signal to +6 V, which is not a happy situation for an inverting amp on a single positive supply. You could bias with -6 V, as long as you take a gain less than 2 with 12 V supply.
 

MrChips

Joined Oct 2, 2009
30,821
Mr.Chips, your circuity is pfttt (an expression a Scottish guy I knew used, pronounced "sir-QUE-i-tree is fut", which isn't really true here since the smoke is still inside)

Your circuit at 18 is biasing the input signal to +6 V, which is not a happy situation for an inverting amp on a single positive supply. You could bias with -6 V, as long as you take a gain less than 2 with 12 V supply.
Well, phooey I say to you!

Both inputs are biased to +6V, right in the mid-range of the power supply rails and the opamp would be perfectly ok with that.

It's bad enough when you make a mistake. It's terrible when your mistake is criticizing someone else's work.:rolleyes:
 

AnalogKid

Joined Aug 1, 2013
11,055
Mr.Chips, your circuity is pfttt
Your circuit at 18 is biasing the input signal to +6 V, which is not a happy situation for an inverting amp on a single positive supply. You could bias with -6 V, as long as you take a gain less than 2 with 12 V supply.
His circuit is fine and will work as shown. I suggest you read *all* of the symbols on the schematic. I disagree with his technique of using the same symbol for a voltage source and its return, and having a positive voltage source symbol pointing downward, but the schematic is correct.

ak
 

ebp

Joined Feb 8, 2018
2,332
Mr. Chips
I'm sorry, I was looking post 17, not 18 AND I misread the the +6V on the NII as 0V. You're absolutely right, all is well in that case.

I should know better than to look at things like that on the computer I was using. I've made errors before because I can't see well enough and misread things. But it is my lounging computer whereas my other one is my sittin' like I'm workin' (which I don't do anymore) computer.
 

MrChips

Joined Oct 2, 2009
30,821
Mr. Chips
I'm sorry, I was looking post 17, not 18 AND I misread the the +6V on the NII as 0V. You're absolutely right, all is well in that case.

I should know better than to look at things like that on the computer I was using. I've made errors before because I can't see well enough and misread things. But it is my lounging computer whereas my other one is my sittin' like I'm workin' (which I don't do anymore) computer.
Actually, I'm also to blame. I knew the resolution of the images was not the best but I was in a rush to get the circuits posted for the TS. I should have posted clearer images. Next time I will.

All's well.:)
 

ebp

Joined Feb 8, 2018
2,332
I should add: I've made some remarkably dopey errors in simple circuits on prototype PCBs. I very rarely breadboarded anything and didn't use simulation much, so I usually went from a paper design directly to a PCB. Lots of what I did was very difficult to breadboard anyway. One thing I learned was to do all of the calculations for a circuit before laying out the PCB instead of while I was waiting for delivery of bare boards. I couldn't use most of the fast turn outfits because they wouldn't do things like 4 oz copper on 3/32" laminate, so I usually had to wait a week or more for boards. Doing all the calc's before layout proved to be a good way of finding things that were wrong, and often it was a resistor to the wrong place in an amp circuit. I've probably said "D'oh" almost as many times as Homer.
 

MrChips

Joined Oct 2, 2009
30,821
I should add: I've made some remarkably dopey errors in simple circuits on prototype PCBs. I very rarely breadboarded anything and didn't use simulation much, so I usually went from a paper design directly to a PCB. Lots of what I did was very difficult to breadboard anyway. One thing I learned was to do all of the calculations for a circuit before laying out the PCB instead of while I was waiting for delivery of bare boards. I couldn't use most of the fast turn outfits because they wouldn't do things like 4 oz copper on 3/32" laminate, so I usually had to wait a week or more for boards. Doing all the calc's before layout proved to be a good way of finding things that were wrong, and often it was a resistor to the wrong place in an amp circuit. I've probably said "D'oh" almost as many times as Homer.
I presume that you know you can get one-day prototyping service from apcircuits.
 

Thread Starter

Jean SP

Joined Feb 11, 2018
13
Also, as discussed elsewhere, you do not need to provide a 2.5V offset for your application. You do not need a 12V power supply. What you need is a rail-to-rail opamp which will run on a single +5V supply. For your application, it would be better to use the opamp in non-inverting mode. Since the LM358 is a dual opamp, use both opamps with moderate gain each. Then rectify and integrate the output to give you an envelope of the sound signal received.
Okay maybe i should elaborate more about my doubt. From what i understand , the voltage divider at the non inverting of the opamp is what creates the DC Offset. Does that mean the circuit you drew have an offset of 6v ? So the sine wave will oscillate at the 6v dc offset ?
If you want to manipulate the signal (amplify for example), you need to change the "frame of reference" of the signal so it is between the voltages of your power supply.
Am i right to say that DC offset is needed for amplify the signal? And if i dont include the dc offset will it affect the signal?

Pardon my ignorance, i have tried rereading a lot of the post but flooded with info. Thanks for the help
 

Thread Starter

Jean SP

Joined Feb 11, 2018
13
The problem is the +6V offset on the bottom side of the sinewave generator. Usually, any signal generator is referenced to GND.

Consider what happens when we turn the amplitude of the sinewave output down to 0V amplitude. The DC voltage of the inverting input of the opamp is at +6V. The voltage at the non-inverting input is also at +6V because of the voltage divider. In other words, the two inputs are at the same voltage. In general, any opamp circuit with proper negative feedback resistor will always have the inverting and non-inverting inputs at the same voltage. Any voltage difference would be amplified by the opamp's open-loop gain and the output of the opamp would hit the supply voltage rail (either V+ or V-). In our example shown, the output is at +6V, regardless of the circuit gain -R2/R1.

In order to reference the signal generator back to 0V, we have to break the DC path. We do this by "AC coupling" the signal generator to the inverting input of the opamp using a capacitor.

View attachment 145850

With the capacitor in place, the signal generator can be referenced to any voltage. The voltage at the inverting input is still +6V.

Why?

That is because the role of the feedback resistor and very high open-loop gain of the opamp means that the output of the opamp has to reach a voltage to force the difference voltage at the two inputs to zero.

Now, does this circuit resemble your microphone amplifier circuit?
Will this work ? And does the voltage at the non inverting have to be 2.5v ? And what does the offset do in this case. Can i just pull down the resistor on the non inverting side to gnd ? 0V

1518593521208713268266_Jean SP-n1.jpg
 

AnalogKid

Joined Aug 1, 2013
11,055
Not quite. In your drawing, the signal "after capacitor" will be sitting on the 2.5 V pedestal. This will be true if the DC portion of the microphone signal is either above or below 2.5 V. The capacitor is charged up (or down) by current from the opamp output through R2 and R1. Since these resistors usually are larger than the 1K pullup resistor at the microphone, they set the time constant and determine how long it takes for the coupling capacitor to match the voltage difference imposed across it in the steady state condition.

The opamp output does whatever is necessary to make and keep the voltages at its two inputs identical. Since it cannot change the + input, it changes the - input through R2. This creates a "virtual ground" at the R1-R2 node, a point that the input signal cannot change directly. The input pumps current into (or out of) the R1-R2 node through R1. Since R1 and R2 form a voltage divider between the microphone and the opamp output, this attempts to change the voltage at the - input. The output voltage changes in the opposite direction to increase or decrease the current through R2 to bring the - input back to 2.5 V. If you put a scope on the - input you will not see the audio signal, yet the output is an amplified version of the input.

ak
 

ebeowulf17

Joined Aug 12, 2014
3,307
As an aside, from the onset, I questioned why do we need to offset the signal in the first place. If we simply amplify the AC signal with the opamp inputs referenced to GND we would be amplifying one half of the signal and clip the other half. Do we really care if all we need is the presence or envelope of the sound signal?
This question may be a bit off-topic, so feel free to move it to another thread if it doesn't belong here.

I would've thought you couldn't feed a ground-biased AC signal into a single supply op amp because you don't want the negative component of the AC hitting your op amp input.

Is this treated as ok here simply because the microphone's signal will be too small to do any harm? In other words, you wouldn't set an op amp up as a half wave rectifier the way you described if the AC signal was several volts, right? It's only ok because we expect the signal to be small fractions of a volt. Or am I missing some other reason why this is acceptable?
 

MrChips

Joined Oct 2, 2009
30,821
I would be inclined to go with a non-inverting amplifier (input to Vin+) and connect R1 to ground (0V offset). I would test it on a breadboard first.

Edit: @ebeowulf17 posted before my post. That is a valid consideration. I don't know the answer and perhaps someone else can respond.
 
Top