Picaxe 14M 6 bit Digital to Analog Converter

Svejk

Senior Member
An inexpensive way to achieve a Digital to Analog Converter (DAC) with a Picaxe 14M. This uses R-2R resistor ladder. The tolerance of resistors is important, the more accurate, the better the results are.

I've used 100/200 ohms resitors 1% tolerance (quite common, out of the junk box).

Test code:

Code:
#picaxe 14M

for b0 = 0 to 63
  pins = b0
  wait 1
next b0

do:loop
This is no invention, just a reiteration of a well known circuit.
 

Attachments

Last edited:

premelec

Senior Member
A reminder too that you can get a pretty decent sine wave using weighted R values - Don Lancaster has some discussion of this in the CMOS Cookbook I think it was... this could lead to the TT output 2 tones occasionally needed...
 

westaust55

Moderator
Yes have done a similar circuit in 8-bit using a DS2408 1-wire chip but that needs a chip with 1-wire comms (X1 or X2 parts).

Easy when the outptus can drive high and low. A little more complex to adjust/trim with outputs that are open collector but it can be done.

How is the linearlity and monotonic nature of the R-2R DAC output with 14M driven circuit?
 

fernando_g

Senior Member
Indeed, ladders are useful and simple D/A converters.
With a 20M you could do the full 8 bits.

I would only add to your circuit an op-amp buffer at the analog output. It has to be of the rail to rail variety, unless it is being powered from a voltage higher than 5 volts.
 

aduy

Senior Member
If you use the advanced features of the 14m you can make it into 9bit I have made a circuit and even a PCB that would work for 9bit

 
Last edited:

Svejk

Senior Member
I think the serial programming isn't exactly the right one. Maybe add a decoupling capacitor as close to the power pins. Another thing to consider when using the resistor ladder is the resistor tolerance: more bits resolution leads to more accurate resistors.
 

westaust55

Moderator
If you use the advanced features of the 14m you can make it into 9bit I have made a circuit and even a PCB that would work for 9bit
Can I suggest that you also post your program for completeness which may at some future date enable others to follow in your foot steps without hassles.
We are afterall here to help each other.
 
Top