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>>, ISamplingCurrentSensor, ISamplingSensor<Current>, ISamplingSensor, ICurrentSensor, ISensor<Current>, ISensor

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

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

Properties​

AnalogPort​

The analog input port connected to the transducer

View Source​
Declaration
protected IObservableAnalogInputPort 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(IObservableAnalogInputPort, 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(IObservableAnalogInputPort analogPort, Voltage maxVoltage, Current maxCurrent, Voltage? minVoltage = null, Current? minCurrent = null)
Parameters​
TypeNameDescription
Meadow.Hardware.IObservableAnalogInputPortanalogPortThe 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

ReadCurrent()​

Reads the instantaneous current of the sensor

View Source​
Declaration
public ValueTask<Current> ReadCurrent()
Returns​

System.Threading.Tasks.ValueTask<Meadow.Units.Current>

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.ISamplingCurrentSensor
  • Meadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISamplingSensor
  • Meadow.Peripherals.Sensors.ICurrentSensor
  • Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>
  • Meadow.Peripherals.Sensors.ISensor