> From: Andrew Warren <.....fastfwdKILLspam@spam@IX.NETCOM.COM>
>
> Steve Hardy <PICLISTKILLspamMITVMA.MIT.EDU> wrote:
>
> > given that each of 4 outputs can be in one of 3 possible states,
> > one could conjecture that it is possible to make a DAC with 3^4 =
> > 729 [sic] possible output levels. Is this possible in practice?
^
Yes, I'm suitably chastised. Somehow I pressed 3 cubed squared
not 3 squared squared. Serves me right for doing on a calculator
what I should have done in my head.
{Quote hidden}> > Ignore the imperfections of the outputs - assume they are exactly
> > 0V or 5V or infinite impedance, and your resistors and opamp are
> > perfect. Is it possible to make a linear (not just monotonic) DAC?
>
> Steve:
>
> If it IS possible, I'd really like to know how... I spent about a
> month trying to replace a 256-step switched attenuator network with
> an arrangement similar to the one you describe.
>
> The best "solution" I found was one that used 12 voltage dividers
> (which would have allowed 4096 possible output values in the
> configuration we were using) and discarded a bunch of values in the
> range... We ended up with 256 well-chosen (through exhaustive
> computer simulation) steps that were SORT OF linear, but not close
> enough for our application, so we gave up.
Well, Keith Dowsett <.....kdowsettKILLspam.....RPMS.AC.UK> got the answer that I was
thinking of, and is attached below (with a few additional comments).
However, I don't think this is directly relevant to your attenuator
problem since the solution below is directed to merely producing a
voltage output. I think you really wanted a multiplying DAC. Of
course, you can use a voltage to control a separate attenuator.
{Quote hidden}> recently someone asked if it was possible to use the fact that PIC pins
> can be tri-stated to produce a different kind of DAC. (Using ideal
> components of coures.) The answer is that it requires an inverting op-amp
> with the +ve input at Vsupply/2.
>
> If you then use a R-3R-9R-27R network to sink and source current it is
> possible to get a reasonably linear response. (depending on how little
> current the tri-state input sinks) Each output can occupy three states
> Hi,Lo, or Tri. Here are the first few codes. Generating the remainder is
> left as an exercise for the three-fingered student from Sirius.
>[cut]
> It's probably not worth generating these codes from scratch, just use an 81
> byte lookup table with one nibble containing the Port bits and the other the
> Tris bits.
What is happening here is that rather than binary, a numbering system
called 'balanced ternary' is being used. In balanced ternary, each
digit has the possible values -1, 0 or 1. D.E.Knuth goes into a little
detail in 'The Art of Computer Programming, Seminumerical Algorithms'.
With the DAC described by Keith, the digit values get weighted by a
power of 3 and fed to a current summing node whose voltage is
maintained at the 'zero' (Vcc/2) level. As far as I can see, the
following advantages accrue c/w 2's complement binary:
. Finer resolution for the same number of outputs.
. Equal numbers of +ve and -ve steps: symmetry.
. At mid-scale (i.e. zero) only the least significant digits
are changing. With binary, the MSB changes as
mid-scale is crossed, which requires the MSB resistor to
be trimmed accurately. This is a significant problem for
low-level audio signals.
. Untrimmed 1% E24 resistors seem to work out a bit nicer:
1, 3, 9.1, 27, 82 vs 1, 2, 3.9, 8.2, 16, 33, 62. This is
a pretty weak argument, I admit.
... and the following disadvantages:
. Require 3-state outputs
. If the summing node is not at Vcc/2 then the 'gain' is different
for +ve and -ve signals. This can add 2nd harmonic distortion.
. The program needs to convert from binary to balanced ternary,
then juggle the TRIS register and port correctly.
Regards,
SJH
Canberra, Australia