Arduino DAC Library and Shield

This is a software library for the Analog Devices precision DAC chips AD5724, AD5734, and AD5754 that works with the Arduino-based prototype boards. A shield is presently in development to accompany the library.

Why this family of DAC chips?

Using the Arduino platform, there are many ways to get an analog output from digital data. One way is to use a PWM output and then smooth the output with external circuity. Unfortunately, while this works, it does not provide the precision one might need when working with sensitive systems such as those in industrial control i.e. controlling the power of a laser, for instance. 😉

Finding the right DAC chip to fit your needs can be a daunting task. I searched and searched until finally settling on the AD57X4 family. I chose this family of DAC chips for the following reasons:

– DAC settling time of 10uS
– 4-channel [Quad] output
– Single-supply dependency
– Unipolar or Bipolar output
– Selectable output range — six output ranges available, including the popular 0-10VDC
– Serial communication via the SPI of the Arduino

I think the only drawback to this chip is that it is so expensive. It’s not the most expensive DAC chip that I found, however. I think the value is right on though because it is such a versatile chip.

Important Information:

As these DAC chips are intended to be precision, some circuit design considerations should be made so that you get the best performance from these chips. I found a great resource in the AD5754 EVAL board PDF which explains the best practices when designing a board for this chip. This PDF also gives a full schematic of the Evaluation board which can be useful if you are designing your own shield.

There is also a wealth of information regarding these chips in the Analog Devices Circuit Note 86.

In addition to the above references, the datasheet for the AD57x4 chip suggests using a precision voltage reference chip. On my shield, I’m using the ADR421BRZ.  I’m also using the ultra-low noise, low drop-out [LDO] TPS7A4700 regulator from Texas Instruments for the supply to both the ADR421BRZ and the AD5754 chip.

Arduino Mega 2560 R3 Precision DAC Shield Information:

As of March 13, 2014, I have sent off what I believe is my final draft of this precision DAC shield to the fabricator. I should have the new boards back in a few weeks and at that time I’ll be able to assemble them and see their performance. In the mean time, here are some rendered images of the shield courtesy of OSHPark.

UPDATE July 22, 2013:

I have received my prototype boards back from the fabricator and have installed the AD5754 onto it. The library works without a flaw so I’ve decided to expand it to cover all of the capabilities of this chip. I will upload the expanded Arduino DAC library [version 1.0.1] either tonight or later this week.

UPDATE July 27, 2013:

I’ve uploaded version 1.0.1 of the Analog Devices AD57x4 DAC library. This version now supports all of the various voltages that this DAC works with. Note that I have not tested the bipolar outputs so I do not know for sure if this code works, but it should. If you have any issues then please let me know.

UPDATE November 18, 2013

I’ve uploaded version 1.0.2 of the Analog Devices AD57x4 DAC library. This version allows one to customize which Slave Select [SS] pin used on the shield. Simply add the pin number as the third argument when instantiating the DAC library and you’re all set. This has been tested and it works.

UPDATE December 6, 2013

Special thanks to Bernd Rilling for not only confirming that the library works with his shield, but also for making some welcomed changes to the library, such as being able to read the registers and a bug fix from the previous version where the user-defined SS pin was not instantiated. This latest version, 1.0.3, is much improved with this collaboration.

UPDATE November 3, 2018

Adding the schematic and BOM for Version 1.0.4 in PDF format. Note, I seem to have lost the data for version 1.0.5, which uses a different power regulator. As I recall, this is the only change.

UPDATE April 13, 2019

I received a request to add support for Daisy Chaining devices together. In doing this, I decided to not make the library backwards compatible so I have changed the version to 2.0.0b. Note, this is a Beta release as I have not been able to test it.

Download:

Daisy Chain Support (Beta)

DAC57X4 Library, Version 2.0.0b: DAC57X4_V2.0.0b

No Daisy Chain Support (Stable)

DAC57X4 Library, Version 1.0.3: DAC57X4_V1.0.3

Arduino Mega DAC V 1.0.0.4 Schematic

Arduino Mega DAC V1.0.4 BOM

Arduino Mega DAC V1.0.4 Eagle BRD File

Older Versions:

DAC57X4 Library, Version 1.0.2: DAC57X4_V1.0.2

DAC57X4 Library, Version 1.0.1: DAC57X4_V1.0.1

DAC57X4 Library, Version 1.0.0 [beta]: DAC57X4-V1-0-0-b

 

30 Responses

  1. Max says:

    Dear Lance,

    Thanks for all your hard work on this project!

    I am a student trying to set up my own optics experiment at home, since my school has been closed for over a year now and I have not had an opportunity do any science. I’m trying to teach myself electronics but am finding the learning curve quite steep.

    In particular, I am trying to use the AD5541 DAC (https://www.analog.com/en/products/ad5541.html#product-overview) in order to create a low-noise voltage-controlled current source for a laser diode. Is there any chance you could give me some pointers on how to appropriately construct the circuit, as well as how to convert your library to interface with the AD5541?

    Thanks so much!

    • Laser-Lance Fordham says:

      Hi Max,
      As I indicated via email, the AD5541 is a much more straightforward device than the AD57X4 family because there is only a single non-addressable register in the AD5541. This configuration means that the value sent to the AD5541 is the voltage value you want for the DAC; there’s nothing to address; no registers to configure, nothing except the voltage value derived from the formula in the datasheet.

      That said, there is a specific way the Arduino should configure the data, so the DAC accepts it. Analog Devices chips usually want the Most Significant Bit (MSB) first, which is the case for the AD5541, too. The next bit of helpful information is to know when in the bitstream will data be accepted. In the case of the AD5541, data is shifted on the rising edge of the clock signal. Finally, the chip begins accepting data when the Chip Select (CS) pin is low and stops accepting data when the CS pin goes high. A low-to-high transition of the CS pin causes the 16-bit value you just sent to be shifted into the DAC register, and the output voltage is changed accordingly.

      So, what is needed to create a library for the AD5541?
      – First, we need to instantiate the class and configure SPI.

      – Second, we need a class method that will take a voltage value and translate that to a 16-bit word. There is a formula in the datasheet that shows you how to do that.

      – Finally, we need a method that handles the communication to the DAC. You can use the SendData method in the AD5754 library in this case. The only two things you’ll need to change are the variables i and k–reduce them from 2 to 1 because only 16-bits are transferred.

      If you put together a library, I’ll be happy to look over it to see if everything is copacetic.

  2. Dimitri Benke says:

    Hi,

    Thank you for this nice library, it helped me a lot. I am using it with the AD5754R which is very similar to your DAC, but it has an included voltage reference. I needed to make slight adjustments to the library in order to make it work with it, but now it is fine.
    While doing this, I found an inconsistency in the code: sometimes DACQTY refers to the amount of channels used (in the POWERDACs method), and sometimes it refers to the number of the specific channel (in the ConfigDACs method).

    If you want, I can provide you with a changed version, once I tested that everything works with my changes.

    • Laser-Lance Fordham says:

      Hi Dimitri,
      Thank you for your feedback!
      I think I see what you’re talking about. In the ConfigDACS method, I use a cascading switch statement, so if I want to configure three DACs, then all but DAC-4 is configured. However, in the PowerDACs method, I don’t use the cascading switch statement, so it looks like it’s addressing a specific DAC. However, the addressing is different for the PowerDACs when compared to the ConfigDACs addressing.
      The Power Control register uses a bitmask to turn on/off a DAC. DACQTY indicates how many DACs to power on, so if all four DACs are turned on, we’d have a bitmask of 1111; however if we only want three DACs on, the bitmask becomes 0111. So, this is how the library is configured.
      Power Control Configuration Register AD57X4
      In the ConfigDACs method, we first set the Control Register, which applies to all DACs. It’s a misnomer that they use A2, A1, A0 as a control selector, and it has nothing to do with the DACs since all DACs are set up the same way–no individual DAC is addressing for the Control register, so DACQTY doesn’t apply.
      After the Control register is set, we set up the Output Range Select Register for each of the DACs. Each DAC can be set to a different scale, but I see in the library where we assume that the same scale is used for every DAC. I see an improvement here, where we *could* make it addressable so each DAC can have a different output scale. This improvement could be functional if using the DAC to control devices requiring different voltage levels. So, for example, if you have two 0-10V devices and two 0-5V devices, as long as we provide 10Vdc to the DAC, we can use two DACs for each of the two control voltages if we expanded the library to allow that.
      It seems to expand this to include this functionality; we would add a break statement, so the switch statement is not cascading; this change makes the selector addressable, so we no longer use DACQTY, but we need DACNumber or some other value. Then, we change the instantiation method to select four values for dacvolts and perhaps create some overloads for backward compatibility. Or is this what you’re talking about that you’ve changed?

  3. Santhosh says:

    Can you please share daisy chain configuration AD7554

    • Laser-Lance Fordham says:

      Hello Santhosh,
      For the hardware configuration, it can be found inside the datasheet for the part.

  4. Michael says:

    Hi LAser-Lance,

    I am concidering to order the board for my tests but without schematics it’s useless as I don’t know the parts beside the AD5754, ADR421BRZ and TPS7A4700.

    Can you provide the schematics too?

    Regards
    Michael

    • Laser-Lance Fordham says:

      Hi Michael,
      In the Eagle BRD file, all components are fully documented, including part numbers and vendor, where available. In any case, I have added both the schematic and the Eagle-generated BOM to the download section.
      Good luck!
      Lance.

      • Michael says:

        Hi Lance,

        thank you for providing the schematics. It mades it a lot easier for me as a non-professional.
        I took this information to develop an openGalvo shield for the teensy 3.6. The project will be open source respective open hardware (if you don’t have issues with that). Is there a possibility to contact you via mail? I don’t see any contact information on the website and I would like to discuss this with you directly and not via a public forum 😉 My mail is provided in the form

        • Laser-Lance Fordham says:

          Hi Michael,
          I attempted to email you, but it bounced back. Feel free to contact me via lance at laserlance.com.

  5. Wesley Kuegler says:

    Hi Lance,
    I’m a student intern working at NASA’s Langley Research Center in Hampton, Virginia. I’ve been using your library this summer to build an Arduino-driven sensor simulator system for the Mars2020 rover’s heat shield instrumentation suite. I’ve made some substantial additions to the library, the most significant of which is the ability to operate multiple DACs in daisy-chain mode. I’m planning on sharing my updated version of the library – either with you directly or in my own repository on GitHub – but I thought I’d try to get in touch with you beforehand to make sure you wouldn’t mind. You can reach me at [email removed] for the next week, until my NASA credentials expire as the internship ends. If I haven’t heard from you by then, I’ll place the updated library on GitHub and be sure to credit your website.

    Thanks for building such a useful library!

    • Laser-Lance Fordham says:

      Hi Wesley,

      It was so nice to receive your message. I’m glad you were able to get some use out of the library, especially on such a cool project! Please feel free to share as you wish, with hope that you will keep the attribution to myself and Bernd Rilling.
      I once wondered if developing open-source things was worth it, but now there is no doubt in my mind as I see how this collaboration is really making a difference. Absolutely wonderful.

      Laser-Lance.

  6. Michael says:

    Will your library work on the Uno r3?
    Great work by the way.

    • Laser-Lance Fordham says:

      Hi Michael,
      Thank you for your kind words. Yes, this library should work with the Uno r3. The library uses the SPI channel to communicate with the DAC so you would want to keep that in mind for your PCB design. The AD575* series is 5V tolerant, too, but I added a regulator to my design because I wanted to take advantage of an isolated, low-noise, input power, which can be important for a DAC. Good luck!
      -Laser-Lance.

  7. William Evans says:

    Hello Lance,

    I am interested in using this design for expansion of an arduino due based control system. Would it be possible to have access to the schematic file of your circuit please? I am a student trying to learn a bit about electronics and would like to learn from your design. I have tried downloading your files from OSHPark but cannot open them with the version of Altium I have access to.

    Thanks for your help,
    Will

    • Laser-Lance Fordham says:

      The board file that is on OSHPark can be opened with the Freeware version of Eagle. From there, you can see all of the component values and such. I do not presently have PDF versions of this schematic, and I do not distribute the sch file.

  8. Xnei says:

    Hello Lance,
    This is a very interesting project. I’m trying to think of best ways to power them up in bipolar mode. Suppose I want -3 V~ 3 V DAC output then I’ll need some negative voltage on Vss. How would you configure your powers in such case? Is it possible to power the board through USB and have ground shared to other regulated supply for negative voltage ? It would be nice if the power distribution can be unified in a single cord (+5V, GND and -5V) though.

    • Laser-Lance Fordham says:

      On my shield, I put a configurable jumper (JP2) that would allow either a unipolar or bi-polar power supply to be used. I did this because I knew that I would have an external power supply that would provide power to the analog side of the chip since I didn’t want to add any sort of voltage upconverter to achieve the 10.8V over concerns of reaching the current limit of the USB supply. It is imperative that the supply for the chip and reference be isolated from the AVSS and AVDD supply. One can add a separate regulator, or regulators in the case of positive and negative voltage, so that the isolation is maintained. This is actually a good idea if you are working in the -3V to +3V range.

  9. Logan says:

    Hi Lance,
    Could you please send me the board file, bom and schematic?

    Btw, which is the maximum output current that internal buffer is able to supply in this DAC?

    Best regards,
    Logan

    • Laser-Lance Fordham says:

      Hi Logan,

      The board file can be found at the OSH Park website. I will not be back at the computer that has the other files until after the first of the year. However, the components on the board file have been thoroughly documented [right-click the component in Eagle and select “Properties”].

      Please see Figure 26 of the datasheet for the AD5754. In this figure, it gives about a ±20mA source/sink current. This is with a 2kohm load and 4000pF capacitance. That said, the short-circuit current is 20mA so if you need more than about 15mA, you may want to use a precision buffer.

      Lance.

  10. Glenn WEst says:

    Did you finish the shield? I’m looking for one just like it, for 0-10v output.

    • Laser-Lance Fordham says:

      Hi Glenn,

      I did finish the shield, but I haven’t had a chance to setup any sort of store. If you’re interested, I’ll send along the board file, BOM, and PDF schematic, and you can have OSHPark make you a few.

      Sorry so late getting back with you.

      Lance.

  11. Josh says:

    Are you selling these shields?

    • Laser-Lance Fordham says:

      Hi Josh,

      At this time, I’m not selling them. However, if you are still interested then I can send you the board file, the BOM, and a PDF of the schematic so that you can have OSHPark make a few and build them.

      Lance.

  12. Shay Ohayon says:

    Hi,

    This project sounds exactly like what I need for my application (laser control from Arduino).
    Is there a way to get/buy one of your boards?

    Thanks!

    Shay

  13. Farrokh Chothia says:

    Hi!

    very interested in this project…. as you mention, there are a lot of DAC / Arduino examples out there, but oat of them use a low pass filter…. how are your trials going? Im looking for a solution to drive my 0>10v hydraulic solenoid valve via an arduino, but the hyd controller accepts only an analog dc signal

    cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *