Expanding PWM outputs - But with Low pass true voltage out

Hey all. I have been looking around and see that by using shift registers it's pretty easy to expand the PWM outputs on the arduino.

The thing is I want real voltage on my pins using a low pass R/C filter.

Like this one here.

https://arduino-info.wikispaces.com/Analog-Output

Is there a way to do it ? .. could it be possible to just put R/C filters on the outputs of a shift regester and that will give me a way to control true voltage ?

There are PWM boards on the market; the below two use I2C

e.g. https://www.adafruit.com/product/815 https://www.adafruit.com/products/1411

PWM with a shift register is just all is software so not that great. There are indeed PWM chips/breakout available that do it in hardware for you.

You can indeed use a RC filter to go to a voltage. But remember you cannot load a RC filter that much, then the filtering is gone.

Is there a way to do it ? .. could it be possible to just put R/C filters on the outputs of a shift regester and that will give me a way to control true voltage ?

yes and no. As already stated, the output of an RC LPF is only useful for high impedance loads , like the input to an ADC or op amp.

You can use 1 k ohm resistor with 47 uF cap or 4.7 k ohm with 4.7 uF for the LPF. If you are even asking this question you probably have never heard of a DAC.

MCP4725

I have been looking around and see that by using shift registers it's pretty easy to expand the PWM outputs on the arduino.

I would disagree with the pretty easy bit, it takes a lot of the CPU's time to do this where as the regular PWM takes zero CPU time.

could it be possible to just put R/C filters on the outputs of a shift regester and that will give me a way to control true voltage ?

Yes you could but there is a bit more to it that that. What ripple can you stand ( there will always be ripple so don't say none )? How fast do you want the voltage to change when you change the PWM value? And don't say instantly because there will always be a lag.

nixnay: The thing is I want real voltage on my pins using a low pass R/C filter.

It might help if you tell us what you want to do with that voltage. Leo..

The thing is I want real voltage on my pins using a low pass R/C filter

Why can't you use a DAC ?

FYI, it's not called "real voltage". It's called Analog voltage.

Thanks for all the replies guys.

Someone mentioned I should use a DAC and I was thinking of going down that road. A low pass filter does the same thing but a true dedicated chip might be the way to go.

@sterretje Those boards look like they are out of stock and I want to build my own anyway. Will check out the PCA9685 chip though. If adafruit use them it might be the way to go.

"6 address select pins so you can stack up to 62 of these on a single i2c bus, a total of 992 outputs" Looks like the way to go as I need about 80 outputs.

Thanks

@Grumpy_Mike I am driving into an op amp ... so no real load as such. I just need the output to the op amp to slew from 0 to about 2v or 3v. I can make adjustments on the op amp circuit to suit.

As for ripple. Not much is the best answer I can give. I appreciate there is ripple on every output but as little as possible.

Slew rate or voltage output change is not THAT important as the device I am driving is not that fast anyway .. anything less than 1ms would be fine for this job.

I have not even had a chance yet to drive the one op amp with PWM and the R/C filter so don't quite know yet so will have to have a look on my scope.

All I really DO know is that I want a lot of analog voltages coming out of the arduino into op amps.

Each op amp drives a transistor in constant current mode using negative feedback.

Thanks for all the tips so far.

Looks like putting it down a serial line and letting some other chip take care of business might be the way to go.

Will look at that Adafruit chip ... looks like it might be the one for the job.

Will let you know how I go.

Cheers,

A PCA9685 and LM324 combo seems the way to go.
PCA9685 can be set from 200hz (default) to 1kHz PWM (max) for lower ripple.

Post a diagram of your proposed opamp CC driver.
Leo…

Hey Leo,

Yes … but I will still need an R/C on each input to the op amp if I do it that way ?

See attachment for op amp driver.

nixnay: Yes ... but I will still need an R/C on each input to the op amp if I do it that way ?

Yes. RC filter is needed to smooth the 5volt PWM square wave to a constant voltage.

If you use the LM324, and supply them with 5volt, consider a voltage divider RC filter to restrict the smoothed voltage to 3volt. You could also restrict in software at the cost of resolution. That might not be a problem with the PCA9685 (12-bit).

3volt at the +input of the opamp is ~3.6volt at the output of the opamp. That's the limit that this opamp can do on a 5volt supply. 0volt in (0.6volt at the output) is not a problem. Leo..

Thanks Leo,

I think PWM is going to be problematic. Interrupts come to mind.

Now looking for a suitable DAC that can cascade up to 80 outputs and hopefully a library.

80 outputs is a big project. I doubt anything else than the PCA9685/LM324/transistors would be easier. Five of these clones and a piece of veroboard with 20x LM324 could work.

http://www.ebay.com/itm/16-Channel-12-bit-PWM-Servo-Drive-shield-module-I2C-PCA9685-For-Arduino-NEW-/401090900127?hash=item5d62e1709f:g:ZQAAAOSwofxUcvYh

There are several PCA9685 libraries with easy commands. Leo..

nixnay: I think PWM is going to be problematic. Interrupts come to mind.

There is no problems with interrupts using a PCA9685, it is a set and forget chip. Once running it continues without needing any processor intervention.

Generating analog outputs using PWM is only reasonable if the output bandwidth required is low. Say you use 10kHz PWM and want fairly low ripple output - then you are limited to perhaps 100Hz output bandwidth unless you use more sophisticated filtering than RC low-pass.

With most DACs you can get 10kHz or more bandwidth without problem and ripple-free.

So it depends a lot on your requirements.

The Adafruit 12-bit MCP4725 has an example sketch that has an array of values to generate a sinewave but only at a low frequency . Can you find any spec in the MCP4725 datasheet that would expain that ? I’m pretty sure it’s “Slew Rate” (SR).

SRMCP4725= 0.55 V/uS

As a comparison, the LT1215 OP AMP :
SRLT1215 = 50 V/uS

sinewave.ino (8.53 KB)