Remarks

LinearHallEffectTachometer
Status Not Tested
Source code GitHub
NuGet package

A Hall effect sensor is a device that is used to measure the magnitude of a magnetic field. Its output voltage is directly proportional to the magnetic field strength through it. These sensors are commonly used for proximity sensing, positioning, speed detection, and current sensing applications.

Frequently, a Hall sensor is combined with threshold detection so that it acts as and is called a switch. Commonly seen in industrial applications such as the pictured pneumatic cylinder, they are also used in consumer equipment; for example some computer printers use them to detect missing paper and open covers. They can also be used in computer keyboards, an application that requires ultra-high reliability.

Hall sensors are commonly used to time the speed of wheels and shafts, such as for internal combustion engine ignition timing, tachometers and anti-lock braking systems. They are used in brushless DC electric motors to detect the position of the permanent magnet. In the pictured wheel with two equally spaced magnets, the voltage from the sensor will peak twice for each revolution. This arrangement is commonly used to regulate the speed of disk drives.

The following example instantiates a LinearHallEffectTachometer object, and registers the RPMsChanged event handler, and it outputs the RPMs in the output console. To trigger the event of the sensor, you can place a magnet on a rotating object like a small motor, or even a fidget spinner, and make sure that the magnet passes very close to the sensor in every rotation so it picks up the electromagnetic field and it will start measuring RPMs.

Wiring Example

Characteristic Locus
Inheritance System.Object > LinearHallEffectTachometer
Inherited Members System.Object.ToString() System.Object.Equals(System.Object) System.Object.Equals(System.Object, System.Object) System.Object.ReferenceEquals(System.Object, System.Object) System.Object.GetHashCode() System.Object.GetType() System.Object.MemberwiseClone()
Namespace Meadow.Foundation.Sensors.HallEffect
Assembly Meadow.Foundation.dll

Syntax

public class LinearHallEffectTachometer

Constructors

LinearHallEffectTachometer(IDigitalInputPort, CircuitTerminationType, UInt16, Single)

Declaration
public LinearHallEffectTachometer(IDigitalInputPort inputPort, CircuitTerminationType type = CircuitTerminationType.CommonGround, ushort numberOfMagnets = 2, float rpmChangeNotificationThreshold = 1F)

Parameters

Type Name Description
IDigitalInputPort inputPort
CircuitTerminationType type
System.UInt16 numberOfMagnets
System.Single rpmChangeNotificationThreshold

LinearHallEffectTachometer(IIODevice, IPin, CircuitTerminationType, UInt16, Single)

LinearHallEffectTachometer driver

Declaration
public LinearHallEffectTachometer(IIODevice device, IPin inputPin, CircuitTerminationType type = CircuitTerminationType.CommonGround, ushort numberOfMagnets = 2, float rpmChangeNotificationThreshold = 1F)

Parameters

Type Name Description
IIODevice device
IPin inputPin
CircuitTerminationType type
System.UInt16 numberOfMagnets
System.Single rpmChangeNotificationThreshold

Fields

_lastNotifiedRPMs

Declaration
protected float _lastNotifiedRPMs

Field Value

Type Description
System.Single

_numberOfReads

Declaration
protected ushort _numberOfReads

Field Value

Type Description
System.UInt16

_revolutionTimeStart

Declaration
protected DateTime _revolutionTimeStart

Field Value

Type Description
System.DateTime

_RPMs

Declaration
protected float _RPMs

Field Value

Type Description
System.Single

Properties

InputPort

Input port for the tachometer

Declaration
public IDigitalInputPort InputPort { get; }

Property Value

Type Description
IDigitalInputPort

NumberOfMagnets

Returns number of magnets of the sensor.

Declaration
public ushort NumberOfMagnets { get; }

Property Value

Type Description
System.UInt16

RPMChangeNotificationThreshold

Any changes to the RPMs that are greater than the RPM change threshold will cause an event to be raised when the instance is set to update automatically.

Declaration
public float RPMChangeNotificationThreshold { get; set; }

Property Value

Type Description
System.Single

RPMs

Returns number of revolutions per minute.

Declaration
public int RPMs { get; }

Property Value

Type Description
System.Int32

Methods

OnRaiseRPMChanged()

Declaration
protected void OnRaiseRPMChanged()

Events

RPMsChanged

Event raised when the RPM change is greater than the RPMChangeNotificationThreshold value.

Declaration
public event EventHandler<FloatChangeResult> RPMsChanged

Event Type

Type Description
System.EventHandler<FloatChangeResult>