I'm new to using I2C devices and I'm currently working with a PCB that has one DAC and one ADC. For the ADC, I'm using the ADS1112 from Texas Instrument with the following code that seems to be working.
{
Wire.begin(); // Wire communication begin
Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
while (!Serial); // Waiting for Serial Monitor
}
int8_t x0,x1;
void loop()
{
Wire.beginTransmission(0x48);
Wire.write(10001100); //PGA modification
Wire.endTransmission();
Wire.requestFrom(0x48,2);
if(2 <= Wire.available())
{
x0=Wire.read();
x1=Wire.read();
Serial.print("x0=");
Serial.print(x0);
Serial.print("\n");
Serial.print("x1=");
Serial.print(x1);
Serial.print("\n");
int16_t ADC_value=((int16_t) x0<<8)|x1;
// int16_t ADC_value=((int16_t) x1>>8)|x0;
Serial.print("ADC_value=");
Serial.print (ADC_value);
Serial.print("\n");
Serial.println(ADC_value);
delay(100);
}
}
However, I'm having issues communicating with the DAC MAX5816 from Maxim Integrated Products. I'm using the following code to write to the device but it doesn't do anything and shuts down the board when uploaded.
void setup()
{
Wire.begin(); // Wire communication begin
Serial.begin(9600); // The baudrate of Serial monitor is set in 9600
while (!Serial); // Waiting for Serial Monitor
}
void loop()
{
//Write
Wire.beginTransmission(0x0F);
Wire.write(00010000);// Five most significant bits 00011 + LSBs 01 for Vdd -> A1 and GND -> A0 + R/W| bit to 1 for read mode
Wire.endTransmission();
}
As the code for the ADC is working, I don't think it's a problem linked to pull up resistors or the devices addresses. I would also like to read from the DAC but don't know how to proceed. The final goal is simply to pass information from the ADC to the DAC and see if the conversion is good. Can someone help me with that please?
Note: I could not find libraries for the converters and changing components is difficult as it would mean I have to re-desing the whole PCB that has other components on it. (I can't upload the technical datasheets as I'm a new user)