GY-63_MS5611/libraries/LTC2991/README.md

150 lines
5.4 KiB
Markdown
Raw Normal View History

2021-05-16 07:21:38 -04:00
[![Arduino CI](https://github.com/RobTillaart/LTC2991/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
2021-12-20 14:24:00 -05:00
[![Arduino-lint](https://github.com/RobTillaart/LTC2991/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/LTC2991/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/LTC2991/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/LTC2991/actions/workflows/jsoncheck.yml)
2021-05-16 07:21:38 -04:00
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/LTC2991/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/LTC2991.svg?maxAge=3600)](https://github.com/RobTillaart/LTC2991/releases)
# LTC2991
2021-12-20 14:24:00 -05:00
Arduino library for an LTC2991 temperature and voltage control IC.
2021-05-16 07:21:38 -04:00
## Description
2021-05-17 09:43:01 -04:00
Experimental - not tested myself, (no hardware)
2021-05-16 07:21:38 -04:00
2021-12-20 14:24:00 -05:00
LTC2991 is an experimental library for the LTC2991 IC which is typically used
to monitor temperature and voltage. It also has a PWM out to control e.g. a fan.
2021-05-16 07:21:38 -04:00
2021-12-20 14:24:00 -05:00
The IC supports normal voltage measurement (8 lines), differential voltage
measurements (4 pairs) and temperature measurements (4 pairs).
These can be combined in a mix.
As the IC has only 8 inputs available one has to choose what.
2021-05-16 07:21:38 -04:00
Read the datasheet for the details.
## Interface
### Constructor and setup
2021-12-20 14:24:00 -05:00
- **LTC2991(const uint8_t address, TwoWire \*wire = Wire)**
- **bool begin(const uint8_t sda, const uint8_t scl)** for ESP32 and ESP8266; initializes the class.
2021-05-16 07:21:38 -04:00
sets I2C pins.
2021-05-17 09:43:01 -04:00
returns true if the LTC2991 address is on the I2C bus.
2021-05-16 07:21:38 -04:00
- **bool begin()** UNO ea. initializes the class.
2021-05-17 09:43:01 -04:00
returns true if the LTC2991 address is on the I2C bus.
- **bool isConnected()** returns true if the LTC2991 address is on the I2C bus.
2021-05-16 07:21:38 -04:00
### Status functions
- **bool new_data(uint8_t channel)** true if there is a new **external** measurement (temperature or voltage) available.
2021-12-20 14:24:00 -05:00
- **bool new_temperature()** true if there is a new **internal** temperature measurement available.
- **bool new_voltage()** true, if there is a new **internal** voltage measurement available.
- **bool is_busy()** true if converting...
2021-05-16 07:21:38 -04:00
### External measurements
The following functions work on pairs
| n | selected |
|:----:|:---------:|
| 1 | V1 V2 T1 |
| 2 | V3 V4 T2 |
| 3 | V5 V6 T3 |
| 4 | V7 V8 T4 |
2021-05-17 09:43:01 -04:00
- **void trigger_conversion(uint8_t n)** wrapper around enable(n, true), better naming.
- **void trigger_conversion_all()** triggers conversions for all 4 channels/pairs.
2021-12-20 14:24:00 -05:00
- **void enable(uint8_t n, bool enable)** enable or disable an external line.
disable can be used to stop the repeat mode.
2021-05-16 07:21:38 -04:00
- **bool is_enabled(uint8_t n)** idem
2021-05-17 09:43:01 -04:00
- **void enable_filter(uint8_t n, bool enable)** enable filter - not investigated.
2021-12-20 14:24:00 -05:00
- **bool is_enabled_filter(uint8_t n)** idem.
2021-05-16 07:21:38 -04:00
- **void set_Kelvin(uint8_t n)** sets temperature mode to Kelvin,
2021-12-20 14:24:00 -05:00
implicit set_mode_temperature().
2021-05-16 07:21:38 -04:00
- **void set_Celsius(uint8_t n)** sets temperature mode to Celsius,
2021-12-20 14:24:00 -05:00
implicit set_mode_temperature.
2021-05-17 09:43:01 -04:00
- **void set_temp_scale(uint8_t n, bool Kelvin = true)** used to switch between Kelvin and Celsius.
2021-12-20 14:24:00 -05:00
- **char get_temp_scale(uint8_t n)** returns 'K' or 'C'.
- **void set_mode_temperature(uint8_t n)** sets operational mode.
- **void set_mode_voltage_differential(uint8_t n)** sets operational mode.
- **void set_mode_voltage_normal(uint8_t n)** sets operational mode.
- **uint8_t get_operational_mode(uint8_t n)** returns operational mode.
- **uint8_t get_differential_mode(uint8_t n)** returns differential flag.
2021-05-16 07:21:38 -04:00
- **float get_value(uint8_t channel)** channel = 1..8;
depending on the operational mode it returns the temperature or the
(differential) voltage.
### Internal measurements
2021-12-20 14:24:00 -05:00
- **void enable_Tintern_Vcc(bool enable)** enable internal temperature measurements.
- **bool is_enabled_Tintern_Vcc()** idem.
2021-05-16 07:21:38 -04:00
- **void enable_filter_Tintern(bool enable)** enable filter - not investigated
- **bool is_enabled_filter_Tintern()**
2021-12-20 14:24:00 -05:00
- **void set_Kelvin_Tintern()** use Kelvin.
- **void set_Celsius_Tintern()** use Celsius.
- **void set_temp_scale_Tintern(bool Kelvin = true)** Obsolete?.
- **char get_temp_scale_Tintern()** returns 'K' or 'C'.
- **float get_Tintern()** returns internal temperature.
2021-05-16 07:21:38 -04:00
- **float get_VCC()** returns the internal voltage.
### Configuration
2021-12-20 14:24:00 -05:00
- **void set_acquisition_repeat()** set continuous measurement mode.
- **void set_acquisition_single()** set single shot mode.
Note that before a measurement one needs to call trigger_conversion();
2021-05-16 07:21:38 -04:00
- **uint8_t get_acquisition_mode()** return mode set (0,1)
### PWM functions
2021-05-17 09:43:01 -04:00
- **void set_PWM(uint16_t value = 0)** value is 0..511
- **void set_PWM(uint16_t value = 0)** value is 0..511, less resolution (256 steps)
- **uint16_t get_PWM()** returns the value from the PWM register, when using PWM_fast this can differ 1.
2021-12-20 14:24:00 -05:00
- **void invert_PWM(bool invert)** idem.
- **bool is_inverted_PWM()** idem.
- **void enable_PWM(bool enable)** idem.
- **bool is_enabled_PWM()** idem.
2021-05-16 07:21:38 -04:00
### Performance
No data available yet.
To be measured when hardware is available...
## Operational
See examples..
2021-12-20 14:24:00 -05:00
### Future
2021-05-16 07:21:38 -04:00
2021-05-17 09:43:01 -04:00
#### must
2021-12-20 14:24:00 -05:00
2022-11-15 04:48:40 -05:00
#### should
- get hardware to test
2021-12-20 14:24:00 -05:00
- update documentation
- error handling
2021-05-17 09:43:01 -04:00
#### could
- cache registers (which) or
2021-05-16 07:21:38 -04:00
- cache a number of flags to speed up retrieving data
2021-12-20 14:24:00 -05:00
- optimize multi-byte read / write
2021-05-17 09:43:01 -04:00
- add Fahrenheit
- do low level in Kelvin and convert to KFC as needed.
- would simplify get_value
- need an enum
2021-05-16 07:21:38 -04:00
- look for code optimizations
2021-05-17 09:43:01 -04:00