Class CANCoder

java.lang.Object
com.ctre.phoenix.sensors.CANCoder
Direct Known Subclasses:
WPI_CANCoder

@Deprecated(since="2024",
            forRemoval=true)
public class CANCoder
extends Object
Deprecated, for removal: This API element is subject to removal in a future version.
This device's Phoenix 5 API is deprecated for removal in the 2025 season. Users should update to Phoenix 6 firmware and migrate to the Phoenix 6 API. A migration guide is available at https://v6.docs.ctr-electronics.com/en/stable/docs/migration/migration-guide/index.html.

If the Phoenix 5 API must be used for this device, the device must have 22.X firmware. This firmware is available in Tuner X after selecting Phoenix 5 in the firmware year dropdown.

CTRE CANCoder.
 
 // Example usage of a CANCoder
 CANCoder cancoder = new CANCoder(0); // creates a new CANCoder with ID 0

 CANCoderConfiguration config = new CANCoderConfiguration();
 // set units of the CANCoder to radians, with velocity being radians per second
 config.sensorCoefficient = 2 * Math.PI / 4096.0;
 config.unitString = "rad";
 config.sensorTimeBase = SensorTimeBase.PerSecond;
 cancoder.configAllSettings(config);

 System.out.println(cancoder.getPosition()); // prints the position of the CANCoder
 System.out.println(cancoder.getVelocity()); // prints the velocity recorded by the CANCoder

 ErrorCode error = cancoder.getLastError(); // gets the last error generated by the CANCoder
 CANCoderFaults faults = new CANCoderFaults();
 ErrorCode faultsError = cancoder.getFaults(faults); // fills faults with the current CANCoder faults; returns the last error generated

 cancoder.setStatusFramePeriod(CANCoderStatusFrame.SensorData, 10); // changes the period of the sensor data frame to 10ms
 
 
  • Constructor Summary

    Constructors 
    Constructor Description
    CANCoder​(int deviceNumber)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructor.
    CANCoder​(int deviceNumber, String canbus)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructor.
  • Method Summary

    Modifier and Type Method Description
    ErrorCode clearStickyFaults()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Clears the Sticky Faults
    ErrorCode clearStickyFaults​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Clears the Sticky Faults
    ErrorCode configAbsoluteSensorRange​(AbsoluteSensorRange absoluteSensorRange)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the signage and range of the "Absolute Position" signal.
    ErrorCode configAbsoluteSensorRange​(AbsoluteSensorRange absoluteSensorRange, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the signage and range of the "Absolute Position" signal.
    ErrorCode configAllSettings​(CANCoderConfiguration allConfigs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures all persistent settings (overloaded so timeoutMs is 50 ms).
    ErrorCode configAllSettings​(CANCoderConfiguration allConfigs, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures all persistent settings.
    ErrorCode configFactoryDefault()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures all persistent settings to defaults.
    ErrorCode configFactoryDefault​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures all persistent settings to defaults.
    ErrorCode configFeedbackCoefficient​(double sensorCoefficient, String unitString, SensorTimeBase sensorTimeBase)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Choose what units you want the API to get/set.
    ErrorCode configFeedbackCoefficient​(double sensorCoefficient, String unitString, SensorTimeBase sensorTimeBase, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Choose what units you want the API to get/set.
    AbsoluteSensorRange configGetAbsoluteSensorRange()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    AbsoluteSensorRange configGetAbsoluteSensorRange​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int configGetCustomParam​(int paramIndex)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the value of a custom parameter.
    int configGetCustomParam​(int paramIndex, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the value of a custom parameter.
    double configGetFeedbackCoefficient()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    double configGetFeedbackCoefficient​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    SensorTimeBase configGetFeedbackTimeBase()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    SensorTimeBase configGetFeedbackTimeBase​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    String configGetFeedbackUnitString()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    String configGetFeedbackUnitString​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    double configGetMagnetOffset()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    double configGetMagnetOffset​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    double configGetParameter​(ParamEnum param, int ordinal)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets a parameter.
    double configGetParameter​(ParamEnum param, int ordinal, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets a parameter.
    boolean configGetSensorDirection()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    boolean configGetSensorDirection​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    SensorInitializationStrategy configGetSensorInitializationStrategy()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    SensorInitializationStrategy configGetSensorInitializationStrategy​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    SensorVelocityMeasPeriod configGetVelocityMeasurementPeriod()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    SensorVelocityMeasPeriod configGetVelocityMeasurementPeriod​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int configGetVelocityMeasurementWindow()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int configGetVelocityMeasurementWindow​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    ErrorCode configMagnetOffset​(double offsetDegrees)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Adjusts the zero point for the absolute position register.
    ErrorCode configMagnetOffset​(double offsetDegrees, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Adjusts the zero point for the absolute position register.
    ErrorCode configSensorDirection​(boolean bSensorDirection)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Choose which direction is interpreted as positive displacement.
    ErrorCode configSensorDirection​(boolean bSensorDirection, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Choose which direction is interpreted as positive displacement.
    ErrorCode configSensorInitializationStrategy​(SensorInitializationStrategy initializationStrategy)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Pick the strategy on how to initialize the CANCoder's "Position" register.
    ErrorCode configSensorInitializationStrategy​(SensorInitializationStrategy initializationStrategy, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Pick the strategy on how to initialize the CANCoder's "Position" register.
    ErrorCode configSetCustomParam​(int newValue, int paramIndex)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the value of a custom parameter.
    ErrorCode configSetCustomParam​(int newValue, int paramIndex, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the value of a custom parameter.
    ErrorCode configSetParameter​(ParamEnum param, double value, int subValue, int ordinal)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets a parameter.
    ErrorCode configSetParameter​(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets a parameter.
    ErrorCode configVelocityMeasurementPeriod​(SensorVelocityMeasPeriod period)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures the period of each velocity sample.
    ErrorCode configVelocityMeasurementPeriod​(SensorVelocityMeasPeriod period, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Configures the period of each velocity sample.
    ErrorCode configVelocityMeasurementWindow​(int windowSize)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the number of velocity samples used in the rolling average velocity measurement.
    ErrorCode configVelocityMeasurementWindow​(int windowSize, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the number of velocity samples used in the rolling average velocity measurement.
    ErrorCode DestroyObject()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    double getAbsolutePosition()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the absolute position of the sensor.
    void getAllConfigs​(CANCoderConfiguration allConfigs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets all persistant settings (overloaded so timeoutMs is 50 ms).
    void getAllConfigs​(CANCoderConfiguration allConfigs, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets all persistant settings.
    double getBusVoltage()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the bus voltage seen by the device.
    int getDeviceID()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    ErrorCode getFaults​(CANCoderFaults toFill)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the CANCoder fault status
    int getFirmwareVersion()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the firmware version of the device.
    ErrorCode getLastError()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Call GetLastError() generated by this object.
    double getLastTimestamp()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the timestamp of the CAN frame retrieved in the last called get routine.
    String getLastUnitString()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Get the units for the signal retrieved in the last called get routine.
    MagnetFieldStrength getMagnetFieldStrength()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the magnet's health.
    double getPosition()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the position of the sensor.
    CANCoderSimCollection getSimCollection()
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    int getStatusFramePeriod​(CANCoderStatusFrame frame)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the period of the given status frame.
    int getStatusFramePeriod​(CANCoderStatusFrame frame, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the period of the given status frame.
    ErrorCode getStickyFaults​(CANCoderStickyFaults toFill)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the CANCoder sticky fault status
    double getVelocity()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Gets the velocity of the sensor.
    boolean hasResetOccurred()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Returns true if the device has reset since last call.
    ErrorCode setPosition​(double newPosition)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the position of the sensor.
    ErrorCode setPosition​(double newPosition, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the position of the sensor.
    ErrorCode setPositionToAbsolute()
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the position of the sensor to match the magnet's "Absolute Sensor".
    ErrorCode setPositionToAbsolute​(int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the position of the sensor to match the magnet's "Absolute Sensor".
    ErrorCode setStatusFramePeriod​(CANCoderStatusFrame statusFrame, int periodMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the period of the given status frame.
    ErrorCode setStatusFramePeriod​(CANCoderStatusFrame statusFrame, int periodMs, int timeoutMs)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Sets the period of the given status frame.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CANCoder

      public CANCoder​(int deviceNumber, String canbus)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructor.
      Parameters:
      deviceNumber - The CAN Device ID of the CANCoder.
      canbus - Name of the CANbus; can be a SocketCAN interface (on Linux), or a CANivore device name or serial number
    • CANCoder

      public CANCoder​(int deviceNumber)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructor.
      Parameters:
      deviceNumber - The CAN Device ID of the CANCoder.
  • Method Details

    • DestroyObject

      Deprecated, for removal: This API element is subject to removal in a future version.
    • getDeviceID

      public int getDeviceID()
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getSimCollection

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      object that can set simulation inputs.
    • getPosition

      public double getPosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the position of the sensor. This may be relative or absolute depending on configuration. The units are determined by the coefficient and unit-string configuration params, default is degrees.
      Returns:
      The position of the sensor.
    • setPosition

      public ErrorCode setPosition​(double newPosition, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the position of the sensor. The units are determined by the coefficient and unit-string configuration params, default is degrees.
      Parameters:
      newPosition -
      Returns:
      ErrorCode generated by function. 0 indicates no error.
    • setPosition

      public ErrorCode setPosition​(double newPosition)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the position of the sensor. The units are determined by the coefficient and unit-string configuration params, default is degrees.
      Parameters:
      newPosition -
      Returns:
      ErrorCode generated by function. 0 indicates no error.
    • setPositionToAbsolute

      public ErrorCode setPositionToAbsolute​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the position of the sensor to match the magnet's "Absolute Sensor". The units are determined by the coefficient and unit-string configuration params, default is degrees.
      Returns:
      ErrorCode generated by function. 0 indicates no error.
    • setPositionToAbsolute

      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the position of the sensor to match the magnet's "Absolute Sensor". The units are determined by the coefficient and unit-string configuration params, default is degrees.
      Returns:
      ErrorCode generated by function. 0 indicates no error.
    • getVelocity

      public double getVelocity()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the velocity of the sensor. The units are determined by the coefficient and unit-string configuration params, default is degrees per second.
      Returns:
      The Velocity of the sensor.
    • getAbsolutePosition

      public double getAbsolutePosition()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the absolute position of the sensor. The absolute position may be unsigned (for example: [0,360) deg), or signed (for example: [-180,+180) deg). This is determined by a configuration. The default selection is unsigned. The units are determined by the coefficient and unit-string configuration params, default is degrees. Note: this signal is not affected by calls to SetPosition().
      Returns:
      The position of the sensor.
    • configVelocityMeasurementPeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures the period of each velocity sample. Every 1ms a position value is sampled, and the delta between that sample and the position sampled kPeriod ms ago is inserted into a filter. kPeriod is configured with this function.
      Parameters:
      period - Desired period for the velocity measurement.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configVelocityMeasurementPeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures the period of each velocity sample. Every 1ms a position value is sampled, and the delta between that sample and the position sampled kPeriod ms ago is inserted into a filter. kPeriod is configured with this function.
      Parameters:
      period - Desired period for the velocity measurement.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configVelocityMeasurementWindow

      public ErrorCode configVelocityMeasurementWindow​(int windowSize, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the number of velocity samples used in the rolling average velocity measurement.
      Parameters:
      windowSize - Number of samples in the rolling average of velocity measurement. Valid values are 1,2,4,8,16,32. If another value is specified, it will truncate to nearest support value.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configVelocityMeasurementWindow

      public ErrorCode configVelocityMeasurementWindow​(int windowSize)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the number of velocity samples used in the rolling average velocity measurement.
      Parameters:
      windowSize - Number of samples in the rolling average of velocity measurement. Valid values are 1,2,4,8,16,32. If another value is specified, it will truncate to nearest support value.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configAbsoluteSensorRange

      public ErrorCode configAbsoluteSensorRange​(AbsoluteSensorRange absoluteSensorRange, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the signage and range of the "Absolute Position" signal. Choose unsigned for an absolute range of [0,+1) rotations, [0,360) deg, etc... Choose signed for an absolute range of [-0.5,+0.5) rotations, [-180,+180) deg, etc...
      Parameters:
      absoluteSensorRange - Desired Sign/Range for the absolute position register.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configAbsoluteSensorRange

      public ErrorCode configAbsoluteSensorRange​(AbsoluteSensorRange absoluteSensorRange)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the signage and range of the "Absolute Position" signal. Choose unsigned for an absolute range of [0,+1) rotations, [0,360) deg, etc... Choose signed for an absolute range of [-0.5,+0.5) rotations, [-180,+180) deg, etc...
      Parameters:
      absoluteSensorRange - Desired Sign/Range for the absolute position register.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configMagnetOffset

      public ErrorCode configMagnetOffset​(double offsetDegrees, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adjusts the zero point for the absolute position register. The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180) and a hard-limited mechanism may have such a discontinuity in its functional range. In which case use this config to move the discontinuity outside of the function range.
      Parameters:
      offsetDegrees - Offset in degrees (unit string and coefficient DO NOT apply for this config).
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configMagnetOffset

      public ErrorCode configMagnetOffset​(double offsetDegrees)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Adjusts the zero point for the absolute position register. The absolute position of the sensor will always have a discontinuity (360 -> 0 deg) or (+180 -> -180) and a hard-limited mechanism may have such a discontinuity in its functional range. In which case use this config to move the discontinuity outside of the function range.
      Parameters:
      offsetDegrees - Offset in degrees (unit string and coefficient DO NOT apply for this config).
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configSensorInitializationStrategy

      public ErrorCode configSensorInitializationStrategy​(SensorInitializationStrategy initializationStrategy, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Pick the strategy on how to initialize the CANCoder's "Position" register. Depending on the mechanism, it may be desirable to auto set the Position register to match the Absolute Position (swerve for example). Or it may be desired to zero the sensor on boot (drivetrain translation sensor or a relative servo). TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the CANCoder is reset.
      Parameters:
      initializationStrategy - The sensor initialization strategy to use. This will impact the behavior the next time CANCoder boots up.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configSensorInitializationStrategy

      Deprecated, for removal: This API element is subject to removal in a future version.
      Pick the strategy on how to initialize the CANCoder's "Position" register. Depending on the mechanism, it may be desirable to auto set the Position register to match the Absolute Position (swerve for example). Or it may be desired to zero the sensor on boot (drivetrain translation sensor or a relative servo). TIP: Tuner's self-test feature will report what the boot sensor value will be in the event the CANCoder is reset.
      Parameters:
      initializationStrategy - The sensor initialization strategy to use. This will impact the behavior the next time CANCoder boots up.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configFeedbackCoefficient

      public ErrorCode configFeedbackCoefficient​(double sensorCoefficient, String unitString, SensorTimeBase sensorTimeBase, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Choose what units you want the API to get/set. This also impacts the units displayed in Self-Test in Tuner. Depending on your mechanism, you may want to scale rotational units (deg, radians, rotations), or scale to a distance (inches, centimeters).
      Parameters:
      sensorCoefficient - Scalar to multiply the CANCoder's native 12-bit resolute sensor. Defaults to 0.087890625 to produce degrees.
      unitString - String holding the unit to report in. This impacts all routines (except for ConfigMagnetOffset) and the self-test in Tuner. The string value itself is arbitrary. The max number of letters will depend on firmware versioning, but generally CANCoder supports up to eight letters. However, common units such as "centimeters" are supported explicitly despite exceeding the eight-letter limit. Default is "deg"
      sensorTimeBase - Desired denominator to report velocity in. This impacts GetVelocity and the reported velocity in self-test in Tuner. Default is "Per Second".
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configFeedbackCoefficient

      public ErrorCode configFeedbackCoefficient​(double sensorCoefficient, String unitString, SensorTimeBase sensorTimeBase)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Choose what units you want the API to get/set. This also impacts the units displayed in Self-Test in Tuner. Depending on your mechanism, you may want to scale rotational units (deg, radians, rotations), or scale to a distance (inches, centimeters).
      Parameters:
      sensorCoefficient - Scalar to multiply the CANCoder's native 12-bit resolute sensor. Defaults to 0.087890625 to produce degrees.
      unitString - String holding the unit to report in. This impacts all routines (except for ConfigMagnetOffset) and the self-test in Tuner. The string value itself is arbitrary. The max number of letters will depend on firmware versioning, but generally CANCoder supports up to eight letters. However, common units such as "centimeters" are supported explicitly despite exceeding the eight-letter limit. Default is "deg"
      sensorTimeBase - Desired denominator to report velocity in. This impacts GetVelocity and the reported velocity in self-test in Tuner. Default is "Per Second".
      Returns:
      Error Code generated by function. 0 indicates no error.
    • getBusVoltage

      public double getBusVoltage()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the bus voltage seen by the device.
      Returns:
      The bus voltage value (in volts).
    • getMagnetFieldStrength

      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the magnet's health.
      Returns:
      The magnet health code (red/orange/green).
    • configSensorDirection

      public ErrorCode configSensorDirection​(boolean bSensorDirection, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Choose which direction is interpreted as positive displacement. This affects both "Position" and "Absolute Position".
      Parameters:
      bSensorDirection - False (default) means positive rotation occurs when magnet is spun counter-clockwise when observer is facing the LED side of CANCoder.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configSensorDirection

      public ErrorCode configSensorDirection​(boolean bSensorDirection)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Choose which direction is interpreted as positive displacement. This affects both "Position" and "Absolute Position".
      Parameters:
      bSensorDirection - False (default) means positive rotation occurs when magnet is spun counter-clockwise when observer is facing the LED side of CANCoder.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • getLastError

      Deprecated, for removal: This API element is subject to removal in a future version.
      Call GetLastError() generated by this object. Not all functions return an error code but can potentially report errors. This function can be used to retrieve those error codes.
      Returns:
      The last ErrorCode generated.
    • getLastUnitString

      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the units for the signal retrieved in the last called get routine.
    • getLastTimestamp

      public double getLastTimestamp()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Get the timestamp of the CAN frame retrieved in the last called get routine.
    • configSetCustomParam

      public ErrorCode configSetCustomParam​(int newValue, int paramIndex, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the value of a custom parameter. This is for arbitrary use. Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.
      Parameters:
      newValue - Value for custom parameter.
      paramIndex - Index of custom parameter. [0-1]
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configSetCustomParam

      public ErrorCode configSetCustomParam​(int newValue, int paramIndex)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the value of a custom parameter. This is for arbitrary use. Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.
      Parameters:
      newValue - Value for custom parameter.
      paramIndex - Index of custom parameter. [0-1]
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configGetCustomParam

      public int configGetCustomParam​(int paramIndex, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the value of a custom parameter. This is for arbitrary use. Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.
      Parameters:
      paramIndex - Index of custom parameter. [0-1]
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Value of the custom param.
    • configGetCustomParam

      public int configGetCustomParam​(int paramIndex)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the value of a custom parameter. This is for arbitrary use. Sometimes it is necessary to save calibration/duty cycle/output information in the device. Particularly if the device is part of a subsystem that can be replaced.
      Parameters:
      paramIndex - Index of custom parameter. [0-1]
      Returns:
      Value of the custom param.
    • configSetParameter

      public ErrorCode configSetParameter​(ParamEnum param, double value, int subValue, int ordinal, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets a parameter. Generally this is not used. This can be utilized in - Using new features without updating API installation. - Errata workarounds to circumvent API implementation. - Allows for rapid testing / unit testing of firmware.
      Parameters:
      param - Parameter enumeration.
      value - Value of parameter.
      subValue - Subvalue for parameter. Maximum value of 255.
      ordinal - Ordinal of parameter.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configSetParameter

      public ErrorCode configSetParameter​(ParamEnum param, double value, int subValue, int ordinal)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets a parameter. Generally this is not used. This can be utilized in - Using new features without updating API installation. - Errata workarounds to circumvent API implementation. - Allows for rapid testing / unit testing of firmware.
      Parameters:
      param - Parameter enumeration.
      value - Value of parameter.
      subValue - Subvalue for parameter. Maximum value of 255.
      ordinal - Ordinal of parameter.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configGetParameter

      public double configGetParameter​(ParamEnum param, int ordinal, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets a parameter. Generally this is not used. This can be utilized in - Using new features without updating API installation. - Errata workarounds to circumvent API implementation. - Allows for rapid testing / unit testing of firmware.
      Parameters:
      param - Parameter enumeration.
      ordinal - Ordinal of parameter.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Value of parameter.
    • configGetParameter

      public double configGetParameter​(ParamEnum param, int ordinal)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets a parameter. Generally this is not used. This can be utilized in - Using new features without updating API installation. - Errata workarounds to circumvent API implementation. - Allows for rapid testing / unit testing of firmware.
      Parameters:
      param - Parameter enumeration.
      ordinal - Ordinal of parameter.
      Returns:
      Value of parameter.
    • setStatusFramePeriod

      public ErrorCode setStatusFramePeriod​(CANCoderStatusFrame statusFrame, int periodMs, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the period of the given status frame.
      Parameters:
      statusFrame - Frame whose period is to be changed.
      periodMs - Period in ms for the given frame.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • setStatusFramePeriod

      public ErrorCode setStatusFramePeriod​(CANCoderStatusFrame statusFrame, int periodMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Sets the period of the given status frame.
      Parameters:
      statusFrame - Frame whose period is to be changed.
      periodMs - Period in ms for the given frame.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • getStatusFramePeriod

      public int getStatusFramePeriod​(CANCoderStatusFrame frame, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the period of the given status frame.
      Parameters:
      frame - Frame to get the period of.
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Period of the given status frame.
    • getStatusFramePeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the period of the given status frame.
      Parameters:
      frame - Frame to get the period of.
      Returns:
      Period of the given status frame.
    • getFirmwareVersion

      public int getFirmwareVersion()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the firmware version of the device.
      Returns:
      Firmware version of device.
    • hasResetOccurred

      public boolean hasResetOccurred()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns true if the device has reset since last call.
      Returns:
      Has a Device Reset Occurred?
    • getFaults

      public ErrorCode getFaults​(CANCoderFaults toFill)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the CANCoder fault status
      Parameters:
      toFill - Container for fault statuses.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • getStickyFaults

      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets the CANCoder sticky fault status
      Parameters:
      toFill - Container for sticky fault statuses.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • clearStickyFaults

      public ErrorCode clearStickyFaults​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Clears the Sticky Faults
      Returns:
      Error Code generated by function. 0 indicates no error.
    • clearStickyFaults

      Deprecated, for removal: This API element is subject to removal in a future version.
      Clears the Sticky Faults
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configGetVelocityMeasurementPeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetVelocityMeasurementPeriod

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetVelocityMeasurementWindow

      public int configGetVelocityMeasurementWindow​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetVelocityMeasurementWindow

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetAbsoluteSensorRange

      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetAbsoluteSensorRange

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetMagnetOffset

      public double configGetMagnetOffset​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetMagnetOffset

      public double configGetMagnetOffset()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetSensorDirection

      public boolean configGetSensorDirection​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetSensorDirection

      public boolean configGetSensorDirection()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetSensorInitializationStrategy

      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetSensorInitializationStrategy

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetFeedbackCoefficient

      public double configGetFeedbackCoefficient​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetFeedbackCoefficient

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetFeedbackUnitString

      public String configGetFeedbackUnitString​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetFeedbackUnitString

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configGetFeedbackTimeBase

      public SensorTimeBase configGetFeedbackTimeBase​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out.
      Returns:
      Read value of the config param.
    • configGetFeedbackTimeBase

      Deprecated, for removal: This API element is subject to removal in a future version.
      Returns:
      Read value of the config param.
    • configAllSettings

      public ErrorCode configAllSettings​(CANCoderConfiguration allConfigs, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures all persistent settings.
      Parameters:
      allConfigs - Object with all of the persistant settings
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configAllSettings

      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures all persistent settings (overloaded so timeoutMs is 50 ms).
      Parameters:
      allConfigs - Object with all of the persistant settings
      Returns:
      Error Code generated by function. 0 indicates no error.
    • getAllConfigs

      public void getAllConfigs​(CANCoderConfiguration allConfigs, int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets all persistant settings.
      Parameters:
      allConfigs - Object with all of the persistant settings
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
    • getAllConfigs

      public void getAllConfigs​(CANCoderConfiguration allConfigs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Gets all persistant settings (overloaded so timeoutMs is 50 ms).
      Parameters:
      allConfigs - Object with all of the persistant settings
    • configFactoryDefault

      public ErrorCode configFactoryDefault​(int timeoutMs)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures all persistent settings to defaults.
      Parameters:
      timeoutMs - Timeout value in ms. If nonzero, function will wait for config success and report an error if it times out. If zero, no blocking or checking is performed.
      Returns:
      Error Code generated by function. 0 indicates no error.
    • configFactoryDefault

      Deprecated, for removal: This API element is subject to removal in a future version.
      Configures all persistent settings to defaults.
      Returns:
      Error Code generated by function. 0 indicates no error.