Adafruit EMC2101 Library
|
Class that stores state and functions for interacting with the EMC2101 Temperature monitor and fan controller. More...
#include <Adafruit_EMC2101.h>
Public Member Functions | |
Adafruit_EMC2101 () | |
Construct a new Adafruit_EMC2101::Adafruit_EMC2101 object. | |
~Adafruit_EMC2101 () | |
Destroy the Adafruit_EMC2101::Adafruit_EMC2101 object. | |
bool | begin (uint8_t i2c_addr=EMC2101_I2CADDR_DEFAULT, TwoWire *wire=&Wire) |
Sets up the hardware and initializes I2C. More... | |
bool | LUTEnabled (void) |
Get the LUT enable status. More... | |
bool | LUTEnabled (bool enable_lut) |
Enable or disable the temperature-to-fan speed Look Up Table (LUT) More... | |
bool | DACOutEnabled (bool enable_dac_out) |
Enable or disable outputting the fan control signal as a DC voltage instead of the default PWM output. More... | |
bool | DACOutEnabled (void) |
Get the current DAC output enable setting. More... | |
float | getExternalTemperature (void) |
Read the external temperature diode. More... | |
int8_t | getInternalTemperature (void) |
Read the internal temperature sensor. More... | |
uint16_t | getFanRPM (void) |
Read the current fan speed in RPM. More... | |
uint8_t | getDutyCycle (void) |
Get the fan speed setting used while the LUT is being updated and is unavailable or not in use. The speed is given as the fan's PWM duty cycle represented as a float percentage. The value roughly approximates the percentage of the fan's maximum speed""". More... | |
bool | setDutyCycle (uint8_t pwm_duty_cycle) |
Set the fan speed. More... | |
uint16_t | getFanMinRPM (void) |
Get the mimnum RPM setting for the attached fan. More... | |
bool | setFanMinRPM (uint16_t min_rpm) |
Set the minimum speed of the attached fan. More... | |
emc2101_rate_t | getDataRate (void) |
Gets the current rate at which pressure and temperature measurements are taken. More... | |
bool | setDataRate (emc2101_rate_t data_rate) |
Sets the rate at which pressure and temperature measurements. More... | |
bool | setLUT (uint8_t index, uint8_t temp_thresh, uint8_t fan_pwm) |
Create a new mapping between temperature and fan speed in the Look Up Table. Requires the LUT to be enabled with LUTEnabled(true) More... | |
uint8_t | getPWMFrequency (void) |
Read the final PWM frequency and "effective resolution" of the PWM driver. No effect when DAC output is enabled. More... | |
bool | setPWMFrequency (uint8_t pwm_freq) |
Set the final PWM frequency and "effective resolution" of the PWM driver. No effect when DAC output is enabled. More... | |
uint8_t | getPWMDivisor (void) |
Get the alternate PWM frequency digide value to use instead of the clock selection bit when the clock select override is set. More... | |
bool | setPWMDivisor (uint8_t pwm_divisor) |
Get the alternate PWM frequency digide value to use instead of the clock selection bit when the clock select override is set. More... | |
bool | configPWMClock (bool clksel, bool clkovr) |
Configure the PWM clock by selecting the clock source and overflow bit. More... | |
bool | setLUTHysteresis (uint8_t hysteresis) |
Set the amount of hysteresis in degrees celcius of hysteresis applied to temperature readings used for the LUT. More... | |
uint8_t | getLUTHysteresis (void) |
Get the amount of hysteresis in Degrees celcius of hysteresis applied to temperature readings used for the LUT. As the temperature drops, the controller will switch to a lower LUT entry when the measured value is belowthe lower entry's threshold, minus the hysteresis value. More... | |
bool | configFanSpinup (uint8_t spinup_drive, uint8_t spinup_time) |
Configure the fan's spinup behavior when transitioning from off/minimal speed to a higher speed (except on power up) More... | |
bool | configFanSpinup (bool tach_spinup) |
Configure the fan's spinup behavior when transitioning from off/minimal speed to a higher speed (except on power up) More... | |
bool | enableForcedTemperature (bool enable_forced) |
Force the LUT to use the temperature set by setForcedTemperature . More... | |
bool | setForcedTemperature (int8_t forced_temperature) |
Set the alternate temperature to use to look up a fan setting in the look up table. More... | |
int8_t | getForcedTemperature (void) |
Get the alternate temperature to use to look up a fan setting in the look up table. More... | |
bool | enableTachInput (bool tach_enable) |
Enable using the TACH/ALERT pin as an input to read the fan speed signal from a 4-pin fan. More... | |
bool | invertFanSpeed (bool invert_speed) |
Set the cotroller to interperate fan speed settings opposite of the normal behavior. More... | |
Class that stores state and functions for interacting with the EMC2101 Temperature monitor and fan controller.
bool Adafruit_EMC2101::begin | ( | uint8_t | i2c_address = EMC2101_I2CADDR_DEFAULT , |
TwoWire * | wire = &Wire |
||
) |
Sets up the hardware and initializes I2C.
i2c_address | The I2C address to be used. |
wire | The Wire object to be used for I2C connections. |
bool Adafruit_EMC2101::LUTEnabled | ( | void | ) |
Get the LUT enable status.
bool Adafruit_EMC2101::LUTEnabled | ( | bool | enable_lut | ) |
Enable or disable the temperature-to-fan speed Look Up Table (LUT)
enable_lut | True to enable the LUT, setting the fan speed depending on the configured temp to speed mapping. False disables the LUT, defaulting to the speed setting from setDutyCycle |
bool Adafruit_EMC2101::DACOutEnabled | ( | bool | enable_dac_out | ) |
Enable or disable outputting the fan control signal as a DC voltage instead of the default PWM output.
enable_dac_out | true will enable DAC output, false disables DAC output |
bool Adafruit_EMC2101::DACOutEnabled | ( | void | ) |
Get the current DAC output enable setting.
float Adafruit_EMC2101::getExternalTemperature | ( | void | ) |
Read the external temperature diode.
int8_t Adafruit_EMC2101::getInternalTemperature | ( | void | ) |
Read the internal temperature sensor.
uint16_t Adafruit_EMC2101::getFanRPM | ( | void | ) |
Read the current fan speed in RPM.
uint8_t Adafruit_EMC2101::getDutyCycle | ( | void | ) |
Get the fan speed setting used while the LUT is being updated and is unavailable or not in use. The speed is given as the fan's PWM duty cycle represented as a float percentage. The value roughly approximates the percentage of the fan's maximum speed""".
bool Adafruit_EMC2101::setDutyCycle | ( | uint8_t | pwm_duty_cycle | ) |
Set the fan speed.
pwm_duty_cycle | The duty cycle percentage as an integer The speed is given as the fan's PWM duty cycle and roughly approximates the percentage of the fan's maximum speed |
uint16_t Adafruit_EMC2101::getFanMinRPM | ( | void | ) |
Get the mimnum RPM setting for the attached fan.
bool Adafruit_EMC2101::setFanMinRPM | ( | uint16_t | min_rpm | ) |
Set the minimum speed of the attached fan.
Used to determine the fan state
min_rpm | The minimum speed of the fan. Any setting below this will return 0 and mark the fan as non-operational |
emc2101_rate_t Adafruit_EMC2101::getDataRate | ( | void | ) |
Gets the current rate at which pressure and temperature measurements are taken.
bool Adafruit_EMC2101::setDataRate | ( | emc2101_rate_t | new_data_rate | ) |
Sets the rate at which pressure and temperature measurements.
new_data_rate | The data rate to set. Must be a emc2101_rate_t |
bool Adafruit_EMC2101::setLUT | ( | uint8_t | index, |
uint8_t | temp_thresh, | ||
uint8_t | fan_pwm | ||
) |
Create a new mapping between temperature and fan speed in the Look Up Table. Requires the LUT to be enabled with LUTEnabled(true)
index | The index in the LUT, from 0-7. Note that the temperature thresholds should increase with the LUT index, so the temperature value for a given LUT entry is higher than the temperature for the previous index: // NO!: setLUT(0, 30, 25); // 25% PWM @ 30 Degrees C setLUT(1, 20, 10); // WRONG! 10% PWM @ 20 Degrees C should be before 30 // degrees from index 0 setLUT(2, 40, 50); // 50% PWM @ 40 Degrees C // YES: setLUT(0, 20, 10); // 10% PWM @ 20 Degrees C setLUT(1, 30, 25); // 25% PWM @ 30 Degrees C setLUT(2, 40, 50); // 50% PWM @ 40 Degrees C |
temp_thresh | When the temperature is more than this threshold, the fan will be set to the given PWM value |
fan_pwm | The pwm-based fan speed for the given temperature threshold. When DAC output is enabled, this determins the percentage of the maximum output voltage to be used for the given temperature threshold |
uint8_t Adafruit_EMC2101::getPWMFrequency | ( | void | ) |
Read the final PWM frequency and "effective resolution" of the PWM driver. No effect when DAC output is enabled.
See the datasheet for additional information: http://ww1.microchip.com/downloads/en/DeviceDoc/2101.pdf
bool Adafruit_EMC2101::setPWMFrequency | ( | uint8_t | pwm_freq | ) |
Set the final PWM frequency and "effective resolution" of the PWM driver. No effect when DAC output is enabled.
See the datasheet for additional information: http://ww1.microchip.com/downloads/en/DeviceDoc/2101.pdf
pwm_freq | The new PWM frequency setting |
uint8_t Adafruit_EMC2101::getPWMDivisor | ( | void | ) |
Get the alternate PWM frequency digide value to use instead of the clock selection bit when the clock select override is set.
bool Adafruit_EMC2101::setPWMDivisor | ( | uint8_t | pwm_divisor | ) |
Get the alternate PWM frequency digide value to use instead of the clock selection bit when the clock select override is set.
pwm_divisor | The alternate divisor setting |
bool Adafruit_EMC2101::configPWMClock | ( | bool | clksel, |
bool | clkovr | ||
) |
Configure the PWM clock by selecting the clock source and overflow bit.
clksel | The clock select true: Use a 1.4kHz base PWM clock false: Use the default 360kHz PWM clock |
clkovr | Clock override When true, override the base clock selected by clksel and use the frequency divisor to set the PWM frequency |
bool Adafruit_EMC2101::setLUTHysteresis | ( | uint8_t | hysteresis | ) |
Set the amount of hysteresis in degrees celcius of hysteresis applied to temperature readings used for the LUT.
hysteresis | The hysteresis value in degrees celcius. As the temperature drops, the controller will switch to a lower LUT entry when the measured value is hystersis degrees below the lower entry's temperature threshold |
uint8_t Adafruit_EMC2101::getLUTHysteresis | ( | void | ) |
Get the amount of hysteresis in Degrees celcius of hysteresis applied to temperature readings used for the LUT. As the temperature drops, the controller will switch to a lower LUT entry when the measured value is belowthe lower entry's threshold, minus the hysteresis value.
bool Adafruit_EMC2101::configFanSpinup | ( | uint8_t | spinup_drive, |
uint8_t | spinup_time | ||
) |
Configure the fan's spinup behavior when transitioning from off/minimal speed to a higher speed (except on power up)
spinup_drive | The duty cycle to drive the fan with during spin up defaults to 100% |
spinup_time | The amount of time to keep the fan at the given drive setting. Defaults to 3.2 seconds |
bool Adafruit_EMC2101::configFanSpinup | ( | bool | tach_spinup | ) |
Configure the fan's spinup behavior when transitioning from off/minimal speed to a higher speed (except on power up)
tach_spinup | If true, drive the fan at 100% until the speed is above the speed set with setFanMinRPM . If previously set, spinup_drive and spinup_time are ignored |
bool Adafruit_EMC2101::enableForcedTemperature | ( | bool | enable_forced | ) |
Force the LUT to use the temperature set by setForcedTemperature
.
This can be used to use the LUT to set the fan speed based on a different source than the external temperature diode. This can also be used to verify LUT configuration
enable_forced | True to force the LUT to use the forced temperature |
bool Adafruit_EMC2101::setForcedTemperature | ( | int8_t | forced_temperature | ) |
Set the alternate temperature to use to look up a fan setting in the look up table.
forced_temperature | The alternative temperature reading used for LUT lookups. |
int8_t Adafruit_EMC2101::getForcedTemperature | ( | void | ) |
Get the alternate temperature to use to look up a fan setting in the look up table.
bool Adafruit_EMC2101::enableTachInput | ( | bool | tach_enable | ) |
Enable using the TACH/ALERT pin as an input to read the fan speed signal from a 4-pin fan.
tach_enable | true: to enable tach signal input, false to disable and use the tach pin as interrupt & status output |
bool Adafruit_EMC2101::invertFanSpeed | ( | bool | invert_speed | ) |
Set the cotroller to interperate fan speed settings opposite of the normal behavior.
invert_speed | If true, fan duty cycle / DAC value settings will work backwards; Setting the highest value (100) will set the fan to it's lowest PWM value, and setting the fan to the lowest value (0) will set the fan output to it's highest setting. |