General ArduinoGravity

GP82XX - Issue writing DAC values - random sine-waves intermitently appearing

userHead Martin.Heroux 2024-06-25 14:12:58 60 Views4 Replies

I purchased and received two GP8211 DAC for a project I am working on. I needed the option of larger range (0-10V) and also the additional resolution (15-bit).

 

Set-up.

 

I followed the online Wiki. Downloaded and installed the library from github. Connected an Arduino Uno (official) and upload the demo code from the Examples. This worked.

 

Problem.

 

Next, I modified the example to cycle through various values.

 

I noted that at certain times, a clean output was being generated. However, at other times, a large amplitude, high-frequency sine-wave was being generated.

I tried both the the GP8211 I purchased and had the same issue. Thinking it might be my Arduino, I uploaded my script to an Elegoo Mega 2560; unfortunately I ran into the same problem.

 

Below is the sketch I am running and also a screencast of the issue happening as I cycle up and down through difference values.

 

Any help with this issue would be greatly appreciated.

 

“”"

#include <DFRobot_GP8XXX.h>

DFRobot_GP8211S GP8211S;

void setup() {

 Serial.begin(9600);

 while(GP8211S.begin()!=0){
   Serial.println("Communication with the device has encountered a failure. Please verify the integrity of the connection or ensure that the device address is properly configured.");
   delay(1000);
   
 }
 GP8211S.setDACOutRange(GP8211S.eOutputRange5V);
 /**
  * @brief. Configuring different channel outputs for DAC values
  * @param data. Data values corresponding to voltage values
  * @n (0 - 32767).This module is a 15-bit precision DAC module, hence the values ranging from 0 to 32767 correspond to voltages of 0-10V respectively.
  */

}

void loop() {

 for (int value=0; value<33; value++){ 
    
 Serial.print("Value to write:");
 Serial.println(value*1000);
 GP8211S.setDACOutVoltage(value*1000);
 delay(200);
 }
 
 for (int value=32; value>0; value--){ 
   
 Serial.print("Value to write:");
 Serial.println(value*1000);
 GP8211S.setDACOutVoltage(value*1000);
 delay(200);
 }
}
 

“”"

 

2024-07-01 17:48:14

The issue you're encountering with the GP8211 DAC module generating unexpected high-frequency sine waves instead of the expected output voltage can be attributed to several factors, including improper configuration or issues with the wiring and power supply. Here are some steps and considerations to help troubleshoot and resolve the issue:

### 1. Check Power Supply

- **Voltage and Current**: Ensure that the GP8211 DAC module is receiving a stable and adequate power supply. The module typically requires a supply voltage within the specified range (often 5V or 3.3V) and sufficient current capacity to operate correctly.

- **Decoupling Capacitors**: Place capacitors (e.g., 100nF ceramic capacitors) close to the power supply pins of the GP8211 module to filter out noise and stabilize the voltage.

### 2. Verify Wiring and Connections

- **Signal Lines**: Double-check all connections between the Arduino (Uno or Mega) and the GP8211 DAC module. Ensure that the data (SDA, SCL, if using I2C) and power (VCC, GND) lines are correctly connected and secure.

- **I2C Address**: Confirm that the I2C address of the GP8211 module matches the address specified in the library or your code. Incorrect addressing can lead to communication failures or unexpected behavior.

### 3. Software Configuration

- **Library and Initialization**: Ensure that the DFRobot_GP8XXX library is correctly installed and initialized in your Arduino sketch. The `GP8211S.begin()` function should return 0 (success) to indicate proper communication with the device.

- **Output Range**: Verify that `GP8211S.setDACOutRange(GP8211S.eOutputRange5V);` correctly sets the output range to 0-5V as intended. This ensures that the DAC is configured to output within the desired voltage range.

### 4. Debugging the Output

- **Output Voltage Check**: Use a multimeter to measure the actual output voltage from the GP8211 DAC module during operation. Compare these readings with the expected voltages you are setting in your loop (`value*1000` should correspond to 0-10V in steps).

- **Scope Analysis**: If possible, use an oscilloscope to observe the output waveform directly. This can help identify any unexpected oscillations or noise in the output signal.

### 5. Code Optimization

- **Delay Adjustment**: Ensure that the `delay(200);` in your loop provides sufficient time for the DAC to settle and stabilize before changing the output voltage. If the delay is too short, it can cause erratic behavior.

### Example Adjusted Sketch

Here's an adjusted version of your Arduino sketch with minor tweaks for clarity and potential stability improvements:

```cpp
#include <DFRobot_GP8XXX.h>

DFRobot_GP8211S GP8211S;

void setup() {
 Serial.begin(9600);

 while (!GP8211S.begin()) {
   Serial.println("Failed to communicate with GP8211S. Check wiring and power.");
   delay(1000);
 }

 GP8211S.setDACOutRange(GP8211S.eOutputRange5V);
}

void loop() {
 for (int value = 0; value <= 10000; value += 1000) {
   Serial.print("Value to write: ");
   Serial.println(value);
   GP8211S.setDACOutVoltage(value);
   delay(200); // Adjust delay as needed
 }

 for (int value = 10000; value >= 0; value -= 1000) {
   Serial.print("Value to write: ");
   Serial.println(value);
   GP8211S.setDACOutVoltage(value);
   delay(200); // Adjust delay as needed
 }
}
```

### Final Steps

- **Documentation and Support**: Refer to the GP8211 DAC module's datasheet, user manual, or community forums for additional troubleshooting tips or updates related to library usage and configurations.  https://www.zouser.com/

By carefully reviewing these steps and making necessary adjustments, you should be able to resolve the issue of unexpected high-frequency sine waves and achieve reliable voltage outputs from your GP8211 DAC module using the Arduino Uno or Mega platform.

userHeadPic JAMES.JACK
2024-06-25 20:48:14

I have the same problem with two of them.

I posted some images from my oscilloscope last month on the product page.

No use posting here as they are the same but you might want to look at them in case you don't believe this person.

 

I also bypassed the on board boost converter and directly powered the chip from my bench PSU and I have the same problem.

 

As I am only generating DC for a TXCO PID loop, I don't mind the extra capacitance.

Otherwise, I think the whole chip is a failure. It's a shame because I don't think there is such a good 15 bit i2c DAC from other vendors. This one has surprisingly good linearity.

 

 

userHeadPic Rob.Fowler
2024-06-25 14:28:03

Sorry…can't figure out how to edit previous comments…

 

Also tried with the Arduino/Mega powered by 9V battery and got the same issue.

 

 

userHeadPic Martin.Heroux
2024-06-25 14:26:20

Apologies,  the video was embedded in the message as I was typing; but on submission the video does not appear at the end of my message.

 

The link to the screencast of the issue happening can be found here: “https://youtu.be/ci2Luckt9oU”

 

userHeadPic Martin.Heroux