Class CurrentTransducer
Represents a general Current Transducer (CT) sensor
Assembly: CurrentTransducer.dll
View Source
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
protected IObservableAnalogInputPort AnalogPort { get; }
MaxVoltage
The maximum voltage the CT outputs
View Source
protected Voltage MaxVoltage { get; }
MaxCurrent
The sensed current at the maximum output voltage
View Source
protected Current MaxCurrent { get; }
MinVoltage
The minimum voltage the CT outputs
View Source
protected Voltage MinVoltage { get; }
MinCurrent
The sensed current at the minimum output voltage
View Source
protected Current MinCurrent { get; }
MinVoltageDelta
The minimum output voltage
View Source
protected Current MinVoltageDelta { get; }
Current
The last sensed Current
View Source
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
protected virtual void Initialize(IObservableAnalogInputPort analogPort, Voltage maxVoltage, Current maxCurrent, Voltage? minVoltage = null, Current? minCurrent = null)
Parameters
| Type | Name | Description |
|---|---|---|
Meadow.Hardware.IObservableAnalogInputPort | analogPort | The analog input port connected to the transducer |
Meadow.Units.Voltage | maxVoltage | The maximum voltage the CT outputs |
Meadow.Units.Current | maxCurrent | The sensed current at the maximum output voltage |
System.Nullable<Meadow.Units.Voltage> | minVoltage | The minimum voltage the CT outputs |
System.Nullable<Meadow.Units.Current> | minCurrent | The 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
protected virtual Current ConvertVoltageToCurrent(Voltage voltage)
Returns
Meadow.Units.Current: The current being sensed by the CT
Parameters
| Type | Name | Description |
|---|---|---|
Meadow.Units.Voltage | voltage | The ADC voltage read by the AnalogPort |
ReadCurrent()
Reads the instantaneous current of the sensor
View Source
public ValueTask<Current> ReadCurrent()
Returns
System.Threading.Tasks.ValueTask<Meadow.Units.Current>
ReadSensor()
Read value from sensor
View Source
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
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
| Type | Name | Description |
|---|---|---|
System.Nullable<System.TimeSpan> | updateInterval | A TimeSpan that specifies how long to |
| wait between readings |
StopUpdating()
Stops sampling the sensor
View Source
public override void StopUpdating()
Implements
System.IObservable<Meadow.IChangeResult<Meadow.Units.Current>>Meadow.Peripherals.Sensors.ISamplingCurrentSensorMeadow.Peripherals.Sensors.ISamplingSensor<Meadow.Units.Current>Meadow.Peripherals.Sensors.ISamplingSensorMeadow.Peripherals.Sensors.ICurrentSensorMeadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>Meadow.Peripherals.Sensors.ISensor