Adafruit EMC2101 Library
Public Member Functions | List of all members
Adafruit_EMC2101 Class Reference

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...
 

Detailed Description

Class that stores state and functions for interacting with the EMC2101 Temperature monitor and fan controller.

Member Function Documentation

◆ begin()

bool Adafruit_EMC2101::begin ( uint8_t  i2c_address = EMC2101_I2CADDR_DEFAULT,
TwoWire *  wire = &Wire 
)

Sets up the hardware and initializes I2C.

Parameters
i2c_addressThe I2C address to be used.
wireThe Wire object to be used for I2C connections.
Returns
True if initialization was successful, otherwise false.

◆ LUTEnabled() [1/2]

bool Adafruit_EMC2101::LUTEnabled ( void  )

Get the LUT enable status.

Returns
true: LUT usage enabled false: LUT disabled

◆ LUTEnabled() [2/2]

bool Adafruit_EMC2101::LUTEnabled ( bool  enable_lut)

Enable or disable the temperature-to-fan speed Look Up Table (LUT)

Parameters
enable_lutTrue 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
Returns
true:success false: failure

◆ DACOutEnabled() [1/2]

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.

Parameters
enable_dac_outtrue will enable DAC output, false disables DAC output
Returns
true:success false: failure

◆ DACOutEnabled() [2/2]

bool Adafruit_EMC2101::DACOutEnabled ( void  )

Get the current DAC output enable setting.

Returns
true: DAC output enabled
false DAC output disabled

◆ getExternalTemperature()

float Adafruit_EMC2101::getExternalTemperature ( void  )

Read the external temperature diode.

Returns
float the current temperature in degrees C

◆ getInternalTemperature()

int8_t Adafruit_EMC2101::getInternalTemperature ( void  )

Read the internal temperature sensor.

Returns
int8_t the current temperature in degrees celcius

◆ getFanRPM()

uint16_t Adafruit_EMC2101::getFanRPM ( void  )

Read the current fan speed in RPM.

Returns
uint16_t The current fan speed, 0 if no tachometer input

◆ getDutyCycle()

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""".

Returns
float The current manually set fan duty cycle

◆ setDutyCycle()

bool Adafruit_EMC2101::setDutyCycle ( uint8_t  pwm_duty_cycle)

Set the fan speed.

Parameters
pwm_duty_cycleThe 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
Returns
true: success false: failure

◆ getFanMinRPM()

uint16_t Adafruit_EMC2101::getFanMinRPM ( void  )

Get the mimnum RPM setting for the attached fan.

Returns
uint16_t the current minimum RPM setting

◆ setFanMinRPM()

bool Adafruit_EMC2101::setFanMinRPM ( uint16_t  min_rpm)

Set the minimum speed of the attached fan.

Used to determine the fan state

Parameters
min_rpmThe minimum speed of the fan. Any setting below this will return 0 and mark the fan as non-operational
Returns
true: success false: failure

◆ getDataRate()

emc2101_rate_t Adafruit_EMC2101::getDataRate ( void  )

Gets the current rate at which pressure and temperature measurements are taken.

Returns
emc2101_rate_t The current data rate

◆ setDataRate()

bool Adafruit_EMC2101::setDataRate ( emc2101_rate_t  new_data_rate)

Sets the rate at which pressure and temperature measurements.

Parameters
new_data_rateThe data rate to set. Must be a emc2101_rate_t
Returns
bool true:success false:failure

◆ setLUT()

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)

Parameters
indexThe 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_threshWhen the temperature is more than this threshold, the fan will be set to the given PWM value
fan_pwmThe 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
Returns
true:success false:failure

◆ getPWMFrequency()

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

Returns
uint8_t The PWM freq register setting

◆ setPWMFrequency()

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

Parameters
pwm_freqThe new PWM frequency setting
Returns
bool true:success false:failure

◆ getPWMDivisor()

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.

Returns
uint8_t The alternate divisor setting

◆ setPWMDivisor()

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.

Parameters
pwm_divisorThe alternate divisor setting
Returns
true:success false: failure

◆ configPWMClock()

bool Adafruit_EMC2101::configPWMClock ( bool  clksel,
bool  clkovr 
)

Configure the PWM clock by selecting the clock source and overflow bit.

Parameters
clkselThe clock select true: Use a 1.4kHz base PWM clock false: Use the default 360kHz PWM clock
clkovrClock override When true, override the base clock selected by clksel and use the frequency divisor to set the PWM frequency
Returns
true:success false:failure

◆ setLUTHysteresis()

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.

Parameters
hysteresisThe 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
Returns
uint8_t The current LUT hysteresis value

◆ getLUTHysteresis()

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.

Returns
uint8_t The current LUT hysteresis value

◆ configFanSpinup() [1/2]

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)

Parameters
spinup_driveThe duty cycle to drive the fan with during spin up defaults to 100%
spinup_timeThe amount of time to keep the fan at the given drive setting. Defaults to 3.2 seconds
Returns
true:success false: failure

◆ configFanSpinup() [2/2]

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)

Parameters
tach_spinupIf 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
Returns
true:success false: failure

◆ enableForcedTemperature()

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

Parameters
enable_forcedTrue to force the LUT to use the forced temperature
Returns
true: success false: failure

◆ setForcedTemperature()

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.

Parameters
forced_temperatureThe alternative temperature reading used for LUT lookups.
Returns
true: success false: falure

◆ getForcedTemperature()

int8_t Adafruit_EMC2101::getForcedTemperature ( void  )

Get the alternate temperature to use to look up a fan setting in the look up table.

Returns
int8_t The alternative temperature reading used for LUT lookups

◆ enableTachInput()

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.

Parameters
tach_enabletrue: to enable tach signal input, false to disable and use the tach pin as interrupt & status output
Returns
true: sucess false: failure

◆ invertFanSpeed()

bool Adafruit_EMC2101::invertFanSpeed ( bool  invert_speed)

Set the cotroller to interperate fan speed settings opposite of the normal behavior.

Parameters
invert_speedIf 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.
Returns
true:sucess false:failure

The documentation for this class was generated from the following files: