Skip to main content

Class CurrentTransducer

Represents a general Current Transducer (CT) sensor

Assembly: CurrentTransducer.dll
View Source
Declaration
public class CurrentTransducer : SamplingSensorBase<Current>, IObservable<IChangeResult<Current>>, ISamplingSensor<Current>, ISensor<Current>, ISensor, ISamplingSensor

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

Implements:
System.IObservable<Meadow.IChangeResult<Meadow.Units.Current>>, Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>, Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>, Meadow.Peripherals.Sensors.ISensor, Meadow.Peripherals.Sensors.ISamplingSensor

Properties

AnalogPort

The analog input port connected to the transducer

View Source
Declaration
protected IAnalogInputPort AnalogPort { get; }

MaxVoltage

The maximum voltage the CT outputs

View Source
Declaration
protected Voltage MaxVoltage { get; }

MaxCurrent

The sensed current at the maximum output voltage

View Source
Declaration
protected Current MaxCurrent { get; }

MinVoltage

The minimum voltage the CT outputs

View Source
Declaration
protected Voltage MinVoltage { get; }

MinCurrent

The sensed current at the minimum output voltage

View Source
Declaration
protected Current MinCurrent { get; }

MinVoltageDelta

The minimum output voltage

View Source
Declaration
protected Current MinVoltageDelta { get; }

Current

The last sensed Current

View Source
Declaration
public Current? Current { get; protected set; }

Methods

Initialize(IAnalogInputPort, Voltage, Current, Voltage?, Current?)

Initializes the CurrentTransducer instance Use this method when a derived class must do pre-initialization work

View Source
Declaration
protected virtual void Initialize(IAnalogInputPort analogPort, Voltage maxVoltage, Current maxCurrent, Voltage? minVoltage = null, Current? minCurrent = null)
Parameters
TypeNameDescription
Meadow.Hardware.IAnalogInputPortanalogPortThe analog input port connected to the transducer
Meadow.Units.VoltagemaxVoltageThe maximum voltage the CT outputs
Meadow.Units.CurrentmaxCurrentThe sensed current at the maximum output voltage
System.Nullable<Meadow.Units.Voltage>minVoltageThe minimum voltage the CT outputs
System.Nullable<Meadow.Units.Current>minCurrentThe sensed current at the minimum output voltage

ConvertVoltageToCurrent(Voltage)

Converts an output voltage from the CT to a sensed current using linear interpolation

View Source
Declaration
protected virtual Current ConvertVoltageToCurrent(Voltage voltage)
Returns

Meadow.Units.Current: The current being sensed by the CT

Parameters
TypeNameDescription
Meadow.Units.VoltagevoltageThe ADC voltage read by the AnalogPort

ReadSensor()

Read value from sensor

View Source
Declaration
protected override Task<Current> ReadSensor()
Returns

System.Threading.Tasks.Task<Meadow.Units.Current>: unitized value### StartUpdating(TimeSpan?) Starts updating the sensor on the updateInterval frequency specified

View Source
Declaration
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
TypeNameDescription
System.Nullable<System.TimeSpan>updateIntervalA TimeSpan that specifies how long to
wait between readings

StopUpdating()

Stops sampling the sensor

View Source
Declaration
public override void StopUpdating()

Implements

  • System.IObservable<Meadow.IChangeResult<Meadow.Units.Current>>
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISensor
  • Meadow.Peripherals.Sensors.ISamplingSensor