PWM to Analog DC Voltage Converter Chip for Arduino - Page 1
Forum section: electronics / projects

author: beaker353
author_rank: Unknown
timestamp: February 18, 2011, 08:39:45 pm
content: Hello all! I am working on a project that uses serial commands to control a voltage controlled gain op-amp. I am using the Arduino to receive and process the serial commands and slowly working through the needed programming. On the output side of the Arduino I need to find a way to convert the 5V PWM outputs into a clean 0-4v DC signal, what the VCA op-amp needs. I have seen various designs on the web using a RC network to accomplish this, but I have to believe that there is a chip out there that would do it more precise and all in one nice package. Anyone know what I should be looking for or some specific recommendations? Thanks!

author: Simon
author_rank: Unknown
timestamp: February 18, 2011, 08:47:40 pm
content: why do you need a chip if a simple RC network (fancy name for two basic parts) will do the job ?

author: DaveW
author_rank: Frequent Contributor
timestamp: February 18, 2011, 09:48:11 pm
content: Well you can buy a nice 5th order filter chip, or just buy a DAC chip which will give you an output that won't need filtering in roughly the same space-but as Simon says, why use that instead of an RC filter?

author: beaker353
author_rank: Unknown
timestamp: February 18, 2011, 10:15:59 pm
content: It honestly comes from to my lack of knowledge of caps and RC circuits in general. Usually an IC datasheet gives me enough information that I can figure out how to interface the chip into a workable circuit. If it's not something that exists on a chip, I can certainly play around with some caps and RC circuits and eventually find a workable solution. Just trying to find an easier way to get to a solution.

author: Zero999
author_rank: Super Contributor
timestamp: February 18, 2011, 10:52:50 pm
content: I agree an RC is ideal.What's the PWM frequency and signal being modulated?If you use a single RC filter with a cut-off of1/100of the PWM frequency you'll have virtually no ripple or you could use two RC filters one after the other with the cut-off at1/10of the PWM frequency for similar performance.An op-amp configured as a non inverting amplifier could be used to reduce the output impedance of the circuit.

author: beaker353
author_rank: Unknown
timestamp: February 18, 2011, 11:12:08 pm
content: The Arduino PWM outputs modulates at just under 500Hz, so the period between pulses is little over 2ms. The impedance of the control voltage input on the Analog Device SSM2018 is 1Mohms, so the drain that will put is minimal at worst. Would I be able to predict how long it would take for the DC voltage to stabilize after a change in the PWM? For example, I change the PWM from 25% modulation to 75%, and then later back to 25%. My understanding is there will be a time for the DC voltage to reflect the PWM change.

author: Eliminateur
author_rank: Regular Contributor
timestamp: February 18, 2011, 11:28:01 pm
content: beaker, i've come to a similar necesiity than your and solved quite easily as i don't like fiddling with analog if i can help it(Rc networks, cutoff freqa, yadda yadda, i don't like it, too messy and i needed a perfectly static output voltage):serial controlled(I2c/SPI, both have arduino libraries) digital potentionmeter.It has the same cost as a low cost-DAC and gives you a little more "simplicity" as you simply put a tap value instead of having to calculate what vout you'll get at what duty and then calibrate it(because arduino pwm ain't exactly 500Hz, in fact it's a little lower and messy freq), they come in various values, shapes and taps.examples:Analog Devices AD5206 spi 6 pots 256taps(8bit word) in DIP packageMicrochip MCP42010and several others, hope it helps

author: Unknown
author_rank: Unknown
timestamp: February 19, 2011, 12:45:41 am
content: Quote from: Eliminateur on February 18, 2011, 11:28:01 pmWith a DAC you simply put a voltage, even simpler in my opinion. You can also get them with higher resolution and/or speed than digital pots. Digital potentiometers seem to me like devices for people who haven't got their head around the digital world yet, so they try to emulate a pot. They are useful for some applications (eg. a variable attenuator with mediocre performance, like for audio), but for generating DC voltages, a DAC is superior.

author: Eliminateur
author_rank: Regular Contributor
timestamp: February 19, 2011, 02:35:16 am
content: how do you "simply put a voltage"?, it's the same as a digital pot, you put vcc, vref and output so it's almost the same for both devices, you simply put the voltage.i use 8 bit digital pot for a 0-5V precision adjust of qusi-static output}(maybe changes once every minute), i find it offers the same performance as an 8bit DAC but much simpler(both offer 256 steps from 0 to 5v), as almost any serial 8-bit dac is multiple output and SMD (which i don't want, and haven't found a single DIP I2C serial 8bit simple voltage output DAC, heck, it's hard to even find a serial 8bit dac at all, the 8bit dacs normally found are +10yr designs like the DAC083 series from National that use parallel bus, which is a no-go).pricewise i'd say they're the same.Maybe if i where to need 12bit or differential output or current output or even simultaneous multiples outputs or high speed or if there where some problem with the variable output impedance of the pot output(easily solvable with a opamp) then a DAC would be the only choice(and some dacs even require external buffers, so kind of moot), but for semi-static 8bit 0-5v single ended output, it's the same(and i think digital pot commands are simpler than a DACs)at the end, everyone uses what they feel more comfortable/simpler/best for their application based on the data they have

author: cyberfish
author_rank: Regular Contributor
timestamp: February 19, 2011, 09:34:56 am
content: Digital pots may have their uses in very specific application areas (variable gain amplifier, etc), but generating an analog voltage digitally is not one of them.By definition, that's what DACs do. Digital to analog converters.QuoteWhat's wrong with more than 8 bits? People don't make slow 8-bit DACs anymore because they can make 12-bit ones for the same price. If you don't need that many bits, just set the 4 LSB to 0. People don't usually complain about having too many bits.http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&name=MAX518BCPA%2B-ND

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2011, 11:08:57 am
content: Quote from: beaker353 on February 18, 2011, 11:12:08 pmWhat about the frequency being modulated?It can't be over 50Hz anyway, otherwise filtering becomes very difficult and there'll be lots of ripple on the output.What's the maximum acceptable ripple on the output?QuoteTechnically speaking, the DC voltage on the capacitor never reaches the average PWM value (steady state), it just gets closer and closer over time until for all intents on purposes it's equal to the average voltage. For a single RC circuit, the DC voltage on the capacitor will be within 3% of the average PWM voltage after 3 RC time constants and it'll be within 0.7% after 5.http://en.wikipedia.org/wiki/RC_circuitUnfortunately, a single RC circuit won't be enough to give you low ripple, unless the bandwidth is really low. Using three, one after another will be better. I've not calculated the settling time but I estimate it'll be three times as long. So for the circuit attached, you can expect the output to be within 0.7% of the input after 16.5ms which is RC time constants.

author: beaker353
author_rank: Unknown
timestamp: February 19, 2011, 08:43:02 pm
content: I can think of places where each of the three options would be the best choice, so I guess you are all right in that respect. Just for the heck of it, I'm going to try to work out each of the three options mentioned and see which one floats my boat the best...Hero999, if I’m reading your last post correctly... There is no data modulated on the PWM signal. Simple duty cycle on/off usually used to vary the brightness of a LED.http://www.arduino.cc/en/Tutorial/PWMI really couldn't tell you what my acceptable ripple is quite yet. The less the better, but I really can't predict the end audible effect the ripple will impart into the VCA until I breadboard it. As far as stabilization time, I would say with 1% within 50 cycles (100ms) is about as good as I would need. I have a feeling that depending on the load a RC circuit places on the PWM outputs, this might be the way to go at least for my first test...Thanks all for the ideas!!

author: Zero999
author_rank: Super Contributor
timestamp: February 19, 2011, 08:52:01 pm
content: If all you need to do is vary the brightness of an LED, there's no need for an RC filter, the slow response of the human eye will act like a low pass filter.

author: Simon
author_rank: Unknown
timestamp: February 19, 2011, 09:00:59 pm
content: for 1% in 50 cycles you will be fine with the RC filter. Don't over complicate your life. If your worried about loading the output (don't know about atmels but pic's can output up to 25mA) just use a transistor as a buffer

author: beaker353
author_rank: Unknown
timestamp: February 19, 2011, 10:04:41 pm
content: Hero999, I was just explaining how the PWM output of the Arduino is USUALLY used. For my application I am feeding a control voltage to a Analog Devices SSM2018 a voltage controlled op-amp that directly uses a true industrial level differential input. Gain is inversely proportional to the DC voltage put on the control pin from 0 to 4vDC. I have the many 2018's in a large Vegas production show I maintain so I know it can actually cut it. It's usually just controlled by a DC voltage from a pot configured as a voltage divider or just 4vDC on/off from a relay or such. I want to be able to control a decent sized bank of these from a fairly remote location, so hence using the PWM outputs of an Arduino connected to a network...If a simple RC circuit will suffice, anyone with specific schematics and values to get me going?...

author: Simon
author_rank: Unknown
timestamp: February 20, 2011, 08:25:37 am
content: well then the RC network is fine. As stated before make the cut of frequency something in the order of 1/10 to 1/100 of the PWM frequency and have fun. The specific values will be determined by exactly how much current you want to draw and the output impedence required

author: Zero999
author_rank: Super Contributor
timestamp: February 20, 2011, 10:38:28 am
content: The values in my previous schematic should do. I deliberately made the impedance low so the load will have negligible effect on the output.

author: Eliminateur
author_rank: Regular Contributor
timestamp: February 20, 2011, 04:04:19 pm
content: you mention "distance", i'm sure it would be negligible at the currents you're dealing but you might need to check power loss at the ends of the cable (but since you're dealing with a diif amp input, that's nanoAmps...)thee are DACs with direct differential outputs as well, they might fit your gadget better

author: Simon
author_rank: Unknown
timestamp: February 20, 2011, 04:09:58 pm
content: maybe by distance he meant remote control, in which case the volume information is being sent as PWM and will need reconverting to something the circuit can use so that it still thinks there is a pot there or whatever

author: beaker353
author_rank: Unknown
timestamp: February 20, 2011, 10:55:44 pm
content: I don't have a usable Arduino in front of me at the moment, but I did have some 1kohm resistors, some 3.3uF caps, and a scope with a function generator. It can't create a square wave from 0V to 4V, but it can do -2V to 2V. Using the diagram from Hero, I have 640mv pk-pk after the first cap, 52mV pk-pk after the second, and only 6mV after the third. This translates to only 0.2dB output ripple from the VCA, which is definitely acceptable. Measured only 2mA current as well, so this will not stress the Arduino output in the least. I'm going to give the DAC and digital pot a try as well just to be academic, but it looks like a RC circuit this should work.I'm still trying to fully wrap my head around the RC formulas. In order to get half the ripple, would I replace the 3.3uF caps with 6.6uF caps (inverse linear), or would I replace the 3.3uF caps with 33uF caps (inverse exponential)?

author: Simon
author_rank: Unknown
timestamp: February 21, 2011, 12:43:56 pm
content: if you increase the capacitors you are lowering the cut off frequency making the network less responsive to change (at the working frequency) and so the ripple is reduced as the cap charges abd discharges more slowly

author: Zero999
author_rank: Super Contributor
timestamp: February 21, 2011, 07:44:28 pm
content: Yes increase the capacitor values to reduce the ripple at the expense of responsiveness.Why don't you experiment with different values to see the affect on ripple and frequency response?The corner frequency for a 3rd order RC filter (three RC circuits) will be the same but the cut-off will be at -9dB.