Problem interfacing with AD766JN serial DAC chip

I’m trying to interface with the AD766JN 16-bit DAC chip.

This is my first post, so I am not allowed to post the link to the datasheet, but you can pull it up by googling for AD766JN. It will be the first result.

I suspect there is something simple going wrong with my serial interface code. The DAC seems to respond only to the LSB of the input.

I have the AD766 connected as follows:

-Vs: to analog ground
DGND: to arduino GND
Vl: to arduino 5V
CLK: to arduino #4
LE: to arduino #3
DATA: to arduino #2
-Vl: to arduino GND
Vout: to Rf and to 10 Kohm resistor to analog ground
Rf: to Vout
SJ: to Iout
AGND: to analog ground
Iout: to SJ
MSB ADJ: NC
TRIM: NC
Vs: to +7.5v analog power supply

The decimila board is powered externally by the analog 7.5v power supply connected to Vin and Gnd, and the power select jumper is on EXT.

Here is a simplified version of the code I’ve been trying:

#define LED 13

#define DAC_DATA 2
#define DAC_LE 3
#define DAC_CLK 4

boolean blink;

void setup()
{
  blink=false;

  pinMode(LED,OUTPUT);

  pinMode(DAC_DATA,OUTPUT);
  pinMode(DAC_LE,OUTPUT);
  pinMode(DAC_CLK,OUTPUT);

  digitalWrite(LED,LOW);
}

void loop()
{
  blink=!blink;

  digitalWrite(LED,blink);

  unsigned int value=blink?32767:0;

  for(unsigned int i=0;i<16;i++)
  {
    boolean bit=0!=(value&(1u<<(15u-i)));
    digitalWrite(DAC_CLK,HIGH);
    digitalWrite(DAC_DATA,bit?HIGH:LOW);
    digitalWrite(DAC_CLK,LOW);
  }

  digitalWrite(DAC_LE,HIGH);
  digitalWrite(DAC_CLK,HIGH);
  digitalWrite(DAC_LE,LOW);
  digitalWrite(DAC_CLK,LOW);

  delay(1000);
}

This code seems to do what I expect. I have confirmed this by inserting long delays and adding LEDs to the DATA, LE, and CLK lines, and watching the sequence.

With a volt meter attached across the 10 Kohm resistor, I see that the voltage varies by about 0.1 mV with each alternate run through the loop. The voltage goes up by 0.1 mV when the LED turns on, and goes down by 0.1 mV when the LED turns off.

Since the code does what I expected it to (confirmed by adding delays and LEDs), and the DAC does respond in some way to my input, I am led to think that I am misunderstanding something about the way I am supposed to communicate with the DAC.

If I add a line at the bottom of loop() to set DAC_DATA to LOW, I do not see the 0.1 mV oscillations. This leads me to think that the DAC’s latch is stuck, and its outut is always reflecting the LSB as whatever is on the DATA line at the time.

I’ve tried another identical AD766 chip to verify that I didn’t accidentally blow up the one I started with.

Any help would be greatly appreciated! I’ve been pulling my hair out over this for a few days now. :slight_smile:

I am not sure about some of your bit operations but that’s maybe my lack of C skills. I would do:-

value = millis() & 0xffff;
for(unsigned int i=0;i<16;i++)
  {
    digitalWrite(DAC_CLK,HIGH);
    if((0x1 << i) & value) !=0) digitalWrite(DAC_DATA,1);   else digitalWrite(DAC_DATA,0);
    digitalWrite(DAC_CLK,LOW);
  }
  digitalWrite(DAC_LE,HIGH);
  digitalWrite(DAC_CLK,LOW);

Not tested

The bit-twiddling code is equivalent. Your code sets the dac to various values depending on millis(), where mine just bounces back and forth between full-on and full-off every second.

OK ho have you got it wired up? That chip requires a supply with +ve ground and -ve are you providing that?
It has a current output are you putting that through a resistor?

Edit. Just re read the first post. You need a -ve supply you cant connect it to ground.

I was worried about that, but according to the section in the datasheet titled "absolute maximum ratings", it should be ok.

VL to DGND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 to 13.2 V VS to AGND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .0 to 13.2 V –VL to DGND . . . . . . . . . . . . . . . . . . . . . . . . . . –13.2 V to 0 V –VS to AGND . . . . . . . . . . . . . . . . . . . . . . . . . . –13.2 V to 0 V Digital Inputs to DGND . . . . . . . . . . . . . . . . . . . . –0.3 V to VL AGND to DGND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ±0.3 V

The way I'm reading that, it is ok for -VL and -VS to be the same as their respective grounds.

thats absolute minimum ratings that the chip can withstand, not what it will operate at!

The way I'm reading that, it is ok for -VL and -VS to be the same as their respective grounds.

Sorry no, those op amps in the IC won't work without a -ve rail.

In fact the data sheet says about absolute maximum ratings:-

This is a stress rating only and functional operation of the device at these or any other conditions above those indicated in the operational section of this specification is not implied. Exposure to absolute maximum rating conditions for extended periods may affect device reliability

This section seems to me to be unnecessarily obfuscated:

  for(unsigned int i=0;i<16;i++)
  {
    boolean bit=0!=(value&(1u<<(15u-i)));
    digitalWrite(DAC_CLK,HIGH);
    digitalWrite(DAC_DATA,bit?HIGH:LOW);
    digitalWrite(DAC_CLK,LOW);
  }

why not :

  for(unsigned int i=0;i<16;i++)
  {
    digitalWrite(DAC_CLK,HIGH);
    digitalWrite(DAC_DATA, (value >> (15 - i)) & 1);
    digitalWrite(DAC_CLK,LOW);

?

Like I said, the code was simplified for posting. :-) I write C and C++ code for a living, so I don't have any trouble reading either version. In C, it's more idiomatic in my experience for this sort of test to shift '1' left than to shift 'value' right. I figured that HIGH and LOW were just #defines for true and false, but that I'd be chastised for not using the official #defines, since they are no doubt more idiomatic in the Arduino community. :-) In any case, that isn't the cause of the problem I'm having.

I am eager to try supplying the correct negative voltages to the chip to see how that works. The easiest way I know to get my hands on a -5V supply is by using a PC power supply. I don't think that is the best route in the long term, since my application will be sensitive to the switching noise in those supplies, and their -5V and -12V rails are asymmetric to their positive counterparts with respect to maximum power.

Add plenty of decoupling to the supply rails and get a proper ground layout. Also read the data sheet, there is a section on power supply configuration but if you have -5 and -12 then that should be fine. Please let us know how you go on.

The easiest way I know to get my hands on a -5V supply is by using a PC power supply

Easier still is to go for +/- 6V with a couple of four-packs of AAs, centre tapped. A lot quieter than a PC supply too!

It is working great now! I put on the AA packs as AWOL suggested ($2 compared to ~$50), and it came right to life.

Thanks to Grumpy_Mike for spotting the problem.