# How do you shift a square wave down?

I have a square wave the oscilates at 25khz from 0 to 30v. I would like it to oscillate from -15v to +15v. Is there a SUPER DUPER SIMPLE circuit to do this? Keep in mind it's going up and down at 25khz.

Here's the circuit. The square wave I want to shift is going into the PiezoSpeaker at the lower right of the circuit.

• What supply rails do you have? Aug 12 '16 at 17:49
• A single 10 uF capacitor in series should do the trick. What's the square wave connected to? Aug 12 '16 at 17:58
• Not sure why someone voted to close this - it's about circuit design not purchase. Aug 12 '16 at 18:06
• Been looking for that square wave clutch all day long ;-) Aug 12 '16 at 18:40
• You don't need to un-bias a piezo speaker Aug 12 '16 at 23:54

How do you shift a square wave down?

Just an RC will do it: -

If fed with a sine wave (for the convenience of the attached picture), it will reproduce the sine wave at the output but with the DC level removed thus maintaining the correct peak-to-peak amplitude. Here is what happens in the first few cycles as the DC level is removed: -

It will work in the same way as a square wave (DC or average value = 15 V will be removed) but, please ensure that 2$\pi$RC << than 40 us to ensure the following doesn't happen: -

If C = 10 uF and R = 1 kohm, the cut-off frequency will be 15.9 hertz and miles away from causing the droop problem seen above.

However, if you in fact have a non 50:50 duty cycle square wave you may need a more complex circuit because the DC level won't be at the midpoint of the waveform.

On the other hand, if you are driving a simple piezo transducer, why bother shifting it to equal positive and negative levels - it's purely capacitive and it won't care so, a really simple circuit becomes "a wire".

• Excellent. Just a capacitor and a resistor. VERY simple and works perfectly !! Aug 16 '16 at 19:27

There are several simple options.

1. Rail-to-rail op-amp

If you have a rail-to-rail op-amp, this can be done using four resistors as follows:

This will divide the signal down to 0-15V which is in the range of the supply of the op-amp, and then compares it with half of 15V (which should be the new midpoint). There is no negative feedback which means the output will be either of the supply rails. If you supply +/-15V to the op-amp, this will output a +/-15V signal.

2. Transistor Level Shifter

A second options is to use a PMOS transistor/resistor level shifter followed by a CMOS inverter to correct the inversion. You need to make sure the transistors are happy with 30V+ on the Vds, and also the Vgs. This is quite high for MOSFETs, but you can get 40V rated ones, so not impossible to find.

3. AC coupling

If your signal is a continuous waveform, you can use a simple AC couple and rebias circuit - which consists of just a capacitor and two resistors as follows:

The capacitor acts as a high pass filter which removes the DC bias. You have to be careful however that the capacitor is rated for at least 45V. Also if you use a polarised capacitor, make sure the positive terminal goes to the input signal as that will always be the higher potential.

The downside to this approach is that if your signal ever goes away, the output will float to the mid supply (0V) which may or may not be ok for whatever you are connecting it too.

Additionally, a 30V zener diode is required on the output to prevent it rising to 30V during the initial transient (while the capacitor effectively "measures" the DC offset of the input signal). You can see from the simulation waveforms how the initial transient looks with the zener diode in place (top trace) and without (bottom trace). Notice how without you get a 30V signal initially.

• If I may ask, what software did you use to simulate this? Aug 12 '16 at 21:13
• @nshct Google Java Circuit Simulator, it should come up as the first result (the falstad one) Aug 12 '16 at 21:59
• I love falstad. So useful for small circuits. You can edit IN REAL TIME. Aug 12 '16 at 22:03

A simple circuit using a few jellybean BJTs:

It won't get quite to the rails, maybe +/-14V with 15V rails, depending on the load.

simulate this circuit – Schematic created using CircuitLab

No fuss, no startup transients, can't go beyond the rails, it will just work.

Edit: If you are really only concerned with removing the DC bias on the piezo, simply add a series capacitor such as a 1uF ceramic and a resistor of, say, 100K across the piezo.