Class CoreCANcoder
Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along with filtered velocity.
public class CoreCANcoder : ParentDevice, CommonDevice
- Inheritance
-
CoreCANcoder
- Implements
- Derived
- Inherited Members
Constructors
CoreCANcoder(int)
Constructs a new CANcoder object.
Constructs the device using the default CAN bus for the system (see CANBus(string)).public CoreCANcoder(int deviceId)
Parameters
deviceIdintID of the device, as configured in Phoenix Tuner
CoreCANcoder(int, CANBus)
Constructs a new CANcoder object.
public CoreCANcoder(int deviceId, CANBus canbus)
Parameters
deviceIdintID of the device, as configured in Phoenix Tuner
canbusCANBusThe CAN bus this device is on
CoreCANcoder(int, string)
Constructs a new CANcoder object.
[Obsolete("Constructing devices with a CAN bus string is deprecated for removal in the 2027 season. Construct devices using a CANBus instance instead.")]
public CoreCANcoder(int deviceId, string canbus)
Parameters
deviceIdintID of the device, as configured in Phoenix Tuner
canbusstringName of the CAN bus. Possible CAN bus strings are:
- CANivore name or serial number
- SocketCAN interface (non-FRC Linux only)
- "" for any CANivore seen by the program
- empty string (default) to select the default for the system:
- "can0" on Linux
- "" on Windows
Properties
Configurator
The configurator for this device. Users may use this to refresh and apply configs, such as the CANcoderConfiguration object
public CANcoderConfigurator Configurator { get; }
Property Value
SimState
Gets the simulation state for this device.
This function reuses an allocated simulation state object, so it is safe to call this function multiple times in a robot loop.public CANcoderSimState SimState { get; }
Property Value
Methods
ClearStickyFault_BadMagnet(double)
Clear sticky fault: The magnet distance is not correct or magnet is missing
public StatusCode ClearStickyFault_BadMagnet(double timeoutSeconds = 0.1)
Parameters
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command
ClearStickyFault_BootDuringEnable(double)
Clear sticky fault: Device boot while detecting the enable signal
public StatusCode ClearStickyFault_BootDuringEnable(double timeoutSeconds = 0.1)
Parameters
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command
ClearStickyFault_Hardware(double)
Clear sticky fault: Hardware fault occurred
public StatusCode ClearStickyFault_Hardware(double timeoutSeconds = 0.1)
Parameters
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command
ClearStickyFault_Undervoltage(double)
Clear sticky fault: Device supply voltage dropped to near brownout levels
public StatusCode ClearStickyFault_Undervoltage(double timeoutSeconds = 0.1)
Parameters
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command
ClearStickyFault_UnlicensedFeatureInUse(double)
Clear sticky fault: An unlicensed feature is in use, device may not behave as expected.
public StatusCode ClearStickyFault_UnlicensedFeatureInUse(double timeoutSeconds = 0.1)
Parameters
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command
ClearStickyFaults(double)
Clear the sticky faults in the device.
This typically has no impact on the device functionality. Instead, it just clears telemetry faults that are accessible via API and Tuner Self-Test.public StatusCode ClearStickyFaults(double timeoutSeconds = 0.1)
Parameters
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command
GetAbsolutePosition(bool)
Absolute Position of the device. The possible range is documented below; however, the exact expected range is determined by the AbsoluteSensorDiscontinuityPoint. This position is only affected by the MagnetSensor configs.
- Minimum Value-1.0
- Maximum Value0.999755859375
- Default Value0
- Unitsrotations
Default Rates:
- CAN 2.0100.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<double> GetAbsolutePosition(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<double>
AbsolutePosition Status Signal Object
GetFaultField(bool)
Integer representing all fault flags reported by the device.
These are device specific and are not used directly in typical applications. Use the signal specific GetFault_*() methods instead.- Minimum Value0
- Maximum Value4294967295
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetFaultField(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
FaultField Status Signal Object
GetFault_BadMagnet(bool)
The magnet distance is not correct or magnet is missing
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetFault_BadMagnet(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
Fault_BadMagnet Status Signal Object
GetFault_BootDuringEnable(bool)
Device boot while detecting the enable signal
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetFault_BootDuringEnable(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
Fault_BootDuringEnable Status Signal Object
GetFault_Hardware(bool)
Hardware fault occurred
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetFault_Hardware(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
Fault_Hardware Status Signal Object
GetFault_Undervoltage(bool)
Device supply voltage dropped to near brownout levels
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetFault_Undervoltage(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
Fault_Undervoltage Status Signal Object
GetFault_UnlicensedFeatureInUse(bool)
An unlicensed feature is in use, device may not behave as expected.
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetFault_UnlicensedFeatureInUse(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
Fault_UnlicensedFeatureInUse Status Signal Object
GetIsProLicensed(bool)
Whether the device is Phoenix Pro licensed.
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetIsProLicensed(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
IsProLicensed Status Signal Object
GetMagnetHealth(bool)
Magnet health as measured by CANcoder.
Red indicates too close or too far, Orange is adequate but with reduced accuracy, green is ideal. Invalid means the accuracy cannot be determined.Default Rates:
- CAN 2.04.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<MagnetHealthValue> GetMagnetHealth(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<MagnetHealthValue>
MagnetHealth Status Signal Object
GetPosition(bool)
Position of the device. This is initialized to the absolute position on boot.
- Minimum Value-16384.0
- Maximum Value16383.999755859375
- Default Value0
- Unitsrotations
Default Rates:
- CAN 2.0100.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<double> GetPosition(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<double>
Position Status Signal Object
GetPositionSinceBoot(bool)
The relative position reported by the CANcoder since boot.
This is the total displacement reported by CANcoder since power up. This signal is relative and is not influenced by the fusing algorithm.- Minimum Value-16384.0
- Maximum Value16383.999755859375
- Default Value0
- Unitsrotations
Default Rates:
- CAN 2.04.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<double> GetPositionSinceBoot(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<double>
PositionSinceBoot Status Signal Object
GetStickyFaultField(bool)
Integer representing all (persistent) sticky fault flags reported by the device.
These are device specific and are not used directly in typical applications. Use the signal specific GetStickyFault_*() methods instead.- Minimum Value0
- Maximum Value4294967295
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetStickyFaultField(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
StickyFaultField Status Signal Object
GetStickyFault_BadMagnet(bool)
The magnet distance is not correct or magnet is missing
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetStickyFault_BadMagnet(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
StickyFault_BadMagnet Status Signal Object
GetStickyFault_BootDuringEnable(bool)
Device boot while detecting the enable signal
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetStickyFault_BootDuringEnable(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
StickyFault_BootDuringEnable Status Signal Object
GetStickyFault_Hardware(bool)
Hardware fault occurred
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetStickyFault_Hardware(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
StickyFault_Hardware Status Signal Object
GetStickyFault_Undervoltage(bool)
Device supply voltage dropped to near brownout levels
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetStickyFault_Undervoltage(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
StickyFault_Undervoltage Status Signal Object
GetStickyFault_UnlicensedFeatureInUse(bool)
An unlicensed feature is in use, device may not behave as expected.
- Default ValueFalse
Default Rates:
- CAN4.0 Hz
public StatusSignal<bool> GetStickyFault_UnlicensedFeatureInUse(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<bool>
StickyFault_UnlicensedFeatureInUse Status Signal Object
GetSupplyVoltage(bool)
Measured supply voltage to the CANcoder.
- Minimum Value4
- Maximum Value16.75
- Default Value4
- UnitsV
Default Rates:
- CAN 2.04.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<double> GetSupplyVoltage(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<double>
SupplyVoltage Status Signal Object
GetUnfilteredVelocity(bool)
The unfiltered velocity reported by CANcoder.
This is the unfiltered velocity reported by CANcoder. This signal does not use the fusing algorithm.- Minimum Value-8000.0
- Maximum Value7999.755859375
- Default Value0
- Unitsrotations per second
Default Rates:
- CAN 2.04.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<double> GetUnfilteredVelocity(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<double>
UnfilteredVelocity Status Signal Object
GetVelocity(bool)
Velocity of the device.
- Minimum Value-512.0
- Maximum Value511.998046875
- Default Value0
- Unitsrotations per second
Default Rates:
- CAN 2.0100.0 Hz
- CAN FD100.0 Hz (TimeSynced with Pro)
public StatusSignal<double> GetVelocity(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<double>
Velocity Status Signal Object
GetVersion(bool)
Full Version of firmware in device. The format is a four byte value.
- Minimum Value0
- Maximum Value4294967295
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetVersion(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
Version Status Signal Object
GetVersionBugfix(bool)
App Bugfix Version number.
- Minimum Value0
- Maximum Value255
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetVersionBugfix(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
VersionBugfix Status Signal Object
GetVersionBuild(bool)
App Build Version number.
- Minimum Value0
- Maximum Value255
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetVersionBuild(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
VersionBuild Status Signal Object
GetVersionMajor(bool)
App Major Version number.
- Minimum Value0
- Maximum Value255
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetVersionMajor(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
VersionMajor Status Signal Object
GetVersionMinor(bool)
App Minor Version number.
- Minimum Value0
- Maximum Value255
- Default Value0
- Units
Default Rates:
- CAN4.0 Hz
public StatusSignal<int> GetVersionMinor(bool refresh = true)
Parameters
refreshboolWhether to refresh the StatusSignal before returning it; defaults to true
Returns
- StatusSignal<int>
VersionMinor Status Signal Object
SetControl(ControlRequest)
Control device with generic control request object.
User must make sure the specified object is castable to a valid control request, otherwise this function will fail at run-time and return the NotSupported StatusCodepublic StatusCode SetControl(ControlRequest request)
Parameters
requestControlRequestControl object to request of the device
Returns
- StatusCode
Status Code of the request, 0 is OK
SetPosition(double, double)
Sets the current position of the device.
public StatusCode SetPosition(double newValue, double timeoutSeconds = 0.1)
Parameters
newValuedoubleValue to set to. Units are in rotations.
timeoutSecondsdoubleMaximum time to wait up to in seconds.
Returns
- StatusCode
StatusCode of the set command