Introduction

This is a 16-bit high-resolution DAC module with a full-scale error of only ±0.2%. It supports I2C or PWM signal control and can be flexibly configured to output ±10V, 0-5V, or 0-10V voltage signals, or 4-20mA current signals, meeting diverse control requirements.

Compared to conventional 0-10V signals, the ±10V analog voltage output is a core feature of this module—covering a range from -10V to +10V and enabling reverse voltage output for direct bidirectional device control. Such symmetrical voltage signals are essential in many applications, such as small motor control: +10V drives forward rotation, -10V drives reverse rotation, and 0V stops the motor—all without additional circuit modifications.

The module is compatible with Arduino programming and widely supports mainstream controllers such as ESP32, and Raspberry Pi. It can directly drive devices like lights, pumps, and servo motors that require the above signal types, offering simplicity and ease of use.

As part of the DAC module series, this product—along with others in the series—can be controlled via I2C or PWM to output voltage or current signals. The series offers a wide range of options, including resolutions from 8-bit to 16-bit, single or dual-channel configurations, and support for multi-module cascading to flexibly build multi-channel output solutions.

Features

  • Supports 3.3V-5V power supply with a standard Gravity interface.
  • Compatible with I2C/PWM signal input, offering broad adaptability.
  • 16-bit resolution with a full-scale error below 0.2%.
  • Supports ±10V symmetrical analog voltage signal output.
  • Supports 0-5V and 0-10V analog voltage signal output.
  • Supports 4-20mA analog current signal output.
  • Supports 1.2× over-range voltage/current signal output.
  • Compatible with Arduino programming and supports controllers such as ESP32 and Arduino.
  • Features 8 configurable I2C addresses, enabling simultaneous control of up to 8 devices.

Applications

  • Motor Forward/Reverse Control
  • Lighting Brightness Control
  • Valve and Pump Control
  • Signal Generator
  • Automation Upgrades for Small Equipment

Specifications

Basic Parameters

  • Chip Model: GP8630N
  • Operating Voltage: 3.3V-5V
  • Power/Communication Interface: PH2.0-4Pin/3Pin
  • Input Signal: I2C / PWM
  • Output Signal:
    • Current Output Range: 0-24mA
    • Voltage Output Range: ±12V/0-6V/0-12V
  • Number of Channels: 1 channel
  • Resolution:
    • 16-bit (I2C mode)
    • 8-bit, 10-bit (PWM mode, selectable based on controller)
  • Full‑Scale Error: ±0.2% (measured after fitting calibration)
  • Value Range:
    • I2C Mode: 0-65535 corresponds to ±12V, 0-6V, 0-12V, or 0-24mA
    • PWM Mode:
      • 0-255 corresponds to ±12V, 0-6V, 0-12V, or 0-24mA
      • 0-1023 corresponds to ±12V, 0-6V, 0-12V, or 0-24mA

Physical Dimensions

  • PCB Dimensions: 42 × 32 × 12.39 mm
  • Mounting Hole Spacing: 25mm
  • Mounting Hole Diameter: 3.0 mm

Functional Schematic Diagram

DFR1230-Function diagram

Hardware Interface Description

The module interfaces are categorized into three types: I2C interface, PWM interface, and output interface. The functional definitions of each pin are presented in the following table:

Interface Type Pin Silkscreen Functional Description
I2C Interface + Positive power supply (3.3V–5V)
- Negative power supply
SCL I2C clock line (SCL)
SDA I2C data line (SDA)
PWM Interface - Negative power supply
+ Positive power supply (3.3V–5V)
D PWM signal input pin
Output Interface OUT Positive output signal (voltage/current) ranges: 0–10V, 0–12V, 10–0V, -12–0V, 0–24mA, 4–20mA
GND Negative output signal

DIP Switch Configuration Logic

The DIP switches (A0, A1, A2) are used to switch the I2C address and PWM output range. Corresponding configurations should be selected based on the control mode, and mixed use is strictly prohibited.

I2C Mode: Configure Module I2C Address

The I2C communication address of the module is defined by the combination of "0 (disconnected)/1 (closed)" for A0, A1, and A2. The default address is 0x58 (A0/A1/A2 are all set to 0).

I2C Mode
A2 A1 A0 ADDR
0 0 0 0x58
0 0 1 0x59
0 1 0 0x5A
0 1 1 0x5B
1 0 0 0x5C
1 0 1 0x5D
1 1 0 0x5E
1 1 1 0x5F

PWM Mode: ConfigureOutputSignal Range

The output type (voltage/current) and range under PWM control can be defined by focusing on specific combinations of A0, A1, and A2.

A2 A1 A0 OUT
0 1 0 -12–0V
0 1 1 0–12V
1 0 0 0–24mA

Arduino IDE User Guide

Example 1: Output 10V in 0–10V Range (I2C Mode)

Objective

Control the module to output 10V within the 0–10V range via I2C communication on the ESP32-E main controller, and verify the result with a multimeter.

Step 1: Wiring Configuration

DFR1230-I2C WIRING

Connect the module to the ESP32-E as shown in the diagram. The core corresponding relationships are as follows:

  • Module I2C interface "+" → ESP32-E 3.3V
  • Module I2C interface "-" → ESP32-E GND
  • Module I2C interface "SCL" → ESP32-E SCL (default GPIO22)
  • Module I2C interface "SDA" → ESP32-E SDA (default GPIO21)
  • DIP switch configuration: A0=0, A1=0, A2=0 (I2C address = 0x58)

Step 2: Code Upload

Open Arduino IDE, copy the following code, and upload it to the ESP32-E:

#include <DFRobot_GP8XXX.h>

// Enable I2C communication mode
#define I2C_COMMUNICATION
// Set the module I2C address to 0x58
#define MODULE_I2C_ADDRESS 0x58

// Create an I2C communication object
DFRobot_GP8630N_I2C GP8630N(&Wire, MODULE_I2C_ADDRESS);

void setup() {
  // Initialize serial communication
  Serial.begin(9600);
  
  // Initialize the DAC module
  while (GP8630N.begin() != 0) {
    Serial.println("Communication with the device failed. Please check if the connection is normal or if the device address is set correctly.");
    delay(1000);
  }
  Serial.println("Successful connection!");
  
  // Set the output range to 0–10V
  GP8630N.setDACOutRange(GP8630N.eOutputRange10V);
  
  // Output 10V (65535 corresponds to the full-scale 10V output)
  GP8630N.setDACOutData(65535);
}

void loop() {
  // No loop operations required; the output is maintained with a single configuration
}

Result Verification:

  1. Set the multimeter to the "DC V" range;
  2. Connect the red probe to the module's "OUT" terminal and the black probe to the module's "GND" terminal;
  3. Under normal conditions, the measured voltage should be close to 10V. In this example, the actual measured output voltage is 10.04V.

DFR1230-i2c result

Example 2: Output 20mA in 4–20mA Range (PWM Mode)

Objective

Control the module to output 20mA within the 4–20mA range via PWM communication on the ESP32-E main controller, and verify the result with a multimeter.

Step 1: Wiring Configuration

DFR1230-pwm wiring

Connect the module to the ESP32-E as shown in the diagram. The core corresponding relationships are as follows:

  • Module PWM interface "+" → ESP32-E 3.3V
  • Module PWM interface "-" → ESP32-E GND
  • Module PWM interface "D" → ESP32-E GPIO13 (PWM output pin)
  • DIP switch configuration: A0=0, A1=0, A2=1 (output range = 4–20mA)

Step 2: Code Upload

Open Arduino IDE, copy the following code, and upload it to the ESP32-E:

#include <DFRobot_GP8XXX.h>

// Define the PWM pin as 13 (applicable to ESP32)
const int pwmPin = 13;
DFRobot_GP8630N_PWM GP8630N(pwmPin);

void setup() {
  // Initialize the sensor
  GP8630N.begin();
  
  // Set output data (PWM range for ESP32 is 0–1023)
  uint16_t data = 1023;  // Maximum output value
  GP8630N.setDACOutData(max(data*0.83, 170.5));
}

void loop() {

}

Result Verification:

  1. Set the multimeter to the "DC A" range;
  2. Connect the red probe to the module's "IOUT" terminal and the black probe to the module's "GND" terminal;
  3. Under normal conditions, the measured current should be close to 20mA. In this example, the actual measured output current is 20.24mA.

DFR1230-pwm result

API Functions

/**************************************************************************
                                  I2C & PWM Series
  **************************************************************************/
    /**
     * @fn begin
     * @brief Initialization function
     * @return Returns 0 for success; other values indicate failure
     */
    int begin(void);

    /**
     * @fn setDACOutRange
     * @brief Set the DAC output range (only valid in I2C mode)
     * @param range DAC output range
     * @n  eOutputRange5V (0–5V)
     * @n  eOutputRange6V (0–6V)       GP8630N, GP8600
     * @n  eOutputRange10V (0–10V)
     * @n  eOutputRange_10V (-10–0V)   GP8630N
     * @n  eOutputRange_12V (-12–0V)   GP8630N
     * @n  eOutputRange12V (0–12V)     GP8630N, GP8600
     * @n  eOutputRange20MA (0–20mA)
     * @n  eOutputRange24MA (0–24mA)   GP8630N, GP210
     * @return NONE
     */
    void setDACOutRange(eOutPutRange_t range);

    /**
     * @fn setDACOutData
     * @brief Set the DAC output value for a single-channel module
     * @param data DAC value
     * @note  In PWM mode, the current/voltage output is determined by the PWM duty cycle. Select the current/voltage output range via DIP switches according to the silkscreen on the back of the module.
     * @note  In I2C mode, the current/voltage output is determined by the output range set via setDACOutRange().
     * @return NONE
     */
    void setDACOutData(uint16_t data);

DAC Accuracy and Calibration Method Description

Overview of DAC Accuracy and Calibration

The accuracy of a DAC (Digital-to-Analog Converter) refers to the proximity between its actual output value and the ideal output value. Higher accuracy indicates a smaller deviation.

Purpose of Calibration:

Due to discrepancies in internal components or the impact of operating environments, DAC modules may exhibit "offset" and "gain" errors. The core of fitting calibration is to rectify the original output deviation through mathematical fitting algorithms, establishing a precise mapping relationship between "program control parameters" and "actual output values" to substantially enhance accuracy.

Practical DAC Calibration Tutorial (PWM Mode · 0–12V Range)

Taking the "0–12V range (program parameter range: 0–1023)" in PWM mode as an example, this tutorial adopts a linear fitting algorithm to quickly calculate calibration parameters using Excel. The steps are concise and easy to understand, requiring no complex programming.

Calibration Prerequisites

Hardware Preparation:

Software Preparation:

  • Excel spreadsheet (for calculating calibration parameters)
  • DAC control program

Environmental Requirements:

  • Stable ambient temperature (to avoid measurement errors caused by temperature drift)
  • No significant fluctuations in power supply voltage

Data Collection and Preparation

Collection Requirements

  • Select 5 or more intermediate program parameters (do not select the range endpoints 0 or 1023): Endpoint data is susceptible to the hardware's extreme characteristics, which may cause the fitting curve to deviate from the actual operating range. Intermediate values can ensure fitting accuracy;
  • Uniform distribution of program parameters: Cover the full 0–1023 range to ensure the fitting curve spans the entire measurement range.

Step 1: Record Raw Data

Configure the DAC according to the selected program parameters, measure the actual output voltage with a multimeter, and record the data in the following table (sample data):

Program Parameter (x) Theoretical Output Voltage (V) Actual Output Voltage (V) Absolute Error (V) Relative Error
0 0 0.0052 0.0052 0.0433%
85 1 1.002 0.0020 0.0167%
171 2 1.9961 -0.0039 -0.0325%
256 3 2.9926 -0.0074 -0.0617%
341 4 4.0012 0.0012 0.0100%
426 5 4.9951 -0.0049 -0.0408%
512 6 5.9924 -0.0076 -0.0633%
597 7 6.9846 -0.0154 -0.1283%
682 8 7.9912 -0.0088 -0.0733%
767 9 8.9891 -0.0109 -0.0908%
853 10 9.9868 -0.0132 -0.1100%
938 11 10.9826 -0.0174 -0.1450%
1023 12 12.0060 0.0060 0.0500%

Note: The values 0 and 1023 in the table are only used to demonstrate full-scale errors. For fitting calculations, exclude the endpoint data (0 and 1023) and use only the 11 intermediate data groups.

Calculation of Calibration Parameters (Excel Tool)

Use the linear fitting functions in Excel to calculate the conversion coefficient c and conversion offset o required for calibration. The core logic is to correct the linear deviation between the original "program parameters and actual output".

Step 2: Input Data into Excel

Enter the 11 intermediate data groups into Excel in the following format (sample cell range):

Cell Content (Program Parameter x) Cell Content (Actual Output Voltage y)
B11 85 D11 1.002
B12 171 D12 1.9961
B13 256 D13 2.9926
B14 341 D14 4.0012
B15 426 D15 4.9951
B16 512 D16 5.9924
B17 597 D17 6.9846
B18 682 D18 7.9912
B19 767 D19 8.9891
B20 853 D20 9.9868
B21 938 D21 10.9826

Step 3: Calculate Original Slope k

The slope k represents the linear relationship between "changes in program parameters" and "changes in actual output" under the original state. The Excel formula is as follows:

=SLOPE(D11:D21, B11:B21)
  • Meaning: D11:D21 is the range of actual output voltages, and B11:B21 is the range of corresponding program parameters. This formula calculates the linear slope between the two sets of data.

Step 4: Calculate Original Intercept b

The intercept b represents the actual output offset when the program parameter is 0. The Excel formula is as follows:

=INTERCEPT(D11:D21, B11:B21)
  • Meaning: Calculate the intercept b based on the linear equation y = k*x + b.

Step 5: Calculate Conversion Coefficient c

The coefficient c is used to correct the original slope deviation, ensuring the output conforms to the theoretical range. The Excel formula is as follows:

=(Theoretical Maximum Voltage / Maximum Program Parameter) / k
  • Example substitution: Theoretical Maximum Voltage = 12V, Maximum Program Parameter = 1023. Thus, the Excel formula is:
=(12/1023)/k
  • Meaning: Adjust the original slope k to the ideal slope that matches the theoretical measurement range.

Step 6: Calculate Conversion Offset o

The offset o is used to counteract the original intercept deviation. The Excel formula is:

=-b/k
  • Meaning: Eliminate the inherent output offset when the program parameter is 0 through offset compensation.

Step 7: Code Integration and Activation

Substitute the c (conversion coefficient) and o (conversion offset) calculated in Excel into the DAC control program, and real-time correct the program parameters using the calibration formula to ensure the actual output is close to the theoretical value.

Calibration Formula:

y = c * x0 + o
  • Explanation: y = Calibrated program parameter (the final control value written to the DAC); x0 = Original target program parameter (uncalibrated, calculated from the theoretical output voltage).
  • The complete calibration formula obtained by substituting the calculated conversion coefficient and offset is: y = 1.0018 * x0 - 0.0924

Code Example

Fill the calculated c (conversion coefficient) and o (conversion offset) values into the code below:

DFR1230-code

You can then obtain more accurate data using the fitting calibration algorithm. The complete code is as follows:

#include <DFRobot_GP8XXX.h>

// Fix the PWM pin to 13 for the ESP32 platform; no multi-platform adaptation required
const int pwmPin = 13;
DFRobot_GP8600_PWM GP8600(pwmPin);

/**
 * @brief Calibration function (ESP32-specific, matching 0–6V range)
 * @param data Uncalibrated original program parameter (0–1023)
 * @param coefficient Fitting calibration coefficient c (calculated in Excel)
 * @param offset Fitting calibration offset o (calculated in Excel)
 * @return Calibrated PWM control parameter (0–1023)
 */
uint16_t calibrationFun(uint16_t data ,double coefficient ,double offset)
{
  double tempdata = data * coefficient + offset;
  // The PWM parameter range for the ESP32 platform is fixed at 0–1023 (corresponding to 0–6V), directly clamp the value
  if(tempdata > 1023) tempdata = 1023;
  if(tempdata < 0) tempdata = 0;

  Serial.print("Calibrated PWM parameter: ");
  Serial.println((uint16_t)tempdata);
  return (uint16_t)tempdata;
}

void setup() {
  // Initialize the serial port (for debugging and viewing calibration parameters)
  Serial.begin(115200);
  // Initialize the GP8600 module (PWM mode)
  GP8600.begin();
  
  /**
   * @brief 0–6V range output configuration (ESP32-specific)
   * @note 1. The module's DIP switches must be configured for 0–6V output (refer to the instructions on the back of the module)
   * @note 2. The PWM parameter range for the ESP32 platform is 0–1023, corresponding to an output of 0–6V
   * @note 3. To enable calibration, pass the data below into calibrationFun
   */
  uint16_t data = 1023; // Uncalibrated original target program parameter (calculated from the theoretical output voltage)
  
  // Enable calibration (replace with the actually calculated coefficient and offset)
  GP8600.setDACOutData(calibrationFun(data, caliCoeff, caliOffset));
}

void loop() {

}

More Document Downloads