Coder Social home page Coder Social logo

zynthian / mcp4728 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marko-pi/mcp4728

1.0 2.0 1.0 85 KB

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: GNU General Public License v2.0

Python 33.21% C 65.74% Makefile 1.05%

mcp4728's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.