Go Down

Topic: True analog outputs (Read 11239 times) previous topic - next topic

Onions

Apr 22, 2011, 08:18 pm Last Edit: Apr 23, 2011, 02:51 pm by Onions Reason: 1
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:

http://i.imgur.com/oXeak.png

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.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

Onions

#1
Apr 22, 2011, 08:22 pm Last Edit: Apr 23, 2011, 02:52 pm by Onions Reason: 1
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.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

CrossRoads

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

retrolefty

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

Quote
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

keeper63

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 will not respond to Arduino help PM's from random forum users; if you have such a question, start a new topic thread.

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  :smiley-red:. 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.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

retrolefty


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  :smiley-red:. 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  ????


Onions

Quote
Full Scale Error    ±2.5LSB  ????


I don't really know what full scale error means  :( :smiley-red: :(. 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:


http://i.imgur.com/LRQsx.png

I have also updated the library. In the write up I said
Quote
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.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

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.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Onions

#9
Apr 23, 2011, 09:31 pm Last Edit: Apr 23, 2011, 09:35 pm by Onions Reason: 1

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:
Quote
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.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

CrossRoads

Yes - follow Figure 3 or 4.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Onions


Yes - follow Figure 3 or 4.


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

Thanks!
Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

CrossRoads

Yes, the op amp will give you the voltage out and provide some current drive capability.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Onions

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:

http://i.imgur.com/dkTBz.png

Onions.
My website: http://www.harryrabbit.co.uk/electronics/home.html Up and running now! (Feel free to look round!) :D

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up