I have an AD5696 quad DAC (https://store.ncd.io/product/ad5696-16-bit-4-channel-digital-to-analog-converter-i2c-mini-module/) and I2C shield (https://store.ncd.io/product/i2c-shield-for-arduino-uno/) attached to an Arduino Uno. My abbreviated code is below.
The Uno reads input from Trimpot and outputs voltage (0-5v) from the DAC although the voltage output isn’t quite right. The AD5696 uses a 16-bit binary input (Decimal 0-65535) to provide 0-5v output but it reaches 5V prematurely at around 43000. From 43000 to 65535 the DAC output remains at 4.97V. Writing 0 to DAC gives ~20mv.
I posted problem on Arduino forum and was told this may be a hardware problem related to my Vref which determines Vout from DAC. The Gain jumper (J1) is open and from reading the specification sheet this should set gain at 1x to give Vref at 2.5V max. Not sure why I’m getting over 2.5V output in current configuration. If I connect J1 pins, there is no change in DAC output voltage.
Hoping the community can point me in the right direction for a solution. Thanks!
const int flowIn;
// Read Flow
int flowIn = analogRead(A0); //read the input on analog pin (0-1023)
float flowOut = flowIn * (500.0 / 1023.0); // maximum total flow will be 500 ml/min
float flowOutDAC = flowOut * (65535.0 / 500.0); // conversion of ml/min to decimal
unsigned int flowOutDAC2 = int(flowOutDAC); //get rid of zero’s for DAC write
Serial.print("flowIn = “); Serial.print(flowIn);
Serial.print(” flowOut = “); Serial.print(flowOut);
Serial.print(” flowOutDAC = “); Serial.println(flowOutDAC);
Serial.print(” flowOutDAC2= "); Serial.println(flowOutDAC2);
//CHANNEL 1 (VoA on board)
Wire.beginTransmission(0x0c); //Binary 00001100 (address of DAC - printed on the circuit board - confrimed with I2C scanner on UNO)
Wire.write(0x31); ///// channel one Binary 00110001 (command 0011 - write to DAC; 0001 channel 1 address; tables 7 and 8 of AD5696 chipset for reference)
Wire.write(flowOutDAC2 >> 8); // send MSB data byte >> right shift 8. 0000011111101000 becomes 00000111
Wire.write(flowOutDAC2 << 8); // send LSB data byte << left shift 8. 0000011111101000 becomes 11101000
The board is a simple breakout board it doesn’t have much on it.
I am attaching the sch for your ref.
Can you measure the voltage at 5V line?
the AD5696 usages vcc as ref voltage.
AD5696_I2CDAC_A.pdf (27.8 KB)
thanks for responding so quickly. The voltage is 4.97-4.98V measured at multiple places across board. On the top LHS of diagram, it look like 2 capacitors between 5V supply and ground. I don’t see these on the breakout board.
If I use a 3.3 / 5.0 conversion factor for the decimal write to DAC seems to work.
Arduino input from Trim Pot = 0 - 1023
Write to DAC = 0 - 65535 * 3.3 / 5.0 gives 0 - 5 volts output over 0 - 43253.
I use a PI III with Qt and the PigPio library. I strictly have the same problem. My VCC value is 4.97 V for any raw value greater than 43251. Fortunately it seems to be linear.
Marcus : I understand your solution, but it does not make sense to me. why 3.3 / 5.0? All in all, its a 16 bit DAC, we should not do that.
I definitely think the boards or the chips have some issues.
Anybody at NCD to provide a solution?
In the AD5696 datasheet page 4 they talk about a dead band. This dead band reduces the range of the 16bit dac value.
DC specifications are tested with the outputs unloaded, unless otherwise noted. Upper dead band (10 mV) exists only when VREF = VDD with gain = 1 or when VREF/2 = VDD
with gain = 2. Linearity calculated using a reduced code range of 256 to 65,280 (AD5696) or 12 to 4080 (AD5694).
3 Guaranteed by design and characterization; not production tested.
The board is a breakout board and doesn’t have any electronics which could cause such issue. I will check with Analog Device people and see if they can provide a true range of this chip.
I have literally no background in electronics so you’ll probably laugh at my answer. The 3.3 / 5.0 (=0.66) conversion factor was almost identical to 43000 / 65535 (=0.656); remember that ~43000 is where my 5.0V output maxed out. In fact, if you use your more precise number of 43251, then the result is 0.66, or 3.3 / 5.0. My VRef is 5.0v measured directly from board.
There is no effect on DAC output with the J1 gain jumper - somethings amiss here.
I have ordered the 8-channel board (slightly different config, no Gain) and let you know what happens.
Bhaskar, Marcus, thanks for your quick answers.
Marcus : Now I understand your solution. You simply compute the ratio on your own. The 3.3 was strange to me cause i was possibly related to 3.3 V power supply. I hvae double checked my own ratio and found that the best value I could find was 43240. ie : In place of 65536 counts I have only 43240 counts to cover from 0 to VRef (5V).
Bhaskar : I carefully reread the chip specs. I am using a DMM to measure the voltage output, so its input impedance is very high and it does not draw any current. We can consider this as an unloaded condition. I carefully watch the schematic you sent in your first answer. It seems to me that there is an issue with the GAIN pin. It seems to be connected to the ground thru a resistor network and a jumper (which is orginally not present) and to 5V. With the jumper removed it should then be a gain of 2 according to the specs on page 8. At least for a gain of 1 the jumper should be installed. And all in all, as you mention on your product page taht it’s a 5V range, the GAIN pin should be unconditionnaly connected to GND.
I hipe AD will provide a solution.