I needed a bipolar analog signal to drive a custom hybrid servo loop. The circuit uses two pwm ports, in my case pins 5 and 6 on a Uno. Each channel is filtered into a 0->5 volt signal using two pole sallen key filters, fc ~100 hz. The two unipolar signals are subtracted using a simple differential amp. The result is a signal that ranges from -5 to +5 volts in a total of 511 steps. A delightful feature is that for zero volts out both channels are set pwm to 127. What happens is that the pwm impulses cancel and there is zero net pwm noise! This is true as long as the voltage requested is less than about +/- 2 volts, past there ripple increases as the timers have less overlap in pwm signal.
Attaches is a schematic of the filter/diff amp. The flop to the right has nothing to do with this circuit.
This project is to design and build a high bandwidth precision motion controller using nested loops: current, velocity then position as classically studied.
doodles.pdf (7.96 KB)