kulbhushanchand / MCP4251

Arduino library for MCP4251 Digital Potentiometer
https://kulbhushanchand.github.io/MCP4251/
GNU General Public License v3.0
13 stars 1 forks source link
arduino-library digital-pot digital-potentiometer mcp4251


Logo

MCP4251

Arduino library for MCP4251 Digital Potentiometer
Explore the docs »



Table of Contents

About

This library can be used for interfacing and controlling the MCP4251 IC with the Arduino. The MCP4251 IC is a volatile, 8-bit (257 wiper steps) digital potentiometers with an SPI compatible interface. It is available with end-to-end resistor values of 5KΩ, 10KΩ, 50kΩ and 100KΩ. More information on the product page.Other MCP42xx family ICs can also be used, but full functionality of the library may not be guaranteed.

Features

Installation

First method

library-manager

  1. In the Arduino IDE, navigate to Sketch > Include Library > Manage Libraries
  2. Then the Library Manager will open and you will find a list of libraries that are already installed or ready for installation.
  3. Then search for MCP4251 using the search bar.
  4. Click on the text area and then select the specific version and install it.

Second method

  1. Navigate to the Releases page.
  2. Download the latest release.
  3. Extract the zip file
  4. In the Arduino IDE, navigate to Sketch > Include Library > Add .ZIP Library

Functions

- DigitalPotWiperIncrement
- DigitalPotWiperDecrement
- DigitalPotSetWiperPosition
- DigitalPotSetWiperMin
- DigitalPotSetWiperMax
- DigitalPotSetWiperMid
- DigitalPotReadWiperPosition
- DigitalPotReadTconRegister
- DigitalPotReadStatusRegister
- DigitalPotWriteTconRegister
- DigitalPotStartup
- DigitalPotShutdown
- DigitalPotTerminalBConnect
- DigitalPotTerminalBDisconnect
- DigitalPotTerminalAConnect
- DigitalPotTerminalADisconnect
- DigitalPotWiperConnect
- DigitalPotWiperDisconnect
- DigitalPotInitTcon
- DigitalPotResistanceToPosition
- DigitalPotPositionToResistance

Usage

Two examples are available in library. Following is the simple example of interfacing a single MCP4251 with the Arduino. Only one potentiometer (pot0) is controlled and wiper is set to a position = 256.

connection-diagram

#include <MCP4251.h>

#define chipSelectPin 53
#define pot0ResistanceRmax 98600 // These resistance values may vary
#define pot0ResistanceRmin 113.5
#define pot1ResistanceRmax 98600
#define pot2ResistanceRmin 130

MCP4251 digitalPot(chipSelectPin, pot0ResistanceRmax, pot0ResistanceRmin, pot1ResistanceRmax, pot2ResistanceRmin);

bool potNum = 1;
uint16_t pos;

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

void loop()
{
    pos = 256;
    digitalPot.DigitalPotSetWiperPosition(potNum, pos);

    while(1)
    {
    }
}

Documentation

The documentation is available at https://kulbhushanchand.github.io/MCP4251/

Contributing

Any contributions you make are greatly appreciated. You can contribute to this project in the following ways :

Please note that this project is released with a Contributor Code of Conduct. By contributing to this project you agree to abide by its terms.

License

This project is distributed under the GPLv3 License. See LICENSE for more information.

Acknowledgment

The open-source tools used in development of this project.

Contact

Kulbhushan Chand