AD7390 IC&Library don't work with Nano Matter

New to Arduino, trying to get AD7390 DAC to work with Nano Matter using AD7390 Library. I assume that IC and library are using a modified SPI interface.

Nano connected to laptop by USB. IC powered by 5V port on Nano.
Following information in the data sheet and a Forum post as best I can.

LDbar(IC 1) to D8 as suggested by codes in library examples (CS = pin 8)
CLK(IC 2) to D13
SDI(IC 3) to D11 (MOSI)
CLRbar(IC 4) to VDD (5v on Nano)
GND(IC 5) to Gnd on Nano and digital scope
Vout(IC 6) to digital scope
Vdd(IC7) to 5v on Nano
Vref(IC 8) not connected

/* Test sketch for AD7390.h library with AD7390 IC */

#include <AD7390.h>

#define DAC_CS 8

AD7390 dac(DAC_CS);

void setup() {
  digitalWrite(8, HIGH);
}

void loop() {
  dac.writeValue(256);
  delay(250);
  dac.writeValue(768);
  delay(250);
}

It just gives a fuzzy line at -8mV. Setting Pin 8 LOW makes no difference.

What am I doing wrong ?

Can you provide a link to the library archive (e.g. GitHub) ?

Found the datasheet, not a complex device.

Vref(IC 8) not connected

So you need to connect Vref to Vdd == 5V
(or e.g. 3.3V or make it configurable with a potmeter

That sounds to me like you are missing a ground connection between your oscilloscope and the Arduino ground. In other words something is floating. As there are no negative voltages involved you should not see one on an output.

Sorry I do not follow word salad as you have substituted for a clear annotated schematic. That schematic needs to show exactly how you have wired it, all power sources, ground connections etc. Links to technical information on the hardware items also helps.

I downloaded the library through Arduino IDE: GitHub - christophjurczyk/AD7390_Arduino_Library: Arduino Library for the AD7390 DAC

I have the spec sheet, will study it further.

Connecting Vref to Gnd, 3.3v or 5v (=VDD) on the Nano makes no difference.

Nano, 7390 and scope share grounds, scope ground definitely connected.

@olehweres
Thanks for the link, first look shows the last commit was ~7 years ago. Arduino libraries (incl SPI) have made a few steps since then so that might be a point of attention.

@olehweres

Looked at the code and the SPI calls are "old style" so they might just not work.

Replace writeValue() in the AD7390.cpp file with the code below

void AD7390::writeValue(uint16_t value)
{
	// select chip
    digitalWrite(_cs_pin, HIGH);
    // transfer data
    uint8_t higher =  uint8_t((value >> 8));
    uint8_t lower = value & 0x00FF;

    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
    SPI.transfer(higher);
    SPI.transfer(lower);
    SPI.endTransaction();

    // deselect chip
    digitalWrite(_cs_pin, LOW);
}

MSBFIRST might need to be LSBFIRST
SPI_MODE3 could be MODE 0,1,2,3

Please give it a try


update, slightly shorter code

void AD7390::writeValue(uint16_t value)
{
    // select chip
    digitalWrite(_cs_pin, HIGH);

    // transfer data
    SPI.beginTransaction(SPISettings(1000000, MSBFIRST, SPI_MODE3));
    SPI.transfer16(value);
    SPI.endTransaction();

    // deselect chip
    digitalWrite(_cs_pin, LOW);
}

Created an alternative library for the AD7390/91 (MIT license) to be published later today.

@olehweres
See - GitHub - RobTillaart/AD7390: Arduino library for AD7390/AD7391 12/10 bit SPI DAC.
(development branch only at the moment)

It provides additional functionality compared to the library above.

@olehweres
Released 0.1.0 - GitHub - RobTillaart/AD7390: Arduino library for AD7390/AD7391 12/10 bit SPI DAC.
Published in library manager so will be available within 24 hrs normally.

Please give it a try

I tried - and tried, but no useful results using the test or later the demo sketch.
First, a few seconds of mountain range of varying flat values.
Then, a few seconds of square wave at about 500Hz with jumping base value.
Finally, a steady value at about 2.3v.
I decided to try using MCP4725 instead in module from Sparkfun.