Removing DC Offset

Thread Starter

Gareth_71

Joined Dec 1, 2017
15
I think #4 is the way to go. The LM393 front end, powered by a single positive voltage (5 V to 36 V) is designed specifically for this type of signal. It will end up acting as a diode with 0 V offset. I'll try to whip up a schematic later.

ak
Many many thanks!
 

Thread Starter

Gareth_71

Joined Dec 1, 2017
15
Hi

The LM393 does not work simply because the ref voltage is not midway between the High and Low voltage.

For example, say the offset voltage is 12v, the signal is a square wave with low being 11.5v and high being 12v. So the signal never crosses the reference voltage so a comparator will not work, unless I can find a way to subtract 0.25v from the from the offset voltage whatever the offset voltage may be.

Any ideas?
 

MrAl

Joined Jun 17, 2014
11,396
Hi All

I am new here, so be gentle :)

I am currently struggling with what should be a simple analog problem:

Need to convert a square wave signal to a 0v based square wave.
I.E. The signal has an amplitude of 0.5v, but a varying offset from about 11.5v to about 13v.
How do I reject the offset?

I have tried to use a DC block with a cap but end up getting a negative voltage component which is not desirable (the entire circuit is single supply).

Also tried many other solutions to no avail, including using a high voltage instrumentation amp (INA126).
As you may be able to tell, my skills are digital, not analog!

Gareth
Hello there,

This is not an uncommon thing to do except more common is a sine wave being measured.

What we know so far is that the amplitude is 0.5v, but is that peak or peak to peak and what is the frequency?
What else we know is the DC offset varies from 11v to 13v roughly, but how fast does that vary?

The usual method is to simply use a voltage divider and use a cap to couple the signal to the voltage divider. That way you get a signal that is all positive but still has the AC component riding on top of it. So if you have a 2R voltage divider and +5v supply the signal would go from 2v to 3v if that 0.5v was a peak value.
If you need to amplify it and you can use an op amp, that should be easy.

However, it would be best if you were to specify the more exact quantities involved here.
The amplitude value in peak or peak to peak, and any variation.
The DC offset variation frequency, fast, slow, 1Hz, 2Hz, 0.01Hz, etc.
The required output signal level, +5v, +2.5v peak, whatever.

The better you specify the signal you have to work with the better we can design the network to work with this.
The reason for the spec on the DC offset change is because that is the same as a second seignal in addition to your square wave that must be dealt with effectively in order to prevent false signals on the output.

Another little example would be a 4k resistor in series with a 1k resistor going to +5v, so we get 1vdc across the 1k resistor. With a coupling cap from your input signal to the voltage divider, the signal would go roughly from 1v down to roughly 0v instead of plus and minus 0.5v or so.

Another example is very simple if your output device can read a 0.5v signal properly. That is a 5k resistor in series with the coupling cap. The next circuit can clamp the signal stopping it from going too much negative, but that depends on the next circuit of course such as if it was a microcontroller.

So better spec's on what you have now leads to a simpler, better design.
 

AnalogKid

Joined Aug 1, 2013
10,987
Something like this. Still need to know input frequency, input signal source impedance, output signal amplitude, output signal load current.

Note: the input is *not* intended as a highpass filter or differentiator. To preserve the input signal wave shape, the R1-C1 time constant should be 3x larger than the input signal period.

EDIT - Updated schematic with correct comparator part number.

ak
DC-Level-Shift-1.gif
 
Last edited:

eetech00

Joined Jun 8, 2013
3,859
Hi

The LM393 does not work simply because the ref voltage is not midway between the High and Low voltage.

For example, say the offset voltage is 12v, the signal is a square wave with low being 11.5v and high being 12v. So the signal never crosses the reference voltage so a comparator will not work, unless I can find a way to subtract 0.25v from the from the offset voltage whatever the offset voltage may be.

Any ideas?
Hi

Perhaps you can draw a picture of the wave form in a voltage vs time format so we can see the signal we have to work with. Take a photo of the drawing and post it.

Also post a picture of the desired (or conditioned) waveform

eT
 
Last edited:

MrAl

Joined Jun 17, 2014
11,396
Something like this. Still need to know input frequency, input signal source impedance, output signal amplitude, output signal load current.

Note: the input is *not* intended as a highpass filter or differentiator. To preserve the input signal wave shape, the R1-C1 time constant should be 3x larger than the input signal period.

EDIT - Updated schematic with correct comparator part number.

ak
View attachment 143431
Hi,

I think i would add a 100 ohm resistor in series with pin 3 if i did it that way.
The other consideration is loading on the source signal, which we still dont know too much about.
 

AlbertHall

Joined Jun 4, 2014
12,345
And the whole thing gets more complicated if the frequency gets very high or very low or, worse, down to zero.
Please give us the frequency range of the signal.
 

BobaMosfet

Joined Jul 1, 2009
2,110
Just interjecting, because I think this is relevant- a Hall Effect sensor is a polarity device. Waveform is indicating polarity based on direction of voltage edge. In a DC environment, it arbitrarily sets up an artifical 'zero' for this waveform as about half the DC voltage.

If you wish to eliminate the 'negative' side of the waveform, in a DC environment, the easy way is to use a voltage divider. This maintains amplitude of the original upper-half of the waveform. Once this is done, in order to bring the waveform closer to the rail voltage, use a Schmitt trigger.

Simple, Straight-forward.
 

AnalogKid

Joined Aug 1, 2013
10,987
in order to bring the waveform closer to the rail voltage, use a Schmitt trigger.
A Schmitt Trigger is a positive feedback circuit configuration, and as such has no affect on the output stage performance of whatever is implementing it. The output high and low saturation voltage levels of whatever is being used (analog comparator, opamp, CMOS gate, etc.) do not change based on the feedback circuit design.

ak
 

BobaMosfet

Joined Jul 1, 2009
2,110
A Schmitt Trigger is a positive feedback circuit configuration, and as such has no affect on the output stage performance of whatever is implementing it. The output high and low saturation voltage levels of whatever is being used (analog comparator, opamp, CMOS gate, etc.) do not change based on the feedback circuit design.

ak
I beg your pardon, you are correct. It's useful for cleaning up the wave form. A simple AND gate could be used to bring the voltage back to rail. Or an OpAmp.
 

MrAl

Joined Jun 17, 2014
11,396
That, or a 1N914 (or a 5 V zener) in parallel with R1, or both. Can't say without more information from the TS.

ak
Hi,

Well sorry but still not quite there if you want to be careful.

The 1N914 is a regular Si diode if i recall, and the internal ESD diode is probably a Schottkey, so the Schottkey is going to conduct before the Si diode. Thus, i would add a resistor simply to limit current to the ESD diode.
Of course to be really careful, both a 1N914 diode and also the series resistor in series with the pin. That limits current to around 0.2/100 amps (2ma) which is really addressing the issue to the fullest. That's the best i think without going to an active circuit unless you want to use another Schottkey and then the current is limited to the mismatch differential voltage divided by the series resistance which could be just microamps.

I ran into problems like this with all of the microcontrollers out there, but the more problematic was the ARM which has severely limited ESD diodes unlike the MC chips i worked with.
 

AnalogKid

Joined Aug 1, 2013
10,987
Well sorry but still not quite there if you want to be careful.
Been decades since I've read the LM393 datasheet in detail ...

1. The simplified internal schematic shows internal standard diodes to protect against input overvoltage, but nothing for undervoltage. While the absolute min input voltage is listed as Vee-0.3 V, the applications section mentions external diode protection and says to see the schematics for examples. The schematics clearly show 1N914 input protection diodes for AC coupled inputs.

2. Here's a shocker: "It is usually unnecessary to use a bypass capacitor across the power supply line."

3. Another surprise: "All input pins of any unused comparators should be tied to the negative supply." Usually this is not recommended because it can cause output transitions based on noise, drifting offset voltages, etc. But there it is.

upload_2018-1-10_17-58-3.png

I ran into problems like this with all of the microcontrollers out there, but the more problematic was the ARM which has severely limited ESD diodes unlike the MC chips i worked with.
I agree about uC's being delicate, but there is a fundamental difference between a 20 year old, 3.3 V or 5.0 V part built on a 12 V CMOS process, and a 45 year old, 36 V part built on a 60 V analog process.

ak
 
Last edited:

MrAl

Joined Jun 17, 2014
11,396
Been decades since I've read the LM393 datasheet in detail ...

1. The simplified internal schematic shows internal standard diodes to protect against input overvoltage, but nothing for undervoltage. While the absolute min input voltage is listed as Vee-0.3 V, the applications section mentions external diode protection and says to see the schematics for examples. The schematics clearly show 1N914 input protection diodes for AC coupled inputs.

2. Here's a shocker: "It is usually unnecessary to use a bypass capacitor across the power supply line."

3. Another surprise: "All input pins of any unused comparators should be tied to the negative supply." Usually this is not recommended because it can cause output transitions based on noise, drifting offset voltages, etc. But there it is.

View attachment 143457


I agree about uC's being delicate, but there is a fundamental difference between a 20 year old, 3.3 V or 5.0 V part built on a 12 V CMOS process, and a 45 year old, 36 V part built on a 60 V analog process.

ak

Hi,

Yes i agree #2 is a little surprising.

I'll agree that the 1N914 internal ESD diode leads to a more comfortable design, slightly, but then the -0.3v spec doesnt make as much sense. I can live with that though :)
However, if they really use 1N914 diodes then if we use an external 1N914 diode that will be in parallel with the internal ESD 1N914 diode.so now we have the impossible situation where we try to predict which diode draws the most current and how much. It depends highly on the difference in diode characteristic voltage and temperature...which would typically boil down to which diode is hotter, and how much hotter it gets after the current starts to flow, and how much hotter it gets after that, etc. With the series resistor added though, there's nothing to guess at there.
I'll tell you what the chief engineer would have asked me back in the 1980's if i suggested an external 1N914 diode alone, and that would be, "if you can accurately predict and calculate the current through the internal diode for all possible environment and operating conditions both electrical and thermal and that current does not exceed the rating of that diode then you can do it, but if not, then add the resistor, because adding the resistor makes it simple to calculate the safe operation of the entire circuit for all time.".
.
One of the things i spotted right away was the coupling cap going directly to the pin. With a zero impedance source that gives the circuit the theoretical ability to pump infinite current into the pin, which in the practical case simply means a high current. Since doing something about this is very simple (a resistor) why not do it. If the input REALLY is limited to plus and minus 0.5v, then we dont even need a diode, just a single resistor in series with the cap, something i suggested back a few posts :)

A long time ago they used to design transistor current sense circuits with no series base resistor. At some point they realized that the base might get an over current if the circuit experienced an over current, so they started to add a 100 ohm resistor in series with the base. Doesnt appear to do much but if you know the history of why it was added you soon realize that it does a lot for the protection of the transistor.
 
Last edited:

AnalogKid

Joined Aug 1, 2013
10,987
I'll agree that the 1N914 internal ESD diode...
I must have been unclear. My point is that the internal diode is shown as a conventional diode, not a Schottkey. As an internal structure, it doesn't have a part number associated with it. It is the *external* diodes in the applications schematics that have the part number.

Also, the internal diode is not a conventional ground (or Vee) clamp that is common in microcontrollers and CMOS logic. It is shown as an *over*voltage clamp. There is no undervoltage protection shown in the simplified schematic.
One of the things i spotted right away was the coupling cap going directly to the pin. With a zero impedance source that gives the circuit the theoretical ability to pump infinite current into the pin,
No, it doesn't. Working from memory, the open loop input impedance of a high gain bipolar differential pair is something like 250K. The stated "input resistance" of an LM741 is 6 Meg, and 500K for the LM301 worst case. The input resistance of the LM393 is not stated, but its bias current is 250 nA, almost identical to the other two opamps. For a capacitor to deliver a large surge current there must be a low impedance on both ends, and the IC pin does not present a low impedance to the external source.

As for the capacitor dumping a large current spike into an *external* clamp diode, note that the cap value is 0.1 uF. The total energy at 12 V is only 7.2 microjoules. I think a 100 mA continuous / 500 mA surge part can handle it.

ak
 
Last edited:

Thread Starter

Gareth_71

Joined Dec 1, 2017
15
I am humbled by your replies, thank you!

A bit more about the application:

The signal is a square wave going from (if the supply voltage is say 12v) 11.5v to 12v.
The supply voltage comes from a 12v battery and the circuit operates during charge and discharge hence the supply varies from about 11v to about 14.5v. So the supply voltage changes slowly over time.

Frequency is from 0 to about 10Khz max.

Many, many thanks for your input.
 
Top