GY-63_MS5611/libraries/X9C10X
2022-02-15 17:54:24 +01:00
..
.github/workflows 0.1.0 X9C10X 2022-02-14 20:53:03 +01:00
examples 0.1.1 X9C10X 2022-02-15 17:54:24 +01:00
test 0.1.0 X9C10X 2022-02-14 20:53:03 +01:00
.arduino-ci.yml 0.1.0 X9C10X 2022-02-14 20:53:03 +01:00
keywords.txt 0.1.0 X9C10X 2022-02-14 20:53:03 +01:00
library.json 0.1.1 X9C10X 2022-02-15 17:54:24 +01:00
library.properties 0.1.1 X9C10X 2022-02-15 17:54:24 +01:00
LICENSE 0.1.0 X9C10X 2022-02-14 20:53:03 +01:00
README.md 0.1.1 X9C10X 2022-02-15 17:54:24 +01:00
X9C10X.cpp 0.1.1 X9C10X 2022-02-15 17:54:24 +01:00
X9C10X.h 0.1.1 X9C10X 2022-02-15 17:54:24 +01:00

Arduino CI Arduino-lint JSON check License: MIT GitHub release

X9C10X

Arduino Library for X9C10X series digital potentiometer.

Description

This experimental library provides a X9C10X base class and four derived classes for specific digital potentiometer.

type resistance tested notes
X9C10X generic N base class
X9C102 1 KΩ N 10 * 10^2
X9C103 10 KΩ N 10 * 10^3
X9C104 100 KΩ N 10 * 10^4
X9C503 50 KΩ N 50 * 10^3

Note: Ω Ohm sign = ALT-234

The library keeps cache of the position.

Interface

X9C10X base class

Use #include "X9C10X.h"

  • X9C10X(uint32_t Ohm = 10000) Constructor, default initializes the resistance to 10000 Ω. To calibrate one can fill in any other value e.g. 9950 Ω.
  • void begin(uint8_t pulsePin, uint8_t directionPin, uint8_t selectPin, uint8_t position = 0) sets the pins used by the device, and resets the position (default to 0). The position parameter allows to start the device with a previous stored position. Use this position with care.

Note: begin() has a hard coded 500uS delay so the device can wake up.

Note: multiple devices can be controlled, just by giving them an unique selectPin. This behaviour is similar to the SPI select pin.

  • void setPosition(uint8_t position) sets the wiper to a position between 0 and 99.
  • uint8_t getPosition() returns the current position.
  • void incr() moves one position up (if possible).
  • void decr() moves one position down (if possible).
  • uint32_t getOhm() returns the position expressed in Ohm. The returned value does depend on the value passed in the constructor.
  • uint32_t getMaxOhm() returns the maximum value ( = parameter from constructor).

Store

Warning: use with care.

  • uint8_t store() stores the current position in the NVRAM of the device, and returns the current position so it can later be used as position parameter for begin().

If one uses an incorrect parameter position in begin() the internal state and the device will probably be out of sync. One way to sync is call begin() with the right parameters. The other way is to call setPosition(0) followed by setPosition(99) (or vice versa) to get a defined internal state.

Derived classes

There are 4 derived classes, each with a other (appropriate) default value for the resistance.

  • X9C102(uint32_t Ohm = 1000)
  • X9C103(uint32_t Ohm = 10000)
  • X9C104(uint32_t Ohm = 100000)
  • X9C503(uint32_t Ohm = 50000)

These classes have the same interface as the base class.

Performance

No hardware to test yet.

Operation

See examples.

Future

  • buy and test different versions of the hardware
  • test different platform
  • test performance
  • documentation
  • optimize setPosition()
  • do we need the hardcoded 500us delay in begin()?
  • do we need getType()
  • add error codes?