Arduino I2C DAC LTC2631 12-bit

Hey everyone, hoping someone can help me figure out why my Vout pin on my LTC2631 is not outputting the sine wave on the oscilloscope. I am using an Arduino uno.

Thanks in advance,

//Include the Wire Library
#include <Wire.h>
//Set up the address of the D-A sensor
#define ADDRESS 0x73

byte da_MSB;
byte da_LSB;
int i = 0;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
}
static int sine[] = {
    0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
    0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
    0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
    0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
    0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
    0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
    0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
    0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
    0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
    0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
    0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
    0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794
};

void loop()
{
  //Send a Request
  //Start Talking
  Wire.beginTransmission(ADDRESS);
  //Ask for Register one
  Wire.write(1);
  //Complete Transmission
  Wire.endTransmission();
  //Request 2 byte
  Wire.requestFrom(ADDRESS, 2);
  //wait for a response
  while(Wire.available() == 1); //same as register one
  
  da_MSB = Wire.read();
  da_LSB = Wire.read();
  
  analogWrite(da_MSB, sine[i]);
  i++;
  if(i == 120)
    i = 0;
}

Hi there

  da_MSB = Wire.read();
  da_LSB = Wire.read();
  
  analogWrite(da_MSB, sine[i]);

You are reading two bytes from the I2C bus and then using one of them to specify an Arduino pin. Then you are setting a PWM output value on that Arduino pin.

You don't seem to be sending the sine wave value to the DAC.

Regards

Ray

if this was an Arduino Due I would use the DAC1 pin to assign to the DAC's Vout pin.

So since I'm using an Arduino Uno, I should assign an analog pin to the DAC's Vout pin correct?

Like so?

//Include the Wire Library
#include <Wire.h>
//Set up the address of the D-A sensor
#define ADDRESS 0x73

byte da_MSB;
byte da_LSB;
int i = 0;
int analogPin = 3; //DAC Vout pin connected to analog pin 3
int val = 0;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
}
static int sine[] = {
    0x7ff, 0x86a, 0x8d5, 0x93f, 0x9a9, 0xa11, 0xa78, 0xadd, 0xb40, 0xba1,
    0xbff, 0xc5a, 0xcb2, 0xd08, 0xd59, 0xda7, 0xdf1, 0xe36, 0xe77, 0xeb4,
    0xeec, 0xf1f, 0xf4d, 0xf77, 0xf9a, 0xfb9, 0xfd2, 0xfe5, 0xff3, 0xffc,
    0xfff, 0xffc, 0xff3, 0xfe5, 0xfd2, 0xfb9, 0xf9a, 0xf77, 0xf4d, 0xf1f,
    0xeec, 0xeb4, 0xe77, 0xe36, 0xdf1, 0xda7, 0xd59, 0xd08, 0xcb2, 0xc5a,
    0xbff, 0xba1, 0xb40, 0xadd, 0xa78, 0xa11, 0x9a9, 0x93f, 0x8d5, 0x86a,
    0x7ff, 0x794, 0x729, 0x6bf, 0x655, 0x5ed, 0x586, 0x521, 0x4be, 0x45d,
    0x3ff, 0x3a4, 0x34c, 0x2f6, 0x2a5, 0x257, 0x20d, 0x1c8, 0x187, 0x14a,
    0x112, 0xdf, 0xb1, 0x87, 0x64, 0x45, 0x2c, 0x19, 0xb, 0x2,
    0x0, 0x2, 0xb, 0x19, 0x2c, 0x45, 0x64, 0x87, 0xb1, 0xdf,
    0x112, 0x14a, 0x187, 0x1c8, 0x20d, 0x257, 0x2a5, 0x2f6, 0x34c, 0x3a4,
    0x3ff, 0x45d, 0x4be, 0x521, 0x586, 0x5ed, 0x655, 0x6bf, 0x729, 0x794
};

void loop()
{
  //Send a Request
  //Start Talking
  Wire.beginTransmission(ADDRESS);
  //Ask for Register one
  Wire.write(1);
  //Complete Transmission
  Wire.endTransmission();

  
  
  val = analogRead(analogPin);
  analogWrite(val, sine[i]);
  i++;
  if(i == 120)
    i = 0;
}

Why are you using analogWrite() with an I2C device? Here is the datasheet.

Page 22 figure 3 and table 3 covers the commands you must send to change the output.