[SOLVED]AD5305 DAC - I²C Problem?

Hi,

I’m trying to connect an AD5305 through the I²C bus. This is my code:

#include <Wire.h>


void setup() {

  Wire.begin(); 
  Serial.begin(115200);
  Serial.println("Ready.");
  delay(1000);
  
}




void loop() {

Wire.beginTransmission(12); // Addresspin GND: 0001100

Wire.write(B00000001);       // Choosing DAC A
  
Wire.write(B00111111);       // CLR: Normale operation LDAC: Only addressed input DATA: 1111
  
Wire.write(B00000000);       // DATA: 0000
  
Wire.endTransmission();
 
  
Serial.println("updated.");
  
}

Is the code itself correct? I am not sure if I am allowed to send bytes this way, but changing it to byte(B00000000) didn’t make a difference.

Start with the i2c_scanner : http://playground.arduino.cc/Main/I2cScanner Use the address that is found by the i2c_scanner. If nothing is found, then there is a problem with the I2C bus (the hardware).

Your code: Sketch : The loop() might run too fast. Add "delay ( 500 ) ;" at the end of the loop(). Address 12 = 0x0C : probably okay, could be 12 or 13. Usage of Wire library : okay. Pointer byte for DAC A : okay. Two shift register bytes for AD5305 : PD1 PD0 = 00: okay, /CLR /LDAC = 11: okay. D4..7 = 1 and D0..4 = 0: fine.

shnytzl: Hi,

I'm trying to connect an AD5305 through the I²C bus. This is my code:

Schnytzl, If you want the DAC output to immediately change when you update it, set the /LDAC bit to low when you write the register data.

Do you have 4.7k pullups on SDA and SCL?

Which Arduino are you using? UNO, MEGA?

Koepel: Start with the i2c_scanner : http://playground.arduino.cc/Main/I2cScanner Use the address that is found by the i2c_scanner. If nothing is found, then there is a problem with the I2C bus (the hardware).

Your code: Sketch : The loop() might run too fast. Add "delay ( 500 ) ;" at the end of the loop(). Address 12 = 0x0C : probably okay, could be 12 or 13. Usage of Wire library : okay. Pointer byte for DAC A : okay. Two shift register bytes for AD5305 : PD1 PD0 = 00: okay, /CLR /LDAC = 11: okay. D4..7 = 1 and D0..4 = 0: fine.

Koepel, I disagree, /LDAC must be low (0). This device has a doubled buffered input. you can load all 4 DAC's and activate them at the same time. If you load the first three DAC's with /LDAC HIGH, then, load the LAST DAC with /LDAC low. All of the DAC's will immediately output the 'new' values at the same time.

Check page 18 of the data sheet. DOUBLE-BUFFERED INTERFACE

Chuck.

Koepel: Start with the i2c_scanner : http://playground.arduino.cc/Main/I2cScanner Use the address that is found by the i2c_scanner. If nothing is found, then there is a problem with the I2C bus (the hardware).

Your code: Sketch : The loop() might run too fast. Add "delay ( 500 ) ;" at the end of the loop(). Address 12 = 0x0C : probably okay, could be 12 or 13. Usage of Wire library : okay. Pointer byte for DAC A : okay. Two shift register bytes for AD5305 : PD1 PD0 = 00: okay, /CLR /LDAC = 11: okay. D4..7 = 1 and D0..4 = 0: fine.

Thanks for you answer. I already have a delay(500) at the end, looks like I didn't copy it. Thanks for the I2cScanner, I didn't know about that! Will try asap.

chucktodd: Schnytzl, If you want the DAC output to immediately change when you update it, set the /LDAC bit to low when you write the register data.

Do you have 4.7k pullups on SDA and SCL?

Which Arduino are you using? UNO, MEGA? Koepel, I disagree, /LDAC must be low (0). This device has a doubled buffered input. you can load all 4 DAC's and activate them at the same time. If you load the first three DAC's with /LDAC HIGH, then, load the LAST DAC with /LDAC low. All of the DAC's will immediately output the 'new' values at the same time.

Check page 18 of the data sheet. DOUBLE-BUFFERED INTERFACE

Chuck.

I am using an Arduino Nano, but also tried with an Arduino Mega 2560. I also tried supplying the DAC with 3,3V and 5V. Plus, I tried different pullups, ranging from 3.6k to 12k. That doublebuffer concerns me. Does that mean I should have two write sequences? One for loading the inputregisters and one for setting them at the output?

EDIT: Thank you so much, that LDAC hint was the solution! I just understood that part in the datasheet completely wrong.