FRC CAN-based devices

Several different CAN motor controllers supported by the WPI Library may be used with VMX-pi, including the CTRE Phoenix-compatible motor controllers (TalonSRX and Victor SPX) and Pneumatics Control Module (PCM), the REV SparkMax motor controller and the Titan Single/Titan Quad motor controllers.

To access these CAN-based devices from VMX-pi, steps must be taken to:

  • Install 3rd-party Libraries
  • Enable Device Operation

Installing 3rd-party Libraries

Simply follow the same online 3rd-party library installation method used during FRC Competition Season, using the URLs indicated below.

Studica Titan Quad/Titan CAN Motor Controller

http://dev.studica.com/releases/2020/Studica.json .

Firmware Version

Titan Quad Firmware Version 0.1.0 or higher is required.

CTRE Phoenix-compatible Devices (TalonSRX, VictorSPX, Pneumatic Control Module (PCM))

http://www.kauailabs.com/dist/frc/2020/Phoenix-vmx.json

Firmware Version

TalonSRX: TalonSRX Firmware version 20.2 (FRC2020) is required.

TalonFX: TalonFX Firmware version 20.5.6.0 (FRC2020) is required.

REV Robotics SparkMAX

https://www.kauailabs.com/dist/frc/2020/REVRobotics.json

Firmware Version

SparkMax Firmware version 1.5.2 is required.

Enabling Device Operation

Competition FRC Robots, when controlled by the National Instruments RoboRIO ®, include a safety mechanism which only enables motor controllers and other actuators during competition, and disables them at all other times. This mechanism ensure that a “runaway robot” will stop functioning as soon as it loses contact with the RoboRIO for any reason.

For CAN-based devices, when a RoboRIO is not present on the robot, special procedures must be used in order to enable the motor controller when under the control of VMX-pi.

CTRE Phoenix-based Devices (TalonSRX, VictorSPX, Pneumatic Control Module (PCM))

1) Disable the “FRC Lock” mechanism

If a CTRE Phoenix-compliant motor controller has ever been operated together with a National Instruments RoboRIO, the motor controller’s “FRC Lock” mechanism is likely active. The “FRC Lock” configuration is stored in the motor controller’s flash memory, so the motor controller will continue to be “FRC Locked” until the lock is disabled. The motor controller’s “FRC Lock” must be disabled before it can be enabled for operation with VMX-pi.

In order to clear a “FRC Lock”, follow these steps:

  • Completely remove the National Instruments RoboRIO from the CAN bus
  • Remove power from the motor controller
  • Press and Hold the motor controller (e.g., TalonSRX) B/C CAL Button
  • While holding down the button, restore power to the motor controller. Continue holding the button until the status LEDs blink green then release the button.

At this point, the motor controller factory default values are restored, which includes clearing the FRC Lock.

Note: if a RoboRIO with a FRC Application loaded onto it is ever again added to same CAN bus, the motor controller will assume it is being used in a FRC competition environment, and will automatically configure itself to be “FRC Locked” again.

2) Add Feed Enable Code to your Robot Software

In addition to the typical code used to access CTRE’s Phoenix devices, the following code to enable CAN Device operation must be added as demonstrated below:

Java

import com.ctre.phoenix.unmanaged.UnmanagedJNI;

@Override
public void autonomousPeriodic() {
UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
}

@Override
public void teleopPeriodic() {
UnmanagedJNI.JNI_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
}

C++

#include <ctre/phoenix/cci/Unmanaged_CCI.h>

void AutonomousPeriodic() override {
c_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
}

void TeleopPeriodic() override {
c_FeedEnable(100); // Enable Phoenix CAN Devices for 100 Milliseconds
}

REV Robotics SparkMAX

The robot application must include code to regularly “enable” the SparkMAX motor controller.

Java

import com.revrobotics.jni.CANSparkMaxJNI;

@Override
public void autonomousPeriodic() {
CANSparkMaxJNI.c_SparkMax_SetEnable(true); // Periodically ensure motor controller outputs are enabled
}

@Override
public void teleopPeriodic() {

CANSparkMaxJNI.c_SparkMax_SetEnable(true); // Periodically ensure motor controller outputs are enabled
}

C++

void Robot::AutonomousPeriodic() {
rev::CANSparkMaxLowLevel::SetEnable(true); // Periodically ensure motor controller outputs are enabled
}


void Robot::TeleopPeriodic() {
rev::CANSparkMaxLowLevel::SetEnable(true); // Periodically ensure motor controller outputs are enabled
}