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

Remarks

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.

Examples

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.

using System.Threading;
using Meadow;
using Meadow.Foundation.Sensors.HallEffect;

namespace LinearHallEffectTachometer_Sample
{
    public class Program
    {
        static IApp _app; 
        public static void Main()
        {
            _app = new App();
        }
    }

    public class App : AppBase<F7Micro, App>
    {
        public App ()
        {
            var _tach = new LinearHallEffectTachometer(Device.Pins.D10);
            _tach.RPMsChanged += RPMsChanged;
        }

        private void RPMsChanged(object sender, Sensors.SensorFloatEventArgs e)
        {
            Debug.Print("RPMs: " + e.CurrentValue);
        }
    }
}
Example Circuit

Constructors

View Source

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
View Source

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

View Source

_lastNotifiedRPMs

Declaration
protected float _lastNotifiedRPMs

Field Value

Type Description
System.Single
View Source

_numberOfReads

Declaration
protected ushort _numberOfReads

Field Value

Type Description
System.UInt16
View Source

_revolutionTimeStart

Declaration
protected DateTime _revolutionTimeStart

Field Value

Type Description
System.DateTime
View Source

_RPMs

Declaration
protected float _RPMs

Field Value

Type Description
System.Single

Properties

View Source

InputPort

Input port for the tachometer

Declaration
public IDigitalInputPort InputPort { get; }

Property Value

Type Description
IDigitalInputPort
View Source

NumberOfMagnets

Returns number of magnets of the sensor.

Declaration
public ushort NumberOfMagnets { get; }

Property Value

Type Description
System.UInt16
View Source

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
View Source

RPMs

Returns number of revolutions per minute.

Declaration
public int RPMs { get; }

Property Value

Type Description
System.Int32

Methods

View Source

OnRaiseRPMChanged()

Declaration
protected void OnRaiseRPMChanged()

Events

View Source

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>