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连接到 ESP 32、以便测试 DAC 以便在我们的电路中实施。
我采用了以下连接-
MOSI (GPIO23)- DIN
MISO (GPIO19)- SD0
SCLK (GPIO18)- SCLK
CS (GPIO05)- LATCH
我为 AVDD 引脚提供了+24V 电压、并为接地提供了-24V 电压、ESP 和 DAC 的两个接地引脚均已连接。
我尝试了使用以下代码
#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; }
提前感谢您。
此致、
Abisheik
尊敬的 Abisheik:
您是否能够提供电路原理图?
使用逻辑分析仪或示波器测量 SPI 信号来验证数字逻辑也非常有用。
谢谢!
卢卡斯
我没有添加任何滤波器、因为这只是为了检查 DAC 的工作情况的测试、我提供了电压并使用上述引脚连接 ESP。
对迟交答复表示歉意。 如果需要添加所有筛选器进行检查、请告知我。 我最初的计划是检查输出、然后再设法在原理图中添加滤波器。
谢谢。此致、
Abisheik
尊敬的 Abisheik:
您能否分享您正在使用的当前原理图? 以及向器件写入 SPO 的逻辑分析仪屏幕截图或示波器快照?
此致!
Katlynne Jones
Abisheik,
逻辑分析仪图非常重要、只是要查看进入器件的数字通信。 您可能 还需要使用 SDO 来读回寄存器、以了解通信正常。
有一件我不明白的事情是您在 AVDD 上有+24V 电压、在器件的接地引脚上有-24V GND 电压? 如果 AVDD 至 GND 大于40V、则我认为器件过压。 从 AVDD 到 GND 或从 AVDD 到 AVSS 的最大电压为40V。
Joseph Wu