Digital to multiple analog conversion

How would one go about taking say 8 or more digital 'on/off' signals from a microcontroller, and producing 8 steady analog outputs that each can vary from say 0-255? I will be using a microcontroller with up to

16 bidirectional pins, 32 altogether, which seems like plenty of pins, but not enough to provide each analog output with 8 pins to control the analog value. Is there a way to do this, or any MCU that would help?
Reply to
Dave
Loading thread data ...

Hello Dave,

You could but it may not be worth it. 8bit multi-channel DACs are cheap and plentiful. If you absolutely have to do it search Google for "R2R network".

Basically it would go like this: Eight port pins run to staggered (increasing value) resistors. One each. Their other ends are summed into a common current node, usually done with an opamp. Now you could use another eight pins, eight FETs and eight capacitors to sample and store eight different DAC values. If you wanted to be really frugal you could do that with a 8:1 mux a la 74HC4051. That reduces the number of selector port pins from eight to three. So you could rent out the five freed ones :-)

--
Regards, Joerg

http://www.analogconsultants.com
Reply to
Joerg

Hi, Dave. If you can bit-select your uC pins as input or output, here's the easiest low-cost/low-resolution way to get a lot of analog outputs from uC pins (view in fixed font or M$ Notepad):

| | VCC | + |uC Out ___ |\\| | >----|___|-o-----|+\\ Vout | 10K +| | >--o---->

| --- .-|-/ | | 1uF --- | |/| | | | | === | | === | GND | | GND '-------' (created by AACircuit v1.28.6 beta 04/19/05

formatting link

Here's the drill: By using a PWM output from the microcontroller, you can use the R, C, and op amp voltage follower to get the analog output. Start out with the uC pin as an input (Hi-Z -- doesn't source or sink current). Now, when you're ready to refresh the analog output, swwitch the pin to an output. If you wanted the output to be 5V or 100% of Vcc, you would leave the output high 100% of the time. If you wanted the output to be 50% of Vcc, you would have it high 50% and low 50%, and so on. When you're done with the analog refresh, just switch the pin back to being an input.

This can be a lot simpler than it sounds, if you use assembly language here. Just add the digital number 0 to 255 into an 8-bit accumulator, and output high at your pin if there's a CY, else low. Piece of cake, and you only have to do it for 50ms. or so per output with the above component values. If you're going to be refreshing frequently, you might even be able to use the ubiquitous LM324 as the op amp. But if you only want to refresh every second or even less, use a rail-to-rail input and output op amp with low bias current. An advantage of this is that you can bring the cap down to 0.1uF or less, and then you only have to refresh for 5ms. or less per analog channel.

Read your uC data sheet -- there may be weak pulldowns/pullups/current sources/sinks at certain pins which make this idea unuseable. As always, know your hardware.

And if this idea isn't for you (rather processor-intensive or you need the capability to interrupt while refreshing), try a serial DAC. Microchip makes several good ones, as do many other manufacturers. You'll pay 3 to 6 times as much per channel, AFAIK.

formatting link

Good luck Chris

Reply to
Chris

--
http://www.analog.com/UploadedFiles/Data_Sheets/366631380AD5346_5347_5348.pdf
Reply to
John Fields

Thanks for the quick reply, and to Jeorge as well. It will take me a few days to understand your solutions, and am still debating whether to make this capability a part of my first project or not. I am using a Microchip PIC processor at the moment so it might be convenient to get the serial DAC the same company. Thanks again.

Reply to
Dave

You could use 2 of these, with an 8 bit data bus, and a few other bits to send the data to one of the 8 outputs.

formatting link
or one of these
formatting link
If you don't like those, you can get enough key words off them to look for others.

Reply to
John Popelish

either PWM (in software or hardware) or use a DAC chip.

Bye. Jasen

Reply to
jasen

PWM. (pulse Width Modulation) through a passing circuit for each.

--
Real Programmers Do things like this.
http://webpages.charter.net/jamie_5
Reply to
Jamie

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.