Differentiating Then Integrating To Eliminate An Offset

This is a pretty common tactic isn't it? In situations where a discontinuity in the derivative is possible, undefined for a short period, the wave could be clipped or somehow limited before the integration.

Bret Cagill

Reply to
Bret Cahill
Loading thread data ...

Of course, there is the "constant of integration" if you use a true integrator, and all real integrators drift and pile up errors. And any clipping or other nonlinear processing of the derivative injects a permanent error into the integrator. No, it's not a common tactic.

The simple AC coupling/highpass circuit is just

IN---------capacitor------+-------------OUT | | | resistor | | | ground

which, of course, loses any useful DC component in the signal.

There's also the dc-restore circuit, where the resistor above is replaced by a switch. Close the switch now and then when you know the signal is "zero."

John

Reply to
John Larkin

That is what needs to be zero. The goal was to center the sine wave on zero.

Another way was to average to the DC component and then subtract the DC from the original signal. An averager circuit on SPICE seemed to be pretty fast, less than a few cycles.

One big advantage with differention-integration, however, is the same circuit could be used to eliminate square waves as well as DC.

Two different situations can be covered with one circuit -- much more flexible.

From cycle to cycle?

If it's over a short time, say, a few degrees, a comparator could detect it and maybe substitute some plausible value over the duration of the spike. If it's a short enough time the error might be small.

Losing DC and lower frequency noise is the goal but it must be within

0.5% in just a few cycles.

That was the other appeal of of taking the derivative and integrating

-- a near zero time constant.

The signal will be zero pi/2 after the derivative is zero or discontinous or exactly between the peaks. What's the name of the circuit that determines the period for each half cycle then uses half that time to predict when the signal will be zero?

That circuit must be as common as XXX movies about lesbian judges harassing their female law clerks.

Bret Cahill

Reply to
Bret Cahill

Any time you'd like to start being coherent, we're ready.

John

Reply to
John Larkin

John I wonder why you humor Mr. Cahill. If you didn't respond he might go away?

George H.

Reply to
George Herold

I wonder would a simple AC coupling with bias resistor set to 1/2 Vcc (or whatever is the appropriate voltage) produce the desired symmetry?

Reply to
David Eather

(I guess that is what you were suggesting)

Reply to
David Eather

Numerical differentiation is notoriously unstable and almost always needs great care to get it right for even slightly awkward functions. What you propose seems like a very brutal way to lose accuracy.

It isn't clear whether you are talking analogue (which will be band limited by the slew rate of the amplifier) or digital signals here.

Why not state the original problem and you might get a sensible answer.

Regards, Martin Brown

Reply to
Martin Brown

It's just an analog op ap circuit.

There are actually two situations. It would be desirable to get both with one circuit so the operator doesn't need to remember to flip any switches.

The first has some DC that needs to be subtracted and the other has a square wave +/- V (same frequency + 90 degree phase angle) that also needs to be subtracted.

The original solution for the DC situation was to just average the signal to DC and then subract that from the original signal.

This seems to work on SPICE if not actual circuits.

The original solution for the square wave situation was to integrate. When the first derivative was positive add the integral to the original signal and when the first derivative was negative subtract the integral.

But if the differentiation - integration approach can be made to work, only one circuit is necessary.

Bret Cahill

Reply to
Bret Cahill

Differentiating requires very high gain at high frequency, and amplifies broadband noise. Practical differentiators always have a high-frequency cutoff, so are effectively high-pass filters. Integrators always benefit from a low-frequency cutoff, or offset voltages would result in saturation of amplifiers, so are effectively low-pass filters.

Combine them, you have a bandpass filter. Yes, that's one way to attack an offset voltage problem.

Reply to
whit3rd

"> Integrators always benefit from a low-frequency cutoff, or

Except if the integrators are inside a control loop. Then (at least sometimes) it's better not to roll them off with a big resistor.

George H.

Reply to
George Herold

OK. John has already shown you how to AC couple and clamp to earth to lose a DC bias. This is basic stuff. You might also need to use a zero adjust trimmer on the opamp to get exactly zero output depending on your tolerances.

What sort of frequencies? And is the wanted component a sine wave or a mixture of frequencies in a broadband signal.

If you have the reference squarewave available why not add the right amount to cancel it out? Otherwise you need a PLL to recover it and had better hope the wanted signal doesn't mask the carrier.

What purpose does this thing have?

Seems likely.

Nonesense. If you differentiate a square wave and then integrate it again you get another square wave (slightly degraded in the real world). You demonstrate remarkable cluelessness.

\\ / \\ / \\ / \\ / \\ integral _ _ _ _ _| |_| |_| |_| |_ raw signal

_|_ _|_ _|_ _|_ _ derivative | | | |

It is a general property of all reasonable functions that the integral of the derivative looks like the function to within an additive constant. What you propose simply will not work.

Regards, Martin Brown

Reply to
Martin Brown

.
0.5 - 1 Hz

Something pretty close to a sine wave. I only need to know that it's well behaved.

The magnitude isn't known directly.

f(x) =3D DC + sinwx

f'(x) =3D wcoswx

Int.[f'(x)] =3D sinwx + const.

Set const. =3D zero to eliminate DC.

Consider that a square wave is just a DC signal that periodically changes values. The derivative of a square wave is always zero except for when it is changing values.

As mentioned above, when the derivative is undefined, a comparator could trigger a circuit to substitute the last known value of the derivative for the duration of the spike, maybe a few degrees -- 30 -

40 msec in my case.

For a 90 degree phase angle between the square wave and a sine curve the last known value of the derivative would be very close to zero.

Integrate the patched derivative that to recover the original signal w/ o the square wave.

Some phase angle issues may appear and need treatment but one circuit will work on square waves, any arbitrarily intermittent DC as well as conventional DC.

Try differentiating and integrating a square wave on SPICE and see what happens.

Bret Cahill

Reply to
Bret Cahill

AC coupling which you have already been shown is a lot simpler.

For an ideal infinite bandwidth square wave perhaps. Most real signals tend to have finite bandwidth. YMMV.

It can also be expressed as a sum of its Fourier components by a well known formula. So guess what. For any reasonable function even one that is piecewise discontinuous you get back a scaled version of it limited only by the slew rate of the original waveform and clipping on the derivative spikes.

I don't care what defects SPICE has simulating this problem I know what the results will be in the real world.

Regards, Martin Brown

Reply to
Martin Brown

.

er.

th

ur

d
,

The error must be below 0.5% in less than 4 - 6 cycles in one situation

Also it would be nice to have one circuit for both situations.

t

The area of the spikes is less than 1% on SPICE. They alternate +/- to cancel each other out each cycle so there is no need to deal with them before integration.

-

).

Nothing like a square wave will reappear after integration regardless of the real world components.

Bret Cahill

Reply to
Bret Cahill

t
s

ns.

d
.

swer.

both

ny

o

ro

your

o

's

had

e.

rk,

ept

0 -

w/

ld).

CORRECTION:

Unless the spikes are knocked out after the differentiation the square wave will reappear on integration.

Bret Cahill

Reply to
Bret Cahill

It's true on SPICE as well.

But I found an easy way to eliminate as much of the square wave as necessary.

Take one or more derivatives until the amplitude of the spikes is >>

than the sine curve.

Then amplify just enough so almost all of each spike is clipped by the limiting voltage but not the sine curve. (I don't know if this is "clipping" is kosher or not.)

Then integrate back -- if necessary -- to recover the sine curve.

Bret Cahill

Reply to
Bret Cahill

If there is high frequency sine noise first use a low pass filter.

Bret Cahill

Reply to
Bret Cahill

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.