# Convert a sawtooth with an offset to to an average voltage of 0

I have a sawtooth waveform generator whose frequency varies from 20Hz to 4000Hz and has an amplitude of 5V (0 to -5V), I want it to have an average voltage of zero. There seems to be many examples on the web of using an RC HPF. however not many of the actual calculations used to require the RC values. I am using values currently of 10uF and 10kohms, which nearly gives me what I desire, but how were these values this derived?

Also the sawtooth is not perfectly around 0V, is this a fault in the values or the method?

• If you know the sawtooth to be fixed from 0 to 5V, why not simply subtract 2.5V? May 4, 2018 at 18:22
• And how would that be done? May 4, 2018 at 18:25
• Since you don't give more details, I cant know how your application is, so I can only guess with the answer you see. May 4, 2018 at 18:35

If you know that the input doesn't vary, that is, if it stays from 0 to 5V, then one solution would be a simple subtraction:

You can get the reference from the supply, if it's stable enough and it fits your needs. Otherwise, the highpass would have to have the cutoff at least a decade lower than the lowest harmonic (to not distort the sawtooth), and to be as linear as possible (1st order best), but even then it might vary in time with temperature and whatnot. Your choice, though.

Here are two reasons why I say a highpass is not the ideal choice:

1) you need a high time constant (or low cutoff frequency) in order not to distort the ramp. See the derivative of the waveform after the highpass with 10k$\Omega$ and stepped values of the cap of 10, 22, 47, and 100$\mu$F, that should have been, ideally, flat, and non-curved (traces are black 10, blue 22, red 47, green 100):

(note that they will never be prefectly flat as that would imply a zero cutoff frequency for the highpass, or, at the very least, a perfectly flat passband from the lowest harmonic upwards)

2) because of the above, here's the settling time for all the stepped values of the capacitor:

As a minor conclusion (and as @Harry Svensson suggests it): the cheapest solution is the highpass, but the price(s) to pay are, in my opinion, too great not to invest a little bit more and choose the proposed difference solution, which also brings the ability to control the level of the DC at the output, should there be a need for it.

• Why would this solution be better than the obvious one which is a capacitor and resistor in HP configuration? May 4, 2018 at 20:44
• @HarrySvensson I never said that (if [...] then one solution would be[...]). For highpass you'll need the filter to be at least a decade below the lowest harmonic, which, for OP's requirements, 20Hz minimum, means quite large values for a capacitor, which draws other minor inconveniences (such as settling time). You say the highpass is the most obvious, I say subtraction is, someone else will say something else; I think it's a matter of preference. Of course, this is a bit more involved, but the results are more also stable. Plus, you can choose the amount of DC, if you wish. May 5, 2018 at 5:58
• If you had that information in your answer I'd given you a +1. Just saying. I know why, you know why. Now OP also knows why. May 5, 2018 at 8:59
• @HarrySvensson You mean the part above the picture and below it? If you read it, it comes down to what I said in the comment, or vice-versa. Come to think of it, I almost repeated myself in the comment. The only extra bit is the DC control part. May 5, 2018 at 12:48

The high pass filter remove the DC component leaving only AC, because of this it can't source or sink any DC current so any input bias current on the next stage will appear as a DC offset

the values are chosen by chosing C to be big enough to drive the next stage and R with reasonable linearity (particularly at the lowest frequency), and choosing R to be small enough that the settling time (after power-on) will be reasonable.

to do this you need to look at the impedance of the source and the next stage and the RC time constant. as a rule of thumb RC > 10x the period of the signal is a good starting point.

10uF * 10k ohms is 100ms and at 20Hz your signal has a period of 50ms

So your chosen filter seems reasonable assuming at least 10K input impedance on your amplifier.