mirror of
https://github.com/RobTillaart/Arduino.git
synced 2024-09-19 16:46:11 -04:00
0.1.2 LTC2991
This commit is contained in:
parent
121f872926
commit
ef444f9cf5
@ -2,6 +2,10 @@ compile:
|
||||
# Choosing to run compilation tests on 2 different Arduino platforms
|
||||
platforms:
|
||||
- uno
|
||||
- leonardo
|
||||
- due
|
||||
- zero
|
||||
# - due
|
||||
# - zero
|
||||
# - leonardo
|
||||
- m4
|
||||
- esp32
|
||||
# - esp8266
|
||||
# - mega2560
|
||||
|
@ -4,10 +4,14 @@ name: Arduino CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
arduino_ci:
|
||||
runTest:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: Arduino-CI/action@master
|
||||
# Arduino-CI/action@v0.1.1
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
- run: |
|
||||
gem install arduino_ci
|
||||
arduino_ci.rb
|
||||
|
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2021-2021 Rob Tillaart
|
||||
Copyright (c) 2021-2022 Rob Tillaart
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
@ -1,15 +1,16 @@
|
||||
//
|
||||
// FILE: LTC2991.cpp
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// DATE: 2021-05-10
|
||||
// PURPOSE: Library for LTC2991 temperature and voltage control IC
|
||||
// URL: https://github.com/RobTillaart/LTC2991
|
||||
//
|
||||
// HISTORY:
|
||||
// 0.1.0 2021-05-10 initial version
|
||||
// 0.1.1 2021-05-16 add trigger_conversion(), set_PWM_fast()
|
||||
// performance optimizations, some default values, and cleanup.
|
||||
// 0.1.1 2021-05-16 add trigger_conversion(), set_PWM_fast()
|
||||
// performance optimizations, some default values, and clean up.
|
||||
// 0.1.2 update library.json, license, minor edits
|
||||
|
||||
|
||||
#include "LTC2991.h"
|
||||
@ -56,9 +57,9 @@
|
||||
// MAGIC NUMBERS
|
||||
//
|
||||
// PAGE 21
|
||||
const float SINGLE_ENDED_FACTOR = 2.5 / 8192; // 2^13
|
||||
const float SINGLE_ENDED_FACTOR = 2.5 / 8192; // 2^13
|
||||
const float DIFFERENTIAL_FACTOR = 2.5 / 131072; // 2^17
|
||||
const float VCC_FACTOR = 2.5 / 8192; // 2^13
|
||||
const float VCC_FACTOR = 2.5 / 8192; // 2^13
|
||||
const float TEMPERATURE_FACTOR = 1.0 / 16;
|
||||
const float DIODE_VOLTAGE_FACTOR = 2.5 / 65536; // 2^16
|
||||
|
||||
@ -158,7 +159,7 @@ bool LTC2991::is_enabled(uint8_t n)
|
||||
void LTC2991::enable_filter(uint8_t n, bool enable)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -173,7 +174,7 @@ void LTC2991::enable_filter(uint8_t n, bool enable)
|
||||
bool LTC2991::is_enabled_filter(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -186,7 +187,7 @@ bool LTC2991::is_enabled_filter(uint8_t n)
|
||||
|
||||
// can be more efficient in one register addressing.
|
||||
void LTC2991::set_Kelvin(uint8_t n)
|
||||
{
|
||||
{
|
||||
set_temp_scale(n, true);
|
||||
set_mode_temperature(n);
|
||||
};
|
||||
@ -203,7 +204,7 @@ void LTC2991::set_Celsius(uint8_t n)
|
||||
void LTC2991::set_temp_scale(uint8_t n, bool Kelvin)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -218,7 +219,7 @@ void LTC2991::set_temp_scale(uint8_t n, bool Kelvin)
|
||||
char LTC2991::get_temp_scale(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -236,7 +237,7 @@ char LTC2991::get_temp_scale(uint8_t n)
|
||||
void LTC2991::set_mode_temperature(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -250,7 +251,7 @@ void LTC2991::set_mode_temperature(uint8_t n)
|
||||
void LTC2991::set_mode_voltage_differential(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -266,7 +267,7 @@ void LTC2991::set_mode_voltage_differential(uint8_t n)
|
||||
void LTC2991::set_mode_voltage_normal(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -282,7 +283,7 @@ void LTC2991::set_mode_voltage_normal(uint8_t n)
|
||||
uint8_t LTC2991::get_operational_mode(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -297,7 +298,7 @@ uint8_t LTC2991::get_operational_mode(uint8_t n)
|
||||
uint8_t LTC2991::get_differential_mode(uint8_t n)
|
||||
{
|
||||
uint8_t reg = CONTROL_V1_V4;
|
||||
if (n > 2)
|
||||
if (n > 2)
|
||||
{
|
||||
reg++;
|
||||
n -= 2;
|
||||
@ -486,12 +487,12 @@ float LTC2991::get_Tintern()
|
||||
{
|
||||
int16_t v = _readRegister16(T_INTERNAL_MSB);
|
||||
|
||||
if (get_temp_scale_Tintern() == 'K')
|
||||
if (get_temp_scale_Tintern() == 'K')
|
||||
{
|
||||
return TEMPERATURE_FACTOR * (float)v;
|
||||
}
|
||||
// CELSIUS positive value
|
||||
if ((v & 0x1000) == 0)
|
||||
if ((v & 0x1000) == 0)
|
||||
{
|
||||
return TEMPERATURE_FACTOR * (float)v;
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
//
|
||||
// FILE: LTC2991.h
|
||||
// AUTHOR: Rob Tillaart
|
||||
// VERSION: 0.1.1
|
||||
// VERSION: 0.1.2
|
||||
// DATE: 2021-05-10
|
||||
// PURPOSE: Library for LTC2991 temperature and voltage control IC
|
||||
// URL: https://github.com/RobTillaart/LTC2991
|
||||
@ -11,7 +11,7 @@
|
||||
#include "Arduino.h"
|
||||
#include "Wire.h"
|
||||
|
||||
#define LTC2991_LIB_VERSION (F("0.1.1"))
|
||||
#define LTC2991_LIB_VERSION (F("0.1.2"))
|
||||
|
||||
|
||||
class LTC2991
|
||||
@ -114,4 +114,6 @@ private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,21 +1,27 @@
|
||||
|
||||
[![Arduino CI](https://github.com/RobTillaart/LTC2991/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
|
||||
[![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)
|
||||
[![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
|
||||
|
||||
Arduino library for an LTC2991 temperature and voltage control IC
|
||||
Arduino library for an LTC2991 temperature and voltage control IC.
|
||||
|
||||
|
||||
## Description
|
||||
|
||||
Experimental - not tested myself, (no hardware)
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
Read the datasheet for the details.
|
||||
|
||||
@ -25,8 +31,8 @@ Read the datasheet for the details.
|
||||
|
||||
### Constructor and setup
|
||||
|
||||
- **LTC2991(const int8_t address, TwoWire \*wire = Wire);**
|
||||
- **bool begin(const uint8_t sda, const uint8_t scl)** for ESP32 and ESP8266; initializes the class.
|
||||
- **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.
|
||||
sets I2C pins.
|
||||
returns true if the LTC2991 address is on the I2C bus.
|
||||
- **bool begin()** UNO ea. initializes the class.
|
||||
@ -37,9 +43,9 @@ returns true if the LTC2991 address is on the I2C bus.
|
||||
### Status functions
|
||||
|
||||
- **bool new_data(uint8_t channel)** true if there is a new **external** measurement (temperature or voltage) available.
|
||||
- **new_temperature()** true if there is a new **internal** temperature measurement available.
|
||||
- **new_voltage()** true, if ther is a new **internal** voltage measurement available.
|
||||
- **is_busy()** true if converting...
|
||||
- **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...
|
||||
|
||||
|
||||
### External measurements
|
||||
@ -55,21 +61,22 @@ The following functions work on pairs
|
||||
|
||||
- **void trigger_conversion(uint8_t n)** wrapper around enable(n, true), better naming.
|
||||
- **void trigger_conversion_all()** triggers conversions for all 4 channels/pairs.
|
||||
- **void enable(uint8_t n, bool enable)** enable or disable an external line. disable can be used to stop the repeat mode.
|
||||
- **void enable(uint8_t n, bool enable)** enable or disable an external line.
|
||||
disable can be used to stop the repeat mode.
|
||||
- **bool is_enabled(uint8_t n)** idem
|
||||
- **void enable_filter(uint8_t n, bool enable)** enable filter - not investigated.
|
||||
- **bool is_enabled_filter(uint8_t n)** idem
|
||||
- **bool is_enabled_filter(uint8_t n)** idem.
|
||||
- **void set_Kelvin(uint8_t n)** sets temperature mode to Kelvin,
|
||||
implicit set_mode_temperature(),
|
||||
implicit set_mode_temperature().
|
||||
- **void set_Celsius(uint8_t n)** sets temperature mode to Celsius,
|
||||
implicit set_mode_temperature
|
||||
implicit set_mode_temperature.
|
||||
- **void set_temp_scale(uint8_t n, bool Kelvin = true)** used to switch between Kelvin and Celsius.
|
||||
- **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
|
||||
- **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.
|
||||
- **float get_value(uint8_t channel)** channel = 1..8;
|
||||
depending on the operational mode it returns the temperature or the
|
||||
(differential) voltage.
|
||||
@ -77,21 +84,23 @@ depending on the operational mode it returns the temperature or the
|
||||
|
||||
### Internal measurements
|
||||
|
||||
- **void enable_Tintern_Vcc(bool enable)** enable internal temperature measurements
|
||||
- **bool is_enabled_Tintern_Vcc()** idem
|
||||
- **void enable_Tintern_Vcc(bool enable)** enable internal temperature measurements.
|
||||
- **bool is_enabled_Tintern_Vcc()** idem.
|
||||
- **void enable_filter_Tintern(bool enable)** enable filter - not investigated
|
||||
- **bool is_enabled_filter_Tintern()**
|
||||
- **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
|
||||
- **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.
|
||||
- **float get_VCC()** returns the internal voltage.
|
||||
|
||||
|
||||
### Configuration
|
||||
- **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();
|
||||
|
||||
- **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();
|
||||
- **uint8_t get_acquisition_mode()** return mode set (0,1)
|
||||
|
||||
|
||||
@ -100,10 +109,10 @@ depending on the operational mode it returns the temperature or the
|
||||
- **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.
|
||||
- **void invert_PWM(bool invert)** idem
|
||||
- **bool is_inverted_PWM()** idem
|
||||
- **void enable_PWM(bool enable)** idem
|
||||
- **bool is_enabled_PWM()** idem
|
||||
- **void invert_PWM(bool invert)** idem.
|
||||
- **bool is_inverted_PWM()** idem.
|
||||
- **void enable_PWM(bool enable)** idem.
|
||||
- **bool is_enabled_PWM()** idem.
|
||||
|
||||
|
||||
### Performance
|
||||
@ -117,17 +126,19 @@ To be measured when hardware is available...
|
||||
See examples..
|
||||
|
||||
|
||||
### TODO
|
||||
### Future
|
||||
|
||||
#### must
|
||||
|
||||
- get hardware to
|
||||
- test test test
|
||||
|
||||
- update documentation
|
||||
|
||||
#### could
|
||||
|
||||
- cache registers (which) or
|
||||
- cache a number of flags to speed up retrieving data
|
||||
- optimize multibyte read / write
|
||||
- optimize multi-byte read / write
|
||||
- add Fahrenheit
|
||||
- do low level in Kelvin and convert to KFC as needed.
|
||||
- would simplify get_value
|
||||
|
@ -34,3 +34,4 @@ void loop()
|
||||
|
||||
|
||||
// -- END OF FILE --
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Syntax Coloring Map For LTC2991
|
||||
# Syntax Colouring Map For LTC2991
|
||||
|
||||
# Datatypes (KEYWORD1)
|
||||
# Data types (KEYWORD1)
|
||||
LTC2991 KEYWORD1
|
||||
|
||||
# Methods and Functions (KEYWORD2)
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "LTC2991",
|
||||
"keywords": "voltage temperature differential PWM",
|
||||
"keywords": "voltage,temperature,differential,PWM",
|
||||
"description": "Arduino library for a LTC2991",
|
||||
"authors":
|
||||
[
|
||||
@ -15,8 +15,9 @@
|
||||
"type": "git",
|
||||
"url": "https://github.com/RobTillaart/LTC2991.git"
|
||||
},
|
||||
"version": "0.1.1",
|
||||
"version": "0.1.2",
|
||||
"license": "MIT",
|
||||
"frameworks": "arduino",
|
||||
"platforms": "*"
|
||||
"platforms": "*",
|
||||
"headers": "LTC2991.h"
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
name=LTC2991
|
||||
version=0.1.1
|
||||
version=0.1.2
|
||||
author=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
|
||||
sentence=Arduino library for LTC2991
|
||||
|
@ -38,8 +38,10 @@
|
||||
|
||||
unittest_setup()
|
||||
{
|
||||
fprintf(stderr, "LTC2991_LIB_VERSION: %s\n", (char *) LTC2991_LIB_VERSION);
|
||||
}
|
||||
|
||||
|
||||
unittest_teardown()
|
||||
{
|
||||
}
|
||||
@ -47,8 +49,6 @@ unittest_teardown()
|
||||
|
||||
unittest(test_constructor)
|
||||
{
|
||||
fprintf(stderr, "VERSION: %s\n", LTC2991_LIB_VERSION);
|
||||
|
||||
LTC2991(0x20);
|
||||
|
||||
fprintf(stderr, "no tests yet");
|
||||
|
Loading…
Reference in New Issue
Block a user