Class CurrentTransducer
Represents a general Current Transducer (CT) sensor
Assembly: CurrentTransducer.dll
View Source
public class CurrentTransducer : SamplingSensorBase<Current>, IObservable<IChangeResult<Current>>, ISamplingSensor<Current>, ISensor<Current>, ISensor, ISamplingSensor
Inheritance: System.Object
-> Meadow.Foundation.ObservableBase<UNIT> -> Meadow.Foundation.SamplingSensorBase<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
protected IAnalogInputPort 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(IAnalogInputPort, 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(IAnalogInputPort analogPort, Voltage maxVoltage, Current maxCurrent, Voltage? minVoltage = null, Current? minCurrent = null)
Parameters
Type | Name | Description |
---|---|---|
Meadow.Hardware.IAnalogInputPort | 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 |
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.ISamplingSensor<Meadow.Units.Current>
Meadow.Peripherals.Sensors.ISensor<Meadow.Units.Current>
Meadow.Peripherals.Sensors.ISensor
Meadow.Peripherals.Sensors.ISamplingSensor