Software for DAC i2c to arduino

Hi,

I have the following code that I need to verify to read the MCP4725 board connected to the I2CAS1 on an arduino uno. I don’t know what the base I2c address is of the ADC since the marking on the chip says AJAR and that isn’t referenced in the manual for the chip.

This is the code segment I have:

init:

Wire.begin();

loop:

//write to DAC

dac_output = 4000; //12 bit value

TWBR = 12; //400khz
Wire.beginTransmission(0x60); //default address
Wire.write(0x40); //write to the DAC
Wire.write(dac_output /16); //upper data bits
Wire.write((dac_output % 16) << 4);
delay(10);
Wire.endTransmission();

Any thoughts on driving the DAC to a specific voltage?

I haven’t changed any of the jumpers

Darren

Hi,
You can use i2c scan code to find out the address.
i use this one

once you find out the address you can simply change the dac register value and it will change the dac output voltage.

ok so that works if I put that segment of code in the init and can change the DAC value on 0x60 using that code. However when I run that code in the loop, it won’t adjust the value of the DAC. Is there a delay I need to be considering?

#include <Wire.h>
void setup()
{
Serial.begin (9600);
Wire.begin();

}

int set_volt ( int raw_value)
{
Wire.beginTransmission(0x60 );
Wire.write(64);
Wire.write(raw_value >> 4); // 8 MSB
Wire.write((raw_value & 15) << 4); //4 LSB
Wire.endTransmission();
Serial.print (raw_value, DEC);
Serial.print("\n");
}
void loop()
{

for (int i=0; i <= 4096; i++)
{
Wire.beginTransmission(0x60 );
Wire.write(64);
// Wire.write(64);
Wire.write(i >> 4); // 8 MSB
Wire.write((i & 15) << 4); //4 LSB
delay(1000);
Serial.print (i, DEC);
Serial.print("\n");
Wire.endTransmission();
i = i + 10;
}
//set_volt(4095);
}