Giter Club home page Giter Club logo

adt7470's Introduction

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

ADT7470

Arduino library for I2C ADT7470 Fan Monitoring.

Description

The ADT7470 Fan Monitoring library offers an I2C device that can monitor and control up to four fans. Further this module can daisy chain up to 10 (specific TMP05/06) temperature sensors.

Please read datasheet carefully before working with the module.

Experimental
This library was build in 2015 from datasheet (PDF) on request and is never tested by me. So it is experimental at best and if you have the hardware and are able to try this library I would really appreciate it as it is a quite unique module.

That said the library is supporting setting the fan speed and measure the RPM, so it should be usable e.g. for a climate controlled room or cabinet.

Warning Do not forget to put a diode over the Fan to prevent damage due to inductive pulse when switched off. (see also datasheet).

ADT7470 Address Select Mode

(from datasheet)

Pin 11 (ADDR) State Address
HIGH (10 kΩ to VCC) 010 1111 0x5E left-justified or 0x2F right-justified
LOW (10 kΩ to GND) 010 1100 0x58 left-justified or 0x2C right-justified
Floating (no pull-up) 010 1110 0x5C left-justified or 0x2E right-justified

Interface

#include "ADT7470.h"

Check datasheet for the details as this section needs to be elaborated.

  • ADT7470(uint8_t address, TwoWire *wire = &Wire) constructor, with default I2C bus.
  • void begin() initialize the library
  • bool isConnected() check if the module is connected to the I2C bus
  • void startMonitoring()
  • void stopMonitoring()
  • void powerDown() energy save mode
  • void powerUp() active mode

Administrative

  • uint8_t getRevision() returns version of the firmware.
  • uint8_t getDeviceID() should return 0x70.
  • uint8_t getCompanyID() should return 0x41.

Temperature

  • int8_t getTemperature(uint8_t index) index = 0..9; if connected it returns the temperature of sensor index. Temperature sensors are daisy changed.
  • int8_t getMaxTemperature() get max temperature of connected temperature sensors.
  • bool setTemperatureLimit(uint8_t index, int8_t low, int8_t high) for ALARM function
  • int8_t getTemperatureLowLimit(uint8_t index) return the set value. Default ?
  • int8_t getTemperatureHighLimit(uint8_t index) return the set value. Default ?

PWM

  • bool setPWM(uint8_t index, uint8_t value) set the speed of the fan at index
  • uint8_t getPWM(uint8_t index) read back the speed set.
  • bool setFanLowFreq(value = 0) set PWM frequency.
  • bool setFanHighFreq(value = 0)
  • void setInvertPWM(uint8_t index)
  • uint8_t getInvertPWM(uint8_t index)

Tachio & RPM

  • bool setPulsesPerRevolution(uint8_t index, uint8_t value) value should be 1..4 as a fan gives 1..4 pulses per revolution. This value is needed to calculate a correct tach and RPM.
  • uint8_t getPulsesPerRevolution(uint8_t index) read back PulsePerRevolution. returns 1..4.
  • void setFastTach() Tach register is updated 4x per second.
  • void setSlowTach() Tach register is updated 1x per second.
  • uint16_t getTach(uint8_t index) get the raw pulses.
  • uint32_t getRPM(uint8_t index) get Revolutions Per Minute, based upon getTach()
  • bool setTachLimits(uint8_t index, uint16_t low, uint16_t high)
  • uint16_t getTachLowLimits(uint8_t index)
  • uint16_t getTachHighLimits(uint8_t index)

Interrupts

  • uint16_t getTemperatureIRQstatus()
  • void setTemperatureIRQMask(uint8_t index)
  • void clrTemperatureIRQMask(uint8_t index)
  • uint8_t getTemperatureIRQMask(uint8_t index)
  • uint8_t getFanIRQstatus()
  • void setFanIRQMask(uint8_t index)
  • void clrFanIRQMask(uint8_t index)
  • uint8_t getFanIRQMask(uint8_t index)

Operation

See examples

Future

This library will only be worked on on request as I have no hardware to test.

Must

Should

Could

  • improve documentation, readme.md file.
    • The descriptions are short and need to be extended.
  • implement async interface - getTemperature()
  • fix TODO's in code
  • get the hardware to test
  • change pins from PWM to digital IO
  • do we need default values for parameters e.g. index = 0 ?
  • investigate temperature sensors (functions are prepared)
  • investigate how to connect temp sensors (daisy chained)
    https://ez.analog.com/temperature_sensors/f/discussions/77540/adt7470-and-tmp05-daisy-chain-temeparure-sensing
  • investigate the FULLSPEED pin, must it be in the library?
    • software version ==> fullSpeed(uint8_t index)
  • investigate auto mode (datasheet?)
  • ...

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,

adt7470's People

Contributors

projectpatatoe avatar robtillaart avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

adt7470's Issues

tach measurement speed config bit

related:#4
(not neccessarily an issue with the library as much as an important point to note when using the chip)

ok there are a few things Ive found odd about tachometer readings. "Fan Speed Measurement Rate" does nothing as far as I can tell on the surface.

Here's a quick test where fan speed is full (255). In the loop,

  • setFastTach()
  • print register to show it's changed
  • getTach() to print raw Tach reading (pre-formula) every 250ms

results:

16:45:29.758 -> --------fast--------config40: 00100001
16:45:29.758 -> Tach2: 0000011001111100     1660
16:45:29.758 -> Tach2: 0000011001111100     1660
16:45:29.758 -> Tach2: 0000011001111101     1661
16:45:29.758 -> Tach2: 0000011001111100     1660
16:45:29.758 -> Tach2: 0000011001111100     1660
16:45:29.758 -> Tach2: 0000011001111100     1660
16:45:29.758 -> Tach2: 0000011001111110     1662
16:45:29.758 -> Tach2: 0000011010000001     1665
16:45:29.758 -> Tach2: 0000011010000001     1665
16:45:29.758 -> Tach2: 0000011001111111     1663
16:45:29.758 -> --------slow--------config40: 00000001
16:45:29.758 -> Tach2: 0000011001111111     1663
16:45:29.758 -> Tach2: 0000011001111111     1663
16:45:29.758 -> Tach2: 0000011010000000     1664
16:45:29.758 -> Tach2: 0000011010000000     1664
16:45:29.781 -> Tach2: 0000011010000000     1664
16:45:30.048 -> Tach2: 0000011010000001     1665
16:45:30.283 -> Tach2: 0000011010000000     1664
16:45:30.551 -> Tach2: 0000011010000000     1664
16:45:30.786 -> Tach2: 0000011010000001     1665
16:45:31.054 -> Tach2: 0000011010000001     1665
16:45:31.289 -> --------fast--------config40: 00100001
16:45:31.289 -> Tach2: 0000011001111111     1663
16:45:31.558 -> Tach2: 0000011001111101     1661
16:45:31.825 -> Tach2: 0000011001111101     1661
16:45:32.060 -> Tach2: 0000011001111110     1662
16:45:32.327 -> Tach2: 0000011001111111     1663
16:45:32.562 -> Tach2: 0000011010000000     1664
16:45:32.830 -> Tach2: 0000011001111110     1662
16:45:33.065 -> Tach2: 0000011001111101     1661
16:45:33.333 -> Tach2: 0000011001111101     1661
16:45:33.568 -> Tach2: 0000011001111101     1661
16:45:33.838 -> --------slow--------config40: 00000001
16:45:33.838 -> Tach2: 0000011001111101     1661
16:45:34.073 -> Tach2: 0000011001111101     1661
16:45:34.342 -> Tach2: 0000011001111100     1660
16:45:34.577 -> Tach2: 0000011001111011     1659
16:45:34.844 -> Tach2: 0000011001111011     1659
16:45:35.079 -> Tach2: 0000011001111011     1659
16:45:35.345 -> Tach2: 0000011001111010     1658
16:45:35.578 -> Tach2: 0000011001111001     1657
16:45:35.847 -> Tach2: 0000011001111001     1657
16:45:36.081 -> Tach2: 0000011001111011     1659

The config change doesn't seem to change anything. What I expect is that 3-4 readings remain the same during "slow" bit as stated on the bottom of pg23.

Same test again but with a changing fan speed to ensure that the tach is changing. The fan is speeding up during "fast" and slowing down during "slow"
Results:

17:05:40.188 -> --------fast--------config40: 00100001
17:05:40.188 -> Tach2: 0000110010001111     3215
17:05:40.424 -> Tach2: 0000100100101011     2347
17:05:40.693 -> Tach2: 0000011111001001     1993
17:05:40.929 -> Tach2: 0000011100110101     1845
17:05:41.198 -> Tach2: 0000011011101110     1774
17:05:41.434 -> Tach2: 0000011011010000     1744
17:05:41.704 -> Tach2: 0000011011000001     1729
17:05:41.940 -> Tach2: 0000011010111000     1720
17:05:42.209 -> Tach2: 0000011010110100     1716
17:05:42.445 -> Tach2: 0000011010110001     1713
17:05:42.716 -> --------slow--------config40: 00000001
17:05:42.716 -> Tach2: 0000011010110001     1713
17:05:42.951 -> Tach2: 0000011110101001     1961
17:05:43.221 -> Tach2: 0000100010100100     2212
17:05:43.457 -> Tach2: 0000100101111001     2425
17:05:43.727 -> Tach2: 0000101001000010     2626
17:05:43.963 -> Tach2: 0000101011110010     2802
17:05:44.198 -> Tach2: 0000101101101011     2923
17:05:44.469 -> Tach2: 0000101111001100     3020
17:05:44.705 -> Tach2: 0000110000011000     3096
17:05:44.974 -> Tach2: 0000110001001111     3151
17:05:45.210 -> --------fast--------config40: 00100001
17:05:45.210 -> Tach2: 0000110001110001     3185
17:05:45.480 -> Tach2: 0000100100100100     2340
17:05:45.716 -> Tach2: 0000011111000101     1989
17:05:45.986 -> Tach2: 0000011100110010     1842
17:05:46.222 -> Tach2: 0000011011101101     1773
17:05:46.492 -> Tach2: 0000011011001101     1741
17:05:46.727 -> Tach2: 0000011010111110     1726
17:05:46.996 -> Tach2: 0000011010110111     1719
17:05:47.231 -> Tach2: 0000011010110101     1717
17:05:47.499 -> Tach2: 0000011010101111     1711
17:05:47.733 -> --------slow--------config40: 00000001
17:05:47.733 -> Tach2: 0000011010101011     1707
17:05:48.001 -> Tach2: 0000011110010011     1939
17:05:48.236 -> Tach2: 0000100010000110     2182
17:05:48.505 -> Tach2: 0000100101110010     2418
17:05:48.740 -> Tach2: 0000101000110100     2612
17:05:49.009 -> Tach2: 0000101011000101     2757
17:05:49.243 -> Tach2: 0000101101010110     2902
17:05:49.512 -> Tach2: 0000101110110011     2995
17:05:49.747 -> Tach2: 0000101111111000     3064
17:05:50.014 -> Tach2: 0000110000100100     3108

The raw tach increases as it slows and decreases as it spins faster as expected (pg23). However, still not seeing the change of where the readings are the same during slow.

My theory:

I believe, doing a tach read resets the timer and immediately begins a new measurement. The usefulness would only be realized when set in automatic mode where the fans are controled by the tach readings with the limits set in the chip ahead of time. this would result in the fans reacting faster or slower to temperature changes.

I feel like theres not much a solution for the simple use of the library / manual control. I don't have the temperature sensors that go with this so I can't test the automatic portion of the chip.

Tested functions

Figured might be good to have a place to list tested functions? Here are the ones I've tested.

  • ADT7470()
  • begin()
  • isConnected()
  • getRevision()
  • getDeviceID()
  • getCompanyID()
  • startMonitoring()
  • stopMonitoring()
  • powerDown()
  • powerUp()
  • getTemperature(idx)
  • getMaxTemperature()
  • setTemperatureLimit(idx, low, high)
  • getTemperatureLowLimit(idx)
  • getTemperatureHighLimit(idx)
  • setPWM(idx, val)
  • getPWM(idx)
  • setFanLowFreq(val = 0)
  • setFanHighFreq(val = 0)
  • setInvertPWM(idx)
  • getInvertPWM(idx)
  • setPulsesPerRevolution(idx, val)
  • getPulsesPerRevolution(idx)
  • setFastTach() - see Issue #6
  • setSlowTach() - see Issue #6
  • getTach(idx)
  • getRPM(idx)
  • setTachLimits(idx, low, high)
  • getTachLowLimits(idx)
  • getTachHighLimits(idx)
  • getTemperatureIRQstatus()
  • setTemperatureIRQMask(idx)
  • clrTemperatureIRQMask(idx)
  • getTemperatureIRQMask(idx)
  • getFanIRQstatus()
  • setFanIRQMask(idx)
  • clrFanIRQMask(idx)
  • getFanIRQMask(idx)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.