Electronics > Beginners
SPI interfacing with AD5791 DAC via Raspberry Pi?
<< < (3/4) > >>
imisaac:
This is a follow-up test. The working solution is given below:

1. The bit pattern to be sent to the SPI slave device (i.e. AD5791) does not need to be reversed in order.

2. The SPI mode of AD5791 can be either mode 1 (thanks to mikerj) and mode 3 (thanks to rrosario from this thread https://ez.analog.com/data_converters/precision_dacs/f/q-a/110156/spi-mode-of-ad5791/326300#326300). Both work equally well in my test program.

3. The LDAC bit should be set to 1 right after writing a value to the DAC register to “trigger” the output. This creates a square pulse on the LDAC pin. This is software triggering using the SPI bus.

4. An alternative way to trigger the output without writing to the LDAC bit is to physically short the LDAC pin and the DGND pin on the AD5791 evaluation board. The DAC output is updated automatically right after writing a value to the DAC register.

5. The interconnection between the AD5791 evaluation board and the Raspberry Pi are 5 wires. They include SCLK, SYNC, SDO, SDIN, and DGND on the evaluation board connecting to SPI0_CLK, SPI0_CE0, SPI0_MISO, SPI0_MOSI, and Ground respectively on the Pi.

6. The jumper settings on the AD5791 evaluation board are as follows: LK1=A, LK2=inserted, LK3=removed, LK4=removed, LK5=inserted, LK6=removed, LK7=removed, LK8=B, LK9=B, LK10=B, LK11=removed.

7. An working test program written in Matlab to drive the AD5791 is shared below (the physical pin of LDAC does not need to be grounded in this case):

--- Code: ---clear rpi; clear spidevice;
rpi = raspi('192.168.2.2','xx,'xxx');
enableSPI(rpi);
spidevice = spidev(rpi,'CE0',1,500000);

%% Write to the "software control register" to reset the DAC to power-on state
wdata = ['010000000000000000000100'];
writeAD5791(spidevice,wdata);

%% Write to the "control register" to initialize the DAC to normal state
wdata = ['001000000000000000010010'];
writeAD5791(spidevice,wdata);

%% Write to the "DAC register" to place some non-zero voltage value at the register
wdata = ['000111000000000000000000'];
writeAD5791(spidevice,wdata);

%% Write to the "software control register" to enable the DAC output
wdata = ['010000000000000000000001'];
writeAD5791(spidevice,wdata);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function [readdata] = writeAD5791(spidevice,wdata)
    readdata = writeRead(spidevice,[bin2dec(wdata(1:8)) bin2dec(wdata(9:16)) bin2dec(wdata(17:end))],'uint8');
    pause(0.5);
end

--- End code ---

Thanks all!
mikerj:
Glad you got it working, and thanks for letting us know.
imisaac:
Just a short update.

I added a ground isolator for the SPI bus (LTM2887 evaluation board) such that the ground of the USB is not connected to the digital ground of the AD5791 DAC.

Attached is a picture of the current setup.
imisaac:
Just another short update.

In the datasheet of AD5791, the voltage output noise floor is specified at ~8 nV/√Hz (see the attached figure).

Using the setup presented here (unboxed, not carefully shielded yet), I measured the noise floor to be ~20 nV/√Hz (see the measurement plot).

Has anyone managed to reproduce the noise floor of AD5791 in the datasheet?

Thanks in advance.
RandallMcRee:

--- Quote from: imisaac on April 30, 2019, 03:27:58 pm ---Just another short update.

In the datasheet of AD5791, the voltage output noise floor is specified at ~8 nV/√Hz (see the attached figure).

Using the setup presented here (unboxed, not carefully shielded yet), I measured the noise floor to be ~20 nV/√Hz (see the measurement plot).

Has anyone managed to reproduce the noise floor of AD5791 in the datasheet?

Thanks in advance.

--- End quote ---

I have not tried, yet, but there would be no way without proper shielding at those low levels. The spuriae in your plot look like unshielded interference problems, as well. In addition, air drafts become important (although not at 1khz!).

What frequency range are you really interested in? You ought to first verify that you can get reliable noise measurements with a grounded output. Especially when using ground isolation, you could be measuring some artifacts unrelated to the 5791. Your measurement noise floor should be measured, first.
Navigation
Message Index
Next page
Previous page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod