Skip to content

Latest commit

 

History

History

DS1804

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

DS1804

Arduino library for DS1804 Nonvolatile Trimmer Potentiometer.

Description

Experimental

The library implements a class for the DS1804 potentiometer. These devices come in 10K, 50K and 100K and allows control in 100 steps.

The DS1804 has a simple pulse interface and cannot be read back so the library cannot provide the current position of the wiper.

The DS1804 has an EEPROM to save the current position (writeable for 50000 times) and uses that as start position at power up.

Power up / down

(from datasheet)
On power-up, wiper position will be loaded within a maximum time period of 500µs once the power-supply is stable. Additionally, the three-terminal interface port will be active after 50 ms.

On power-down, the wiper position register data will be lost. On the next device power-up, the value of EEPROM memory will be loaded into the wiper position register.

There is no defined factory default, expect the value to be random.

Related

Other digipots

Interface

#include "DS1804.h"

Constructor

  • DS1804(uint8_t csPin, uint8_t incPin, uint8_t udPin) constructor.
  • void begin(bool b = false) initializes pins, default the device is not selected.

Base

  • void select(bool b) enable / disable device.
  • void moveUp(uint8_t n = 1) if enabled move position n steps up (n is clipped to 0..100)
  • void moveDown(uint8_t n = 1) if enabled move position n steps down (n is clipped to 0..100)

Duration of moveUp/Down depends linearly on n, expect less than half a millisecond.

EEPROM power up value

  • void saveEEPROM() saves the current position to internal EEPROM. Note the library cannot read this EEPROM value.

To set a value for sure, you might go 100x down and P times up to get at the requested position.

See DS1804_save_EEPROM.ino

Future

Must

  • improve documentation
  • test with hardware

Should

  • array example (sharing UD, INC pins, unique CS)
  • stereo example, (sharing all pins).

Could

  • default true for select() / begin()?

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,