Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Sample project(s) available on GitHub
Syntax
public class CurrentTransducer : SamplingSensorBase<Current>, IObservable<IChangeResult<Current>>, ISamplingSensor<Current>, ISensor<Current>
Constructors
CurrentTransducer()
Creates a new CurrentTransducer instance
Declaration
protected CurrentTransducer()
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
CurrentTransducer(IAnalogInputPort, Voltage, Current, Voltage?, Current?)
Creates a new CurrentTransducer instance
Declaration
public CurrentTransducer(IAnalogInputPort analogPort, Voltage maxVoltage, Current maxCurrent, Voltage? minVoltage = null, Current? minCurrent = null)
Parameters
Type | Name | Description |
---|---|---|
IAnalogInputPort | analogPort | The analog input port connected to the transducer |
Voltage | maxVoltage | The maximum voltage the CT outputs |
Current | maxCurrent | The sensed current at the maximum output voltage |
Voltage? | minVoltage | The minimum voltage the CT outputs |
Current? | minCurrent | The sensed current at the minimum output voltage |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Properties
AnalogPort
The analog input port connected to the transducer
Declaration
protected IAnalogInputPort AnalogPort { get; }
Property Value
Type | Description |
---|---|
IAnalogInputPort |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Current
The last sensed Current
Declaration
public Current? Current { get; protected set; }
Property Value
Type | Description |
---|---|
Current? |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
MaxCurrent
The sensed current at the maximum output voltage
Declaration
protected Current MaxCurrent { get; }
Property Value
Type | Description |
---|---|
Current |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
MaxVoltage
The maximum voltage the CT outputs
Declaration
protected Voltage MaxVoltage { get; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
MinCurrent
The sensed current at the minimum output voltage
Declaration
protected Current MinCurrent { get; }
Property Value
Type | Description |
---|---|
Current |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
MinVoltage
The minimum voltage the CT outputs
Declaration
protected Voltage MinVoltage { get; }
Property Value
Type | Description |
---|---|
Voltage |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
MinVoltageDelta
The minimum output voltage
Declaration
protected Current MinVoltageDelta { get; }
Property Value
Type | Description |
---|---|
Current |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Methods
ConvertVoltageToCurrent(Voltage)
Converts an output voltage from the CT to a sensed current using linear interpolation
Declaration
protected virtual Current ConvertVoltageToCurrent(Voltage voltage)
Parameters
Type | Name | Description |
---|---|---|
Voltage | voltage | The ADC voltage read by the AnalogPort |
Returns
Type | Description |
---|---|
Current | The current being sensed by the CT |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Initialize(IAnalogInputPort, Voltage, Current, Voltage?, Current?)
Initializes the CurrentTransducer instance Use this method when a derived class must do pre-initialization work
Declaration
protected virtual void Initialize(IAnalogInputPort analogPort, Voltage maxVoltage, Current maxCurrent, Voltage? minVoltage = null, Current? minCurrent = null)
Parameters
Type | Name | Description |
---|---|---|
IAnalogInputPort | analogPort | The analog input port connected to the transducer |
Voltage | maxVoltage | The maximum voltage the CT outputs |
Current | maxCurrent | The sensed current at the maximum output voltage |
Voltage? | minVoltage | The minimum voltage the CT outputs |
Current? | minCurrent | The sensed current at the minimum output voltage |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
RaiseEventsAndNotify(IChangeResult<Current>)
Method to notify subscribers to CurrentUpdated event handler
Declaration
protected override void RaiseEventsAndNotify(IChangeResult<Current> changeResult)
Parameters
Type | Name | Description |
---|---|---|
IChangeResult<Current> | changeResult |
Overrides
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
ReadSensor()
Read value from sensor
Declaration
protected override Task<Current> ReadSensor()
Returns
Type | Description |
---|---|
Task<Current> | unitized value |
Overrides
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
StartUpdating(TimeSpan?)
Starts updating the sensor on the updateInterval frequency specified
Declaration
public override void StartUpdating(TimeSpan? updateInterval = null)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan? | updateInterval | A TimeSpan that specifies how long to wait between readings |
Overrides
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
StopUpdating()
Stops sampling the sensor
Declaration
public override void StopUpdating()
Overrides
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}
Events
CurrentUpdated
Raised when the value of the reading changes
Declaration
public event EventHandler<IChangeResult<Current>> CurrentUpdated
Event Type
Type | Description |
---|---|
EventHandler<IChangeResult<Current>> |
Remarks
CurrentTransducer | |
---|---|
Status | |
Source code | GitHub |
NuGet package |
Code Example
private CurrentTransducer transducer = default!;
public override Task Initialize()
{
Resolver.Log.Info("Initialize...");
var bus = Device.CreateI2cBus();
transducer = new CurrentTransducer(
Device.Pins.A00.CreateAnalogInputPort(1),
new Voltage(3.3, Voltage.UnitType.Volts), // a reading of 3.3V
new Current(10, Current.UnitType.Amps) // equals 10 amps of current
);
Resolver.Log.Info($"-- Current Transducer Sample App ---");
transducer.Updated += (s, v) =>
{
Resolver.Log.Info($"Current is now {v.New.Amps}A");
};
return Task.CompletedTask;
}
public override Task Run()
{
transducer.StartUpdating(TimeSpan.FromSeconds(2));
return Task.CompletedTask;
}