Device Faults#

“Faults” are status indicators on CTR Electronics CAN devices that indicate a certain behavior or event has occurred. Faults do not directly affect the behavior of a device; instead, they indicate the device’s current status and highlight potential issues.

Faults are stored in two fashions. There are “live” faults, which are reported in real-time, and “sticky” faults, which assert persistently and stay asserted until they are manually cleared (like trouble codes in a vehicle).

Sticky Faults can be cleared by clicking the Clear Faults button in Phoenix Tuner X, or by calling clearStickyFaults() on the device in the robot program. A regular fault can only be cleared when the offending problem has been resolved.

Clear faults button in Tuner located in the top bar.

Using API to Retrieve Faults#

Faults can also be retrieved in API using the getFault_*() (regular) or getStickyFault_*() (sticky) methods on the device object. This can be useful for diagnostics or error handling.

var faulted = m_cancoder.getFault_BadMagnet().getValue();

if (faulted) {
   // do action when bad magnet fault is set
}
auto faulted = m_cancoder.GetFault_BadMagnet().GetValue();

if (faulted) {
   // do action when bad magnet fault is set
}
faulted = self.cancoder.get_fault_bad_magnet().value

if faulted:
   # do action when bad magnet fault is set

A list of possible faults can be found in the API documentation for each device.

Using API to Clear Sticky Faults#

Sticky faults can be cleared in API using the clearStickyFaults() method on the device objects. Additionally, individual sticky faults may be cleared using the clearStickyFault_*() APIs.

Note

Clearing sticky faults is a blocking operation and should not be run in a periodic loop.

// clear the undervoltage sticky fault
m_cancoder.clearStickyFault_Undervoltage();
// clear the undervoltage sticky fault
m_cancoder.ClearStickyFault_Undervoltage();
# clear the undervoltage sticky fault
self.cancoder.clear_sticky_fault_undervoltage()