True analog outputs

I have (kind of) completed my latest project - a device to give an analog voltage output from the arduino. (The reason I have kind of completed it is because I have thought up how it would work, designed the hardware and written the software, but not built the device yet). I have also created a library for it to make things easier.

The schematic is below:

The shift register is set up as shown in the shiftOut tutorial, and the DAC is a common R/2R resistor DAC.
For the library, the .h file, .cpp file, keywords and a full writeup and explanation is attatched, as I cannot fit it all on here. To add the library, make a file called 'Analog' in the libraries section of your sketchbook, put the .h, .cpp and keywords files into it, and get experimenting!

The rest of the information is all on the writeup.

I hope people will find this useful!
Onions.

Analog.cpp (548 Bytes)

Analog.h (378 Bytes)

keywords.txt (35 Bytes)

about true analog.txt (5.75 KB)

And there are also some example sketches, but I was limited to 4 attachments per post. To add these to your IDE, make a file called 'examples' in the analog library folder, and put the sketches into it. You can then access them easily from File->examples->Analog in the IDE.

Onions.

P.S. You can also download the schematic from here, should you want to.

basics.pde (287 Bytes)

count_up_and_down.pde (590 Bytes)

true analog 2.png

Small error in the schematic - should be D0 to D7 (not D8).

Add some decouplig caps to the LM358, maybe a low pass filter also to reduce switching noise.

Am wondering if you will see noise additional noise with such high value resistors.
5V/1M is only 5uA, will be susceptible to outside influences.

Another problem with R2R networks is the required accuracy of the resistors as the bit count increases.

Accuracy of resistor ladders:

Resistors used with the more significant bits must be proportionally more accurate than those used with the lower significant bits; for example, in the R-2R network shown above, inaccuracies in the Bit4 MSB resistors must be insignificant compared to R/32 (i.e., much better than 3%). Further, to avoid problems at the 10000 to 01111 transition, the sum of the inaccuracies in the lower bits must be significantly less than R/32. The required accuracy doubles with each additional bit—for 8 bits, the accuracy required will be better than 1/256 (0.4%). Within integrated circuits, high accuracy R-2R networks may be printed directly onto a single substrate using thin-film technology, ensuring the resistors share similar electrical characteristics. Even so, they must often be laser trimmed to achieve the required precision. Such on-chip resistor ladders for digital-to-analog converters achieving 14 bits accuracy have been demonstrated. On a printed circuit board, using discrete components, high precision resistors of 1% accuracy may be employed for a 5 bit circuit, however with bit counts beyond this the cost of ever increasing precision resistors becomes prohibitive. Often, even for a 5 bit circuit, the home constructor will use either a matched set (by measuring a batch of 100 5% resistors and selecting the best set of 15) or by trimming down individual resistors to a common value (by adding high value resistors in parallel).

Lefty

I think after going thru all of that and dealing with the resistor precision issues, it would probably be faster (and maybe cheaper) just to use an SPI/I2C DAC.

I have sorted out the schematic, so it goes from D0 to D7, not up to D8 :). After looking around on some component suppliers' websites, I have found the TLC7524CN from RS. at the minute, I am scrolling through the datasheet to see how it works and how to apply it for the analog circuit.
Hopefully I will not get any noise from the IC, but I will still add in the capacitors. The only problem is that I do not know where to put them :blush:. As it is to filter noise from the input of the buffer, I would assume that it would go from the buffer input to 0 volts, however I do not know if it is right...

Onions.

Onions:
I have sorted out the schematic, so it goes from D0 to D7, not up to D8 :). After looking around on some component suppliers' websites, I have found the TLC7524CN from RS. at the minute, I am scrolling through the datasheet to see how it works and how to apply it for the analog circuit.
Hopefully I will not get any noise from the IC, but I will still add in the capacitors. The only problem is that I do not know where to put them :blush:. As it is to filter noise from the input of the buffer, I would assume that it would go from the buffer input to 0 volts, however I do not know if it is right...

Onions.

Full Scale Error ±2.5LSB ????

Full Scale Error ±2.5LSB ????

I don't really know what full scale error means :frowning: :blush: :(. I think it means the difference between what the output voltage should be and what it is. Is that correct?

I have re-designed the hardware, ditched the R/2R idea, and used the TLC7524CN DAC (datasheet here). I have not used the IC before, so if it does not work, don't be surprised. I set it up using the details on the datasheet. the new schematic is here:



I have also updated the library. In the write up I said

The shift register needs all the pins that have already been discussed if it is going to work.
The latch pin is different as it does not need to be connected, although it can be useful ... By taking the latch pin low, you can shift out the data without the bits changing. This means that the output value will stay the same until all the bits have been shifted out, and the new
value can be seen.

As I have written that you do not need the latch pin, it seems stupid that I had not allowed the circuit to be used without it – in the library the constructor is called with the latch pin anyway, so you cannot use the latch pin for anything else. I have altered that by overloading the analog class to (int dataPin, int clockPin), as well as (int dataPin, int clockPin, int latchPin). I have updated the write up to show this.

Onions.

Analog.cpp (706 Bytes)

Analog.h (418 Bytes)

about true analog.txt (7.26 KB)

You are not following Figure 3 or 4 of the datasheet for the output to the op amp.
Try it as suggested first to avoid damaging the chip.

CrossRoads:
You are not following Figure 3 or 4 of the datasheet for the output to the op amp.
Try it as suggested first to avoid damaging the chip.

No, I was setting it up slightly differently. The datasheet says that the device is a current DAC, but it also says:

It is possible to operate the current-multiplying DAC in these devices in a voltage mode. In the voltage mode, a fixed voltage is placed on the current output terminal. The analog output voltage is then available at the reference voltage terminal. Figure 1 is an example of a current-multiplying DAC, which is operated in voltage mode.

so I had to set it up differently to what the datasheet shows. But if it would damage the IC, I will have to find a different way of connecting it to the op amp... Any suggestions for a suitable method? I am determined to complete it in the end!

Thanks, Onions.

Yes - follow Figure 3 or 4.

CrossRoads:
Yes - follow Figure 3 or 4.

:smiley: :smiley: :smiley: So I guess that it will give a voltage output?
I'll start revising the schematic now.

Thanks!
Onions.

Yes, the op amp will give you the voltage out and provide some current drive capability.

That's good. I've revised the schematic, but I do not know what to do with Vref. I would assume I connect it to 5V or 0V?
The new schematic is here:


Onions.

Vref goes to +5v

CrossRoads:
Vref goes to +5v

Oh good, thought so. Thankyou very much for the help!

Onions.