# 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.) Sep 26, 2014 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 Aug 11, 2017 at 14:52
• Yes bipolar. I changed the title. Aug 11, 2017 at 15:01

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.

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? Sep 26, 2014 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. Sep 26, 2014 at 13:54
• @ 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. Sep 26, 2014 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. Sep 27, 2014 at 2:39
• @Capn: R2 is a essential part of the voltage divider formed by R1 and R2. Without it, the output voltage amplitude would not be attenuated. 3.3 V was the assumed logic voltage level since the OP didn't specify. Now, nearly 3 years after this answer was written, the OP has come back and specified 5 V logic. Oh, well. He'll have to compute the required resistor values himself. Aug 11, 2017 at 16:49

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? Sep 26, 2014 at 13:21
• not cascaded, they both come off the same input signal. They will have the same phase. Sep 26, 2014 at 13:29
• @Harsha see my comment above, I forgot to tag you in it Sep 26, 2014 at 15:40
• How to get down the voltage level using the op-amp's gain? Aug 11, 2017 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. Aug 11, 2017 at 22:29

But you will need to pass the output from your PWM signal though some additional external circuitry in order to offset the center point of the signal and limit the range of voltages to the levels you want to see. That could be as simple as a couple of transistors or more likely an op-amp. Your circuit will also need to provide a negative voltage rail too.

It really depends what it is you want to be doing with the final output. Are you driving a motor, generating an audio signal or something else?

• I plan to use this signal in water salinity/conductivity measurements Oct 6, 2014 at 12:00

As already mentioned above, you need to specify what load you are driving. It may even be possible to split your DC bus using a pair of caps if your load does not need to be referenced to DC ground. simulate this circuit – Schematic created using CircuitLab

Using an comparator with open loop configuration will do the job.