Skip to main content

GP8XXX-IIC

The GP8XXX-IIC module provides an interface for controlling DAC (Digital to Analog Converter) devices over the I2C protocol. This module supports various DAC models with different resolutions and output voltage ranges.

Features

  • I2C Communication: Utilizes the smbus2 library for communicating with DAC devices over the I2C bus.
  • Output Ranges: Supports 0-5V/0-10V (with automatic range selection), 0-2.5V/0-VCC and 0-25mA/4-20mA.
  • Support Multiple DAC Models:
    • GP8302: 12-bit DAC I2C to 0-25mA/4-20mA
    • GP8211S: 15-bit DAC I2C to 0-5V/0-10V
    • GP8512: 15-bit DAC I2C to 0-2.5V/0-VCC
    • GP8503: 12-bit DAC Dual Channel I2C to 0-2.5V/0-VCC
    • GP8413: 15-bit DAC Dual Channel I2C to 0-5V/0-10V
    • GP8403: 12-bit DAC Dual Channel I2C to 0-5V/0-10V

Installation

You can install the GP8XXX module from PyPI using pip (Python 3.8 or newer):

pip install GP8XXX-IIC

To save the output in the chip with store(), install the optional lgpio dependency as well:

pip install "GP8XXX-IIC[store]"

On Raspberry Pi OS (Bookworm/Trixie) lgpio is also available as system package: sudo apt install python3-lgpio.

Example

import time
from GP8XXX_IIC import GP8403

dac = GP8403(i2c_addr=0x5F)

while dac.begin():
    print("init error")
    time.sleep(1)

# Optional, the range is selected automatically by default (auto_range=True)
# dac.set_dac_outrange(dac.OUTPUT_RANGE_10V)

# Channel 0: 6.821V
dac.set_dac_out_voltage(voltage=6.821, channel=0)

time.sleep(3)

# Channel 1: 2.774V
dac.set_dac_out_voltage(voltage=2.774, channel=1)

time.sleep(3)

# Channel 0 & 1: 0.253V
dac.set_dac_out_voltage(voltage=0.253, channel=2)

Voltages outside of the output range are clamped. With auto_range=False call set_dac_outrange() before setting a voltage.

GP8503 / GP8512 (0-2.5V/0-VCC)

The range is selected by the REFEN switch on the module, not by software. With the switch on 0-VCC pass the supply voltage as full scale:

from GP8XXX_IIC import GP8512

dac = GP8512(vref=5.0)  # default vref=2.5 for the 0-2.5V switch position
dac.set_dac_out_voltage(1.9)

GP8302 (0-25mA / 4-20mA)

The current is set in A. The full scale is 50V / Rset (0.025A with Rset = 2kOhm on the DFRobot module, pass full_scale=0.020 for Rset = 2.5kOhm). For an accurate 4-20mA signal measure the DAC codes for 4mA and 20mA and pass them to calibration4_20ma().

from GP8XXX_IIC import GP8302

dac = GP8302()
dac.calibration4_20ma(dac_4=655, dac_20=3277)
dac.set_dac_out_electric_current(0.012)  # 12mA

Store output values

The chip can save the current output so it's restored after a power cycle. The store sequence isn't valid I2C (3-bit frame, unacknowledged bytes), so it's bit-banged on the SDA/SCL pins with lgpio (see Installation, works on the Pi 5). The pin functions are read with pinctrl beforehand and restored afterwards, so the hardware I2C bus keeps working.

dac.set_dac_out_voltage(voltage=6.821, channel=0)
dac.store()  # bus 1: SDA=GPIO2, SCL=GPIO3 (BCM)
dac.store(sda_pin=22, scl_pin=23)  # other buses: pass the pins of the bus

Tested devices

DAC Module Tested
GP8503 ❌
GP8211S ❌
GP8512 ❌
GP8413 ✅
GP8403 ✅
GP8302 ❌

Metadata

Release files for GP8XXX-IIC 0.0.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GP8XXX-IIC 0.0.5
File Size Uploaded Provenance Actions
gp8xxx_iic-0.0.5.tar.gz 9.4 kB Without provenance Details for gp8xxx_iic-0.0.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for GP8XXX-IIC 0.0.5
File Interpreter ABI Platform Actions
gp8xxx_iic-0.0.5-py3-none-any.whl Python 3 none any Details for gp8xxx_iic-0.0.5-py3-none-any.whl

Total release size: 19.6 kB

Release files / gp8xxx_iic-0.0.5.tar.gz

Download URL gp8xxx_iic-0.0.5.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
6d03aceadb44d25126b50f94af047efdd2e675f1f2342830427b4f1e9aea0b3e
BLAKE2b-256 checksum
How to use checksums
640082fb3231d6bf4d7e232df6b9d3e9e5f875a824d9e346c1d78bda642be2d8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Release files / gp8xxx_iic-0.0.5-py3-none-any.whl

Download URL gp8xxx_iic-0.0.5-py3-none-any.whl
Size 10.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
98e4ebe4c277711dd586824e267be733fab5ab2aa41994ece60dd37102fac27b
BLAKE2b-256 checksum
How to use checksums
5ec642c6e78d2973a7c5081bd80670d7a25f9cc565fd146d194424dbd4f17306
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.15

Security for GP8XXX-IIC 0.0.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page