Author Topic: PWM to Analog DC Voltage Converter Chip for Arduino  (Read 32467 times)

0 Members and 1 Guest are viewing this topic.

Offline beaker353Topic starter

  • Supporter
  • ****
  • Posts: 102
  • Country: us
PWM to Analog DC Voltage Converter Chip for Arduino
« on: February 18, 2011, 08:39:45 pm »
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!
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #1 on: February 18, 2011, 08:47:40 pm »
why do you need a chip if a simple RC network (fancy name for two basic parts) will do the job ?
 

Offline DaveW

  • Frequent Contributor
  • **
  • Posts: 284
  • Country: gb
    • WattCircuit
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #2 on: February 18, 2011, 09:48:11 pm »
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?
 

Offline beaker353Topic starter

  • Supporter
  • ****
  • Posts: 102
  • Country: us
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #3 on: February 18, 2011, 10:15:59 pm »
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.
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #4 on: February 18, 2011, 10:52:50 pm »
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 of 1/100 of the PWM frequency you'll have virtually no ripple or you could use two RC filters one after the other with the cut-off at 1/10 of 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.
 

Offline beaker353Topic starter

  • Supporter
  • ****
  • Posts: 102
  • Country: us
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #5 on: February 18, 2011, 11:12:08 pm »
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.
 

Offline Eliminateur

  • Regular Contributor
  • *
  • Posts: 179
  • Country: ar
  • Electronic's Technician
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #6 on: February 18, 2011, 11:28:01 pm »
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 package
Microchip MCP42010

and several others, hope it helps
 

alm

  • Guest
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #7 on: February 19, 2011, 12:45:41 am »
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.
With 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.
 

Offline Eliminateur

  • Regular Contributor
  • *
  • Posts: 179
  • Country: ar
  • Electronic's Technician
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #8 on: February 19, 2011, 02:35:16 am »
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
 

Offline cyberfish

  • Regular Contributor
  • *
  • Posts: 240
  • Country: gb
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #9 on: February 19, 2011, 09:34:56 am »
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.

Quote
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.
What'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
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #10 on: February 19, 2011, 11:08:57 am »
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.
What 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?


Quote
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.

Technically 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_circuit

Unfortunately, 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.


 

Offline beaker353Topic starter

  • Supporter
  • ****
  • Posts: 102
  • Country: us
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #11 on: February 19, 2011, 08:43:02 pm »
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/PWM  I 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!!
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #12 on: February 19, 2011, 08:52:01 pm »
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.
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #13 on: February 19, 2011, 09:00:59 pm »
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
 

Offline beaker353Topic starter

  • Supporter
  • ****
  • Posts: 102
  • Country: us
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #14 on: February 19, 2011, 10:04:41 pm »
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?...
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #15 on: February 20, 2011, 08:25:37 am »
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
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #16 on: February 20, 2011, 10:38:28 am »
The values in my previous schematic should do. I deliberately made the impedance low so the load will have negligible effect on the output.
 

Offline Eliminateur

  • Regular Contributor
  • *
  • Posts: 179
  • Country: ar
  • Electronic's Technician
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #17 on: February 20, 2011, 04:04:19 pm »
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
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #18 on: February 20, 2011, 04:09:58 pm »
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
 

Offline beaker353Topic starter

  • Supporter
  • ****
  • Posts: 102
  • Country: us
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #19 on: February 20, 2011, 10:55:44 pm »
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)?
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17728
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #20 on: February 21, 2011, 12:43:56 pm »
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
 

Online Zero999

  • Super Contributor
  • ***
  • Posts: 19345
  • Country: gb
  • 0999
Re: PWM to Analog DC Voltage Converter Chip for Arduino
« Reply #21 on: February 21, 2011, 07:44:28 pm »
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.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf