> From: Tony Matthews > Hello > I would like to simplify a four bit d/a that I'm using portb 4-7 to > emulate I have each pin connected to a diode then a resistor this in > turn draws current from the noninverting side of a voltage follower > configured opamp this in turn causes the output to swing + to compensate > and the inverting output is connected to a pot to provide the initial > offset simple right? only I figure if I change the port pins from low to > high impedance I can dispense with the diodes right? What sort of morass > am I wading into firmware wise I mean the port is allready working hard > but is configured as an output and I have no experience changing > individual pin configurations. Generally I configure b out a in and > leave it at that but...anyway.oh yeah 16c84 xt mode 100khz line powered > .R2R increases the part count (discrete's) and space is as usual at a > premium.can I toggle a configuration bit without creating artifacts on > the other pins of that or any other port?The data book explains how I > suppose but is not to clear on the downside . respects Tony M. > You can toggle any of the TRIS bits without glitching the outputs. If I read your prose correctly, you are using a non-inverting configuration of the op amp. The trouble with this is that the gain will vary depending on the setting of the offset pot, and the output will be nonlinear. This may not be a problem, but I think you would be a lot better off using an inverting configuration. Tie each output through a binary weighted resistor to the inverting input, and connect the non-inverting input to the offset trimmer. Now if each output pin is either LOW or HI-Z, then the output will swing positive with respect to the voltage on the non-inverting input. Added bonus: it is now possible for you to implement a 5-bit DAC using only 4 port pins. You can now change the SIGN of the output by setting the output port pins to HIGH or HI-Z. Effectively, you can change the output for a total of 31 steps: 15 below 'zero' and 15 above. Note that the 'gain' for +ve and -ve swings may be different if the non-inverting input is not set to half Vcc. Now a question for you gurus: 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 possible output levels. Is this possible in practice? 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? Regards, SJH Canberra, Australia