# Converting PWM to bipolar square wave?

Is it possible to make bi-polar square signal from PWM signal?

Im talking about 40 kHz frequency and 0.5v /-0.5v peak to peak signal.

The PWM dose is %50. And the PWM frequency is 40 kHz too. The PWM is generated with an Atmel MCU with no extra parts. The MCU digital pins are rated at 5V.

• Sure, A high pass filter is the easiest. If that won't work then you could use a comparator with the needed power supply rails. Or float a digital buffer/ inverter. (I think you meant to call this bipolar and not bidirectional.) – George Herold Sep 26 '14 at 13:14
• As pointed out by @GeorgeHerold Do you mean bipolar? Bidirectional suggests its capable of being an input or an output, bipolar means the output switches between a positive and a negative level. You can make a suitable level shift circuit with an op-amp – Warren Hill Aug 11 '17 at 14:52
• Yes bipolar. I changed the title. – user30878 Aug 11 '17 at 15:01

All you need is a capacitor to block DC and a resistor divider to attenuate the signal:

This example will have a output impedance of about 3 kΩ.

• The capacitor will not distort the signal? – Martin Petrei Sep 26 '14 at 13:49
• @Martin: Everything distorts a signal, the right question is whether the added distortion is within acceptable limits. In this example, the RC time constant is at least 10 ms. The 12.5 us levels are therefore 1/800 time constants long. The end of each level will therefore droop only 0.13% to the other level, or 1.3 mV. If that's not good enough, use a bigger capacitor. – Olin Lathrop Sep 26 '14 at 13:54
• You're right. Thanks for the clarification. Good answer! – Martin Petrei Sep 26 '14 at 14:00
• @ Olin: What the OP specifically asked was: "Is it possible to make bi-directional ( symmetrical) square waveform from PWM signal?". The answer, of course, is "no" but, as we all know, what he meant was: "Is it possible to cause a PWM signal which swings between 0 volts and some positive voltage to swing, instead, symmetrically between positive and negative voltages while maintaining its mark-to-space ratio? The answer is, of course, "yes", but since your answer didn't preserve the symmetry of the voltage swing over even the slightest range of duty cycle, it's invalid. – EM Fields Sep 26 '14 at 16:57
• My belief is that, since the OP used the acronym, "PWM", his interest lies in duty cycles other than just 50%. If that's true, then your scheme clearly fails to meet the symmetry criterion requested by the OP and should be flagged as an error, regardless of your self-serving opinion as to the relevance of the error. – EM Fields Sep 27 '14 at 2:39

You can use a circuit like:

simulate this circuit – Schematic created using CircuitLab

where $V_{ref}$ is the level below GND that shifts the signal. For example, if the PWM signal is 1V amplitude, with $V_{ref}$ = 0.5V you get a square signal $\pm$0.5 V.

Of course, you can add a circuit for limiting or attenuating the output of the operational amplifier. The slew rate of this device is not too critical for the frequency of 40 k, and easily find such devices on the market.

### Attention

The scheme I present is only a guideline for implementation. You must take into account the gain levels of OPAMP (adjusted with external components), or if you use a comparator, the levels of signal excursion, according to the power supply.

Use an inverting buffer and non-inverting buffer. You can use op-amps with +-5V supply to get the voltages you want, using gain resistors etc. for the voltage you need. Probably 1/10 gain to get down to the 0.5V level.

40kHz bandwidth is not much, so a general purpose (low slew rate) op-amp should be able to do it well enough. Especially because it will be a very low/fractional gain the slew rate should not be an issue at all.

• are you sure that using cascaded inverting buffer and non-inverting buffer would give square wave? – Harsha Sep 26 '14 at 13:21
• not cascaded, they both come off the same input signal. They will have the same phase. – KyranF Sep 26 '14 at 13:29
• @Harsha see my comment above, I forgot to tag you in it – KyranF Sep 26 '14 at 15:40
• How to get down the voltage level using the op-amp's gain? – user30878 Aug 11 '17 at 14:40
• @user30878 with an inverting op-amp you can create a gain of less than 1. you can then un-invert it using another inverting unity gain (gain of 1) buffer after it. or you can use resistor dividers to reduce voltage, and then buffer the output of the resistor junction with the op-amp. – KyranF Aug 11 '17 at 22:29