This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

DAC8760: DAC 8760 interface with ESP 32

Part Number: DAC8760

Tool/software:

Hello everyone,

I've been trying to Interface DAC8760 to an ESP 32 for testing out the DAC in order to implement in our circuit.

I used the following connections-

MOSI(GPIO23) - DIN 

MISO(GPIO19) - SD0 

SCLK(GPIO18) - SCLK

CS (GPIO05) - LATCH

I supplied +24v to AVDD pin and -24v to ground, both ground pins of esp and dac were connected. 
I tried using the following code 

#include <SPI.h>

#define MOSI_PIN 23   // GPIO23 for MOSI
#define SCLK_PIN 18   // GPIO18 for SCLK
#define CS_PIN   5    // GPIO5 for CS (Chip Select)
#define MISO_PIN 19   // GPIO19 for MISO

// DAC8760 register addresses
#define DAC_WRITE_CR     0x02  // Control Register address
#define DAC_READ_STATUS  0x05  // Status Register address

// Initialize SPI and DAC
void setup() {
  Serial.begin(9600);
  
  // Set up SPI pins
  SPI.begin(SCLK_PIN, MISO_PIN, MOSI_PIN, CS_PIN);
  
  // Initialize DAC8760
  pinMode(CS_PIN, OUTPUT);
  digitalWrite(CS_PIN, HIGH);
  
  // Send initialization commands to DAC8760
  dac8760Init();
}

void loop() {
  // Read status register to check initialization status
  uint8_t status = readDACStatus();
  Serial.print("DAC Status: ");
  Serial.println(status, HEX);
  
  delay(1000); // Check status every 1 second
}

// Function to initialize the DAC8760
void dac8760Init() {
  // Write to Control Register (Configure DAC for current output 4-20 mA)
  // Data to write: Bit 15 (DAC Enable) = 1, Bit 13-11 (Output Range) = 100 for 4-20 mA
  digitalWrite(CS_PIN, LOW);    // Select DAC
  SPI.transfer(DAC_WRITE_CR);   // Send command to write to Control Register
  SPI.transfer(0xA0);           // High byte: 0xA0 (DAC Enable, 4-20mA output range)
  SPI.transfer(0x00);           // Low byte: 0x00 (No additional configurations in low byte)
  digitalWrite(CS_PIN, HIGH);   // Deselect DAC

  // Optionally, you could write again for different configurations (e.g., for voltage output)
  // This example configures for 4-20mA current output
}

// Function to read DAC status register
uint8_t readDACStatus() {
  uint8_t status;

  digitalWrite(CS_PIN, LOW);    // Select DAC
  SPI.transfer(DAC_READ_STATUS | 0x80); // Send command to read status register (with MSB = 1 for read)
  status = SPI.transfer(0x00);  // Receive status byte
  digitalWrite(CS_PIN, HIGH);   // Deselect DAC
  
  return status;
}
 
i was not able to receive both 4-20 mA output and voltage output. i also checked the internal reference voltage which turned out to be a stable 5v. Is there anything i am missing?


Thank you in advance.

Regards,

Abisheik

  • Hi Abisheik,

    Are you able to provide a schematic of your circuit?

    It would also be very useful to measure the SPI signal using a logic analyzer or oscilloscope to verify the digital logic.

    Thanks,
    Lucas

  • i did not add any filters since it was just a test to check the working of DAC, i supplied voltage and connected the esp using the mentioned pins. 

    apologies for late reply. Please let me know if it is necessary to add all filters for checking. my original plan was to just check the output and then work on adding filters into the schematic.

    Thanks and regards,

    Abisheik

  • Hi Abisheik,

    Can you share the current schematic you are using? And a screen capture of a logic analyzer or oscilloscope shot of a SPO write to the device?

    Best,

    Katlynne Jones

  • Abisheik,

    The logic analyzer plot is very important just to see the digital communications going to the device. You might want to also use the SDO just to read back registers to see that the communication is ok.

    One thing that I didn't understand is that you have a +24V on AVDD and a -24V on GND on the ground pin of the device? If AVDD to GND is greater than 40V, then I think you're over-voltaging the device. The maximum voltage from AVDD to GND or AVDD to AVSS is 40V. 

    Joseph Wu