Skip to content

Raspberry Pi library for the MCP4728 chip. It allows both reading/writing the address using three arbitrary GPIO pins and changing the output voltages using the i2c-0 and i2c-1 buses.

License

marko-pi/MCP4728

main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 

MCP4728

Raspberry Pi library for the MCP4728 Quad DAC chip. It allows

  • reading/writing the address by bitbanging at three arbitrary GPIO pins,
  • changing the output voltages by kernel procedures on both i2c-0 and i2c-1 busses.

The core of the project is an OOP (object oriented programming) compatible C library (MCP4728.so). There are two reasons for this step:

  • There is no need for any other library (RPi.GPIO, pigpio...) to execute the code;
  • The bitbanging part of the library is much faster and time consistent (see below).

Reading and writing address for the MCP4728 chip requires an additional LDAC line and is not I2C protocol compliant. Therefore bitbanging must be used. The target frequency for bitbanging is 100 kHz, but the de facto frequency is about 90 kHz. Executing C programs is simply not as efficient as using kernel procedures.

PulseView screenshot

The output voltages are changed uses kernel procedures.

On this page you will find the application circuits with some additional instructions.

The library provides eight public functions: two functions for initialisation/de-initialisation, two functions for reading/writing the address and four functions for changing the output voltages. The description of the functions is given in the Python test file (MCP4728_test.py).

A simple Python script is provided as an example of how to use the library. A proper Python library could easily be created to wrap up all procedures into a standard Python class. Since I assume that only advanced users will use this library, I think that the Python example script will be sufficient.

When the chip operates in internal source mode, it offers gain=1 for voltages up to 2.048 and gain=2 for voltages up to 4.096 or VDD, whichever is smaller. The library makes automatic choice there, gain=1 when a voltage up to 2 V is requested and gain=2 when a voltage above 2 V is requested.

About

Raspberry Pi library for the MCP4728 chip. It allows both reading/writing the address using three arbitrary GPIO pins and changing the output voltages using the i2c-0 and i2c-1 buses.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published