Skip to main content

Meadow.Foundation.ICs.FanControllers.Emc2101

Emc2101
StatusStatus badge: working
Source codeGitHub
Datasheet(s)GitHub
NuGet packageNuGet Gallery for Meadow.Foundation.ICs.FanControllers.Emc2101

Code Example

Emc2101 fanController;

public override Task Initialize()
{
Resolver.Log.Info("Initialize...");

fanController = new Emc2101(i2cBus: Device.CreateI2cBus());

return base.Initialize();
}

public override Task Run()
{
Resolver.Log.Info("Run ...");

return base.Run();
}

Sample project(s) available on GitHub

Class Emc2101

Represents an EMC2101 fan controller and temperature monitor

Assembly: Emc2101.dll
View Source
Declaration
public class Emc2101 : PollingSensorBase<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>, IObservable<IChangeResult<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>>, ISamplingSensor<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>, ISensor<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>, ISensor, ISamplingSensor, II2cPeripheral

Inheritance: System.Object -> Meadow.Foundation.ObservableBase<UNIT>

Implements:
System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>>, Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>, Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor, Meadow.Hardware.II2cPeripheral

Properties

ExternalTemperature

The temperature as read by the external sensor

View Source
Declaration
public Temperature? ExternalTemperature { get; }

InternalTemperature

The temperature as read by the internal sensor

View Source
Declaration
public Temperature? InternalTemperature { get; }

FanSpeed

The current fan speed

View Source
Declaration
public AngularVelocity? FanSpeed { get; }

DefaultI2cAddress

The default I2C address for the peripheral

View Source
Declaration
public byte DefaultI2cAddress { get; }

MinimumFanSpeed

Get/Set the minimum fan speed for the currently connected fan

View Source
Declaration
public AngularVelocity MinimumFanSpeed { get; set; }

PwmFrequencyScaler

Scales the PWM frequency against the current fan settings Recommended to leave at max value of 0x1F The is a 5 bit value

View Source
Declaration
public byte PwmFrequencyScaler { get; set; }

PwmDivisor

The alternate PWM divide value that can be used instead of CLK_SEL bit function This can set anytime but will only be used if the clock override bit is enabled

View Source
Declaration
public byte PwmDivisor { get; set; }

FanPwmDutyCycle

Get/Set the current manually set fan PWM duty cycle (0 - 1.0)

View Source
Declaration
public float FanPwmDutyCycle { get; set; }

Hysteresis

Get / set the amount of hysteresis applied to the temperature readings used in the fan speed lookup table

View Source
Declaration
public Temperature Hysteresis { get; set; }

SensorDataRate

The temperature sensor data rate

View Source
Declaration
public Emc2101.DataRate SensorDataRate { get; set; }

DACOutputEnabled

Enable or disable outputting the fan control signal as a DC voltage

View Source
Declaration
public bool DACOutputEnabled { get; set; }

Fields

i2cComms

I2C Communication bus used to communicate with the peripheral

View Source
Declaration
protected readonly II2cCommunications i2cComms

Methods

RaiseEventsAndNotify(IChangeResult<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>)

Raise changed events for subscribers

View Source
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)> changeResult)
Parameters
TypeNameDescription
Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>changeResultThe new sensor values

ReadSensor()

Reads data from the sensor

View Source
Declaration
protected override Task<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)> ReadSensor()
Returns

System.Threading.Tasks.Task<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>: The latest sensor reading### EnableTachInput(bool) Enable the TACH/ALERT pin as an input to read the fan speed (for 4 wire fans)

View Source
Declaration
public void EnableTachInput(bool enable)
Parameters
TypeNameDescription
System.Booleanenabletrue to enable, false to disable

InvertFanSpeed(bool)

Invert the sensor's reading of fan speed

View Source
Declaration
public void InvertFanSpeed(bool invert)
Parameters
TypeNameDescription
System.Booleaninverttrue to invert, false for normal

ConfigurePwmClock(bool, bool)

Configure the PWM clock

View Source
Declaration
public void ConfigurePwmClock(bool clockSelect, bool clockOverride)
Parameters
TypeNameDescription
System.BooleanclockSelecttrue to use a 1.4kHz base PWM clock, false to use the default 360kHz PWM clock
System.BooleanclockOverridetrue to override the base clock and use the frequency divisor to set the PWM frequency

ConfigureFanSpinup(FanSpinupDrive, FanSpinupTime)

Configure the fan spinup behavior

View Source
Declaration
public void ConfigureFanSpinup(Emc2101.FanSpinupDrive spinupDrive, Emc2101.FanSpinupTime spinupTime)
Parameters
TypeNameDescription
Meadow.Foundation.ICs.FanControllers.Emc2101.FanSpinupDrivespinupDriveThe drive or percent to spin up to
Meadow.Foundation.ICs.FanControllers.Emc2101.FanSpinupTimespinupTimeThe time taken to spin up to the drive speed

SetLookupTable(LutIndex, Temperature, float)

Set a temperature and fan duty cycle to the lookup table

View Source
Declaration
public void SetLookupTable(Emc2101.LutIndex index, Temperature temperatureThreshhold, float pwmDutyCycle)
Parameters
TypeNameDescription
Meadow.Foundation.ICs.FanControllers.Emc2101.LutIndexindexThe LUT index to set
Meadow.Units.TemperaturetemperatureThreshholdthe temperature threshold
System.SinglepwmDutyCyclethe fan PWM duty cycle

Events

InternalTemperatureUpdated

Internal Temperature changed event

View Source
Declaration
public event EventHandler<IChangeResult<Temperature>> InternalTemperatureUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Temperature>>

ExternalTemperatureUpdated

External Temperature changed event

View Source
Declaration
public event EventHandler<IChangeResult<Temperature>> ExternalTemperatureUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.Temperature>>

FanSpeedUpdated

Fan Speed changed event

View Source
Declaration
public event EventHandler<IChangeResult<AngularVelocity>> FanSpeedUpdated
Event Type

System.EventHandler<Meadow.IChangeResult<Meadow.Units.AngularVelocity>>

Implements

  • System.IObservable<Meadow.IChangeResult<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>
  • Meadow.Peripherals.Sensors.ISensor<System.ValueTuple<System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.Temperature>,System.Nullable<Meadow.Units.AngularVelocity>>>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • Meadow.Hardware.II2cPeripheral