Library for 16 bit DAC AD5667 with I2C

Hi everyone,
i`m writing a library to be used with this I2C device.
By now, I succeeded in talking to it, but still the outputs are low.

Regarding the chip wiring, I could have messed up with the *CLR pin. Now, on the pcb, i`ve got it left floating.
On the datasheet, http://tiny.cc/06p62w , is written the following "Asynchronous Clear Input. The CLR input is falling-edge sensitive. While CLR is low, all LDAC pulses are ignored. When CLR is activated, zero scale is loaded to all input and DAC registers. This clears the output to 0 V. The part exits clear code mode on the falling edge of the 9th clock pulse of the last byte of valid write. If CLR is activated during a write sequence, the write is aborted. If CLR is activated during high speed mode the part will exit high speed mode."
So what do you thing...is that the problem?
Also, could somebody explain me the differences between the first command 000 and the fourth 011(table 8 pag 23 of the datasheet).

You can find the still under development libraries for the AD5667 here http://tiny.cc/wbq62w. Fell free to use and modify them helping e to speed up the process.

Bye,
Georgi

Also, could somebody explain me the differences between the first command 000 and the fourth 011(table 8 pag 23 of the datasheet).

0 1 1 is the combination of 0 0 0 and 0 0 1.

My interpretation of the datasheet text for the CLR pin is that you have to pull it high if you don't want to use it but still using the LDAC pin. Leaving it floating means it may be activated any time, you don't have control over it. So connect it to Vcc in case you plan to use the LDAC pin or to GND if you don't want to use the LDAC pin.

Thanks for the reply.
My LDAC pin is permanently grounded because not used. And now, as you said, Ive connected CLR to VDD. Still I dont see anything at the output.

What I do is the following:

  1. Complete software reset of all registers
  2. Set POWERDOWN registers to normal operation
  3. Set LDAC registers to transparent
  4. Write and update both DAC channels.
  5. Read operation

p.s. The only way of seeing some signal is by putting POWERDOWN register to “high impedence”. In that way the cascaded buffer saturates to VDD, otherwise always 0V.
p.p.s I would think my libraries are broken, but the fact that I see some response when changing registers means that both the connection and software are right.

My LDAC pin is permanently grounded because not used. And now, as you said, I`ve connected CLR to VDD.

Did you really read my post? I wrote, if you don't use LDAC, pull CLR to GND.

Post your code.

:sweat_smile: :sweat_smile: :sweat_smile:
In any case its "edge sensitive" and the important is to keep it quite. Thats, the sketch.

#include <Wire.h>
#include "AD5667.h"

ad5667 dac(ad5667_ADDRESS_GND); 

void setup() {                
    Serial.begin(19200);    // initialize serial communication 
    Serial.println("Initializing I2C devices..."); 
    dac.begin();            // join I2C bus
    Serial.println("Setting transparent LDAC..."); 
    dac.reset(1);           //reset ALL
    dac.setLDAC(1,2);       //setting both LDAC transparent
    dac.setPOWERDOWN(0,2);  //setting normal POWER operationing   
}

void loop() 
  {   
    uint16_t value= 0x0000;
    while(value<0x7FFF){
      Serial.print("Writing value: ");
      Serial.print(value,(DEC));
      dac.writeDAC(3,2,value);  //Write and update command 011(3),both DAC(2),value
      delay(50);
      value=value+0xFFF;    // just writing random increasing values
      uint32_t readout = dac.readDAC();   //reading the registers
      Serial.print(". Readout returns: ");
      Serial.println(readout);
      delay(300);
    }
  }

For the libraries, you can find them here http://tiny.cc/wbq62w

Thanks for your help!
Georgi

You don't check for the return value of Wire.endTransmission(). You should! If you get a NAK you won't ever notice.

Sorry, but I cannot do that. I'm using an Arduino DUE, and the endTransmission() function is bugged returning always NACKs even when the transmission went well.
But in any case, I've checked the sketch with an UNO and still no results.
I've sent an email also to the Analog Devices "emergency desk". Let's see if they can tell me something.

I'm using an Arduino DUE

You didn't mention that, that's quite an important information as many details are different between the "standard" Arduinos and the Due. Did you have success with I2C on the Due with other devices? Do you use external pullups?

Im actually going backwards now. As you can see here http://forum.arduino.cc/index.php?topic=180552, its a quite a long time i`m arguing with this DUE.
I made a mistake when building up the connection. Missed the voltage translator and the DUE nothing was working. I had to implement a homemade translator with two transistors, taken out the wrong 1K pull ups from the Arduino DUE and placed resistors outside for both (so all 4 wires) directions and both Wire and Wire1.
I get to work both a DS3231 RTC and an ADS1115 ADC with the DUE, by using the libraries that can be found on the sparkfun site. I just had to modify few lines, but nothing difficult.

After all the hardware part was done and working (apart from the endTransmission() function), I`ve started writing the library for the last device for which the Arduino community has never written anything, the AD5665.

When I started seeing that it was not working I`ve switched back to my arduino UNO, to be sure that I was not arguing again with some bugs in the Wire.h arm library.

So thats all the story :~

Tomorrow I`ll try to add the end transmission to the UNO sketch...

Tomorrow I`ll try to add the end transmission to the UNO sketch…

Nothing to do. I`ve attached the AD5667 to my Arduino UNo and added a Serial.print to all the endTransmission(), but nothing suspicious. All the time it returns a 0. So the problem is not the connection. The UNO and the DAC are talking well.

Here btw is the email I`ve sent to Analog Devices customers support:

I’m writing you regarding a DAC i’m unable to interface with.
I’ve also opened many discussions on specialized forums but we cannot still get the device to work.
I hope the mistake in my libraries will be evident to your expert view.

I’ve written a library in C, based on the Wire.h library developed by the Arduino guys to talk with I2C devices.

Now, I’m experiencing the following:

  1. I’m able to communicate with the AD5667 by calling the right address
  • I can write to all the registers (that is confirmed by the fact that i can see the output going high when setting PowerDown High Impedence mode),
  • I can read the DAC registers (the same value written before with the write operation),
  • I see that by performing a software reset, the registers are really empty.
  1. I’ve measured the SCL and SDA pins with a oscilloscope and checked if the pulses were right and if the voltage translator (3.3V <-> 5V) between the AD5667 and the Arduino DUE was performing well.

THE ISSUE: even if I see the DAC registers written and can read them afterwards, both the outputs stay always low no matter what value has been written in the registers.

Here is the link of the discussion in the Arduino forum: http://forum.arduino.cc/index.php?topic=187215.0
And here you can find my arduino sketch along with the libraries and an image showing the connections: http://tiny.cc/wbq62w

Hi Georgi.

Please confirm that your are using a chip with an “R” suffix directly after the chip name (like AD5647RBRMZ, not AD5667BRMZ).

Chips without the first “R” do not have an on-board voltage reference, and you would need to supply your own.

Also, be sure that you noticed from our other thread that the DUE’s I2C status registers are reset upon every status-resgister-read (states of ACK’s/nACK’s, and such).

I would recommend that you not use any of the DUE’s higher-level I2C library functions. This is especially true when performing I2C transfers with multiple reads/writes and ‘repeated starts’ (SR).

Could you post a schematic?

Regards,

Chris

Chris... you are a life saver!
I've totally forgot the Vref pin, and missed the fact that i've bought the chip version WITHOUT the internal reference.

Just by setting Vref to 5V, the DAC started working!!!

With the UNO, everything is fine and smooth.
With the DUE, the endTransmission() returns always 3 (but thats not important).

Thank you again Chris. You got it perfectly right :slight_smile: BRAVO!

Hi Georgi,

My pleasure... We've all been there.

-Chris

I can't get these library's to even compile... All I get is a number of the following... "...Libraries\AD5667/AD5667.cpp:16: multiple definition of `ad5667::ad5667(unsigned char)'"

Any help would be greatly appreciated, I'm new to using these library's.

Thanks,

Hi everyone,

I have problems use these libraries, even can’t compile a code of post #4.

Arduino: 1.5.5 (Linux), Board: "Arduino Leonardo"

/home/stable/Arduino/libraries/AD5667/AD5667.h:87: error: stray ‘\226’ in program
...
/home/stable/Arduino/libraries/AD5667/AD5667.h:87: error: stray ‘\202’ in program
In file included from test_scetch_ino.ino:2:
/home/stable/Arduino/libraries/AD5667/AD5667.h:90:46: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:91:52: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:92:58: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:93:55: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:94:61: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:95:73: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:112: error: stray ‘\320’ in program
...
/home/stable/Arduino/libraries/AD5667/AD5667.h:112: error: stray ‘\270’ in program
/home/stable/Arduino/libraries/AD5667/AD5667.h:114:43: error: empty character constant
/home/stable/Arduino/libraries/AD5667/AD5667.h:203: error: stray ‘\320’ in program
...
/home/stable/Arduino/libraries/AD5667/AD5667.h:203: error: stray ‘\275’ in program
/home/stable/Arduino/libraries/AD5667/AD5667.h:239: error: stray ‘$’ in program
...
/home/stable/Arduino/libraries/AD5667/AD5667.h:256: error: stray ‘$’ in program
/home/stable/Arduino/libraries/AD5667/AD5667.h:1: error: expected unqualified-id before ‘<’ token
/home/stable/Arduino/libraries/AD5667/AD5667.h:3: error: expected constructor, destructor, or type conversion before ‘.’ token

Help me, please.