Remarks

Emc2101
Status Status badge: working
Source code GitHub
Datasheet(s) GitHub
NuGet package NuGet 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

Characteristic Locus
Inheritance System.Object ObservableBase<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>> SamplingSensorBase<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>> PollingSensorBase<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>> > Emc2101
Implements ISamplingSensor<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>> ISamplingSensor<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>>
Inherited Members PollingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.StartUpdating(Nullable<TimeSpan>) PollingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.StopUpdating() SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.samplingLock SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.Updated SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.SamplingTokenSource SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.Conditions SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.IsSampling SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.UpdateInterval SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.ReadSensor() SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.RaiseEventsAndNotify(IChangeResult<>) SamplingSensorBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.Read() ObservableBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.observers ObservableBase<(Nullable<Temperature> InternalTemperature, Nullable<Temperature> ExternalTemperature, Nullable<AngularVelocity> FanSpeed)>.NotifyObservers(IChangeResult<>) Meadow.Foundation.ObservableBase<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>>.Subscribe(IObserver<>) Meadow.Foundation.ObservableBase<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>>.CreateObserver(Action<>, System.Nullable<Predicate<IChangeResult<UNIT>>>)
Namespace Meadow.Foundation.ICs.FanControllers
Assembly Emc2101.dll

Syntax

public class Emc2101 : PollingSensorBase<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>, ISamplingSensor<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>, ISamplingSensor<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)>

Constructors

Emc2101(II2cBus, Byte)

Create a new EMC2101 object

Declaration
public Emc2101(II2cBus i2cBus, byte address = null)

Parameters

Type Name Description
II2cBus i2cBus

I2CBus connected to display

System.Byte address

Address of the EMC2101 (default = 0x4C)

Properties

DACOutputEnabled

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

Declaration
public bool DACOutputEnabled { get; set; }

Property Value

Type Description
System.Boolean

ExternalTemperature

The temperature as read by the external sensor

Declaration
public Temperature? ExternalTemperature { get; }

Property Value

Type Description
System.Nullable<Temperature>

FanPwmDutyCycle

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

Declaration
public float FanPwmDutyCycle { get; set; }

Property Value

Type Description
System.Single

FanSpeed

The current fan speed

Declaration
public AngularVelocity? FanSpeed { get; }

Property Value

Type Description
System.Nullable<AngularVelocity>

Hysteresis

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

Declaration
public Temperature Hysteresis { get; set; }

Property Value

Type Description
Temperature

The hysteresis temperature value

InternalTemperature

The temperature as read by the internal sensor

Declaration
public Temperature? InternalTemperature { get; }

Property Value

Type Description
System.Nullable<Temperature>

MinimumFanSpeed

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

Declaration
public AngularVelocity MinimumFanSpeed { get; set; }

Property Value

Type Description
AngularVelocity

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

Declaration
public byte PwmDivisor { get; set; }

Property Value

Type Description
System.Byte

PwmFrequencyScaler

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

Declaration
public byte PwmFrequencyScaler { get; set; }

Property Value

Type Description
System.Byte

SensorDataRate

The temperature sensor data rate

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

Property Value

Type Description
Emc2101.DataRate

Methods

ConfigureFanSpinup(Emc2101.FanSpinupDrive, Emc2101.FanSpinupTime)

Configure the fan spinup behavior

Declaration
public void ConfigureFanSpinup(Emc2101.FanSpinupDrive spinupDrive, Emc2101.FanSpinupTime spinupTime)

Parameters

Type Name Description
Emc2101.FanSpinupDrive spinupDrive

The drive or percent to spin up to

Emc2101.FanSpinupTime spinupTime

The time taken to spin up to the drive speed

ConfigurePwmClock(Boolean, Boolean)

Configure the PWM clock

Declaration
public void ConfigurePwmClock(bool clockSelect, bool clockOverride)

Parameters

Type Name Description
System.Boolean clockSelect

true to use a 1.4kHz base PWM clock, false to use the default 360kHz PWM clock

System.Boolean clockOverride

true to override the base clock and use the frequency divisor to set the PWM frequency

EnableTachInput(Boolean)

Enable the TACH/ALERT pin as an input to read the fan speed (for 4 wire fans)

Declaration
public void EnableTachInput(bool enable)

Parameters

Type Name Description
System.Boolean enable

true to renable, false to disable

InvertFanSpeed(Boolean)

Invert the sensor's reading of fan speed

Declaration
public void InvertFanSpeed(bool invert)

Parameters

Type Name Description
System.Boolean invert

true to invert, false for normal

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

Raise changed events for subscribers

Declaration
protected override void RaiseEventsAndNotify(IChangeResult<(Temperature? InternalTemperature, Temperature? ExternalTemperature, AngularVelocity? FanSpeed)> changeResult)

Parameters

Type Name Description
IChangeResult<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>> changeResult

The new sensor values

ReadSensor()

Reads data from the sensor

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

Returns

Type Description
Task<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>>

The latest sensor reading

Overrides

Meadow.Foundation.SamplingSensorBase<System.ValueTuple<System.Nullable<Temperature>, System.Nullable<Temperature>, System.Nullable<AngularVelocity>>>.ReadSensor()

SetLookupTable(Emc2101.LutIndex, Temperature, Single)

Set a temperature and fan duty cycle to the lookup table

Declaration
public void SetLookupTable(Emc2101.LutIndex index, Temperature temperatureThreshhold, float pwmDutyCycle)

Parameters

Type Name Description
Emc2101.LutIndex index

The LUT index to set

Temperature temperatureThreshhold

the temperature threshhold

System.Single pwmDutyCycle

the fan PWM duty cycle

Events

ExternalTemperatureUpdated

External Temperature changed event

Declaration
public event EventHandler<IChangeResult<Temperature>> ExternalTemperatureUpdated

Event Type

Type Description
EventHandler<IChangeResult<Temperature>>

FanSpeedUpdated

Fan Speed changed event

Declaration
public event EventHandler<IChangeResult<AngularVelocity>> FanSpeedUpdated

Event Type

Type Description
EventHandler<IChangeResult<AngularVelocity>>

InternalTemperatureUpdated

Internal Temperature changed event

Declaration
public event EventHandler<IChangeResult<Temperature>> InternalTemperatureUpdated

Event Type

Type Description
EventHandler<IChangeResult<Temperature>>