CoreCANcoder Class

Class for CANcoder, a CAN based magnetic encoder that provides absolute and relative position along with filtered velocity.

Definition

Namespace: CTRE.Phoenix6.Hardware.Core
Assembly: Phoenix6 (in Phoenix6.dll) Version: 1.0.0
C#
public class CoreCANcoder : ParentDevice
Inheritance
Object    ParentDevice    CoreCANcoder

Constructors

CoreCANcoder Constructs a new CANcoder object.

Properties

Configurator The configurator for this device. Users may use this to refresh and apply configs, such as the CANcoderConfiguration object
ControlRequest The last applied control request. Caller can cast this to the derived class if they know what type it is, otherwise they can use the ControlInfo to get info out of it.
(Inherited from ParentDevice)
DeviceHash Hash of this device
(Inherited from ParentDevice)
DeviceID ID of this device
(Inherited from ParentDevice)
HasResetOccurred Returns true if device has reset since the previous call of this routine.
Network Network this device is on
(Inherited from ParentDevice)

Methods

EqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
FinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
GetAbsolutePosition Absolute Position of device. The possible range is documented below, however the exact expected range is determined by the AbsoluteSensorRange.
  • Minimum Value – -0.5
  • Maximum Value – 0.999755859375
  • Default Value – 0
  • Units – rotations
Default Rates:
  • CAN – 100.0 Hz
GetFault_BadMagnet The magnet distance is not correct or magnet is missing
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetFault_BootDuringEnable Device boot while detecting the enable signal
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetFault_Hardware Hardware fault occurred
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetFault_Undervoltage Device supply voltage dropped to near brownout levels
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetFault_UnlicensedFeatureInUse An unlicensed feature is in use, device may not behave as expected.
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetFaultField Integer representing all faults

This returns the 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 Value – 0
  • Maximum Value – 16777215
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
GetHashCodeServes as the default hash function.
(Inherited from Object)
GetMagnetHealth Magnet health as measured by CANcoder.

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.0 – 4.0 Hz
  • CAN FD – 100.0 Hz
GetPosition Position of device.
  • Minimum Value – -16384.0
  • Maximum Value – 16383.999755859375
  • Default Value – 0
  • Units – rotations
Default Rates:
  • CAN – 100.0 Hz
GetPositionSinceBoot 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. It is also not timesynced. If you wish to use a signal with timesync, use Position.

  • Minimum Value – -16384.0
  • Maximum Value – 16383.999755859375
  • Default Value – 0
  • Units – rotations
Default Rates:
  • CAN 2.0 – 4.0 Hz
  • CAN FD – 100.0 Hz
GetResetOccurredChecker Return a lambda that checks for device resets
GetStickyFault_BadMagnet The magnet distance is not correct or magnet is missing
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetStickyFault_BootDuringEnable Device boot while detecting the enable signal
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetStickyFault_Hardware Hardware fault occurred
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetStickyFault_Undervoltage Device supply voltage dropped to near brownout levels
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetStickyFault_UnlicensedFeatureInUse An unlicensed feature is in use, device may not behave as expected.
  • Default Value – False
Default Rates:
  • CAN – 4.0 Hz
GetStickyFaultField Integer representing all sticky faults

This returns the 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 Value – 0
  • Maximum Value – 16777215
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
GetSupplyVoltage Measured supply voltage to the CANcoder.
  • Minimum Value – 4
  • Maximum Value – 16.75
  • Default Value – 4
  • Units – V
Default Rates:
  • CAN 2.0 – 4.0 Hz
  • CAN FD – 100.0 Hz
GetTypeGets the Type of the current instance.
(Inherited from Object)
GetUnfilteredVelocity The unfiltered velocity reported by CANcoder.

This is the unfiltered velocity reported by CANcoder. This signal does not use the fusing algorithm. It is also not timesynced. If you wish to use a signal with timesync, use Velocity.

  • Minimum Value – -8000.0
  • Maximum Value – 7999.755859375
  • Default Value – 0
  • Units – rotations per second
Default Rates:
  • CAN 2.0 – 4.0 Hz
  • CAN FD – 100.0 Hz
GetVelocity Velocity of device.
  • Minimum Value – -512.0
  • Maximum Value – 511.998046875
  • Default Value – 0
  • Units – rotations per second
Default Rates:
  • CAN – 100.0 Hz
GetVersion Full Version. The format is a four byte value.

Full Version of firmware in device. The format is a four byte value.

  • Minimum Value – 0
  • Maximum Value – 4294967295
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
GetVersionBugfix App Bugfix Version number.
  • Minimum Value – 0
  • Maximum Value – 255
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
GetVersionBuild App Build Version number.
  • Minimum Value – 0
  • Maximum Value – 255
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
GetVersionMajor App Major Version number.
  • Minimum Value – 0
  • Maximum Value – 255
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
GetVersionMinor App Minor Version number.
  • Minimum Value – 0
  • Maximum Value – 255
  • Default Value – 0
  • Units
Default Rates:
  • CAN – 4.0 Hz
LookupStatusSignalT(UInt16, String, Boolean) Looks up a status signal and inserts it into the local dictionary if not found
(Inherited from ParentDevice)
LookupStatusSignalT(UInt16, Int32, FuncDictionaryInt32, StatusSignalT, String, Boolean) Looks up a status signal and inserts it into the local dictionary if not found
(Inherited from ParentDevice)
MemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
OptimizeBusUtilization Optimizes the device's bus utilization by reducing the update frequencies of its status signals.

All status signals that have not been explicitly given an update frequency will be disabled. Note that if other status signals in the same status frame have been given an update frequency, the update frequency will be honored for the entire frame.

This function only needs to be called once on this device in the robot program. Additionally, this method does not necessarily need to be called after setting the update frequencies of other signals.

To restore the default status update frequencies, remove this method call, redeploy the robot application, and power-cycle the devices on the bus. Alternatively, the user can override individual status update frequencies using {@link BaseStatusSignal#setUpdateFrequency}.
(Inherited from ParentDevice)

ReportIfTooOld Function to call to check if the device is too old, and if so report it to the console output
(Overrides ParentDeviceReportIfTooOld)
SetControl Control motor 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 StatusCode

SetControlPrivate Sets the control request to this device
(Inherited from ParentDevice)
ToStringReturns a string that represents the current object.
(Inherited from Object)

Fields

deviceIdentifier The unique deviceIdentifier for this device
(Inherited from ParentDevice)

See Also