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
www.tech-chat.de)
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.
http://www.microchip.com
Good luck
Chris