wiki:SoftwareCAN

Configuring and Using the CAN Interface for Software

CAN is a connection interface like PWM is as well. A controller area network is a series of nodes daisy-chained together to a single signal port. Instead of referencing a port number, as is done with PWM or digital input, CAN objects are referenced by each device's unique ID number, which needs to be initially set. This somewhat complicates things when switching components and robots, as the numbers would change drastically.

Maintenance

For a tutorial with more pictures and lengthier discussion, see screen steps live.

Setting Device IDs

For best performance, start allocating device IDs with 1. The ID 0 is reserved for new devices which have not been assigned a number yet.

Talon SRXs have a maximum ID value of 62, but it is generally not recommended to use more than 16.

To set a device ID:

  1. Open a web browser and go to one of the addresses below:
    roboRIO-2537.local
    
    OR
    172.22.11.2
    
  2. On the Home page, select a device on the CAN Network list.
  3. In the device options, change the value of the field Device ID to the desired ID, preferably one that is not currently in use and is in accordance with the I/O sheet.
  4. Press Save in the top menu bar.

Updating Firmware

Whenever FIRST or NI rolls out a new version of firmware for the Talon SRX, PCM, or PDP, the new software will need to be flashed onto the device.

  1. Open the web browser and go to one of the addresses below:
    roboRIO-2537.local
    
    OR
    172.22.11.2
    
  2. On the Home page, select a device on the CAN Network list.
  3. In the device options, select Update Firmware in the lower right corner.
  4. Select the latest version of firmware from the dialog that pops up. The .crf files should be located at
    C:\Users\Public\Documents\FRC
    
  5. Install and flash the device. This should only take ~10 seconds.

Running Diagnostics

The CAN self tests can be used to clear sticky faults, view ports and allocations, and other miscellaneous information.

  1. Open the web browser and go to one of the addresses below:
    roboRIO-2537.local
    
    OR
    172.22.11.2
    
  2. On the Home page, select a device on the CAN Network list.
  3. In the device options, select Self Test in the top menu bar.

Writing Code

In code, a simple access of the CANTalon class:

...
CANTalon egTalon = new CANTalon(1);
egTalon.enableBrakeMode(true);

egTalon.set(.75);

egTalon.stopMotor();

// special methods & functionalities
egTalon.getEncPosition();
egTalon.getEncVelocity();

egTalon.isFwdLimitSwitchClosed();
egTalon.isRevLimitSwitchClosed();


// diagnostics tools
egTalon.getDeviceID();

egTalon.getOutputCurrent();
egTalon.getOutputVoltage();
egTalon.getTemp();

/* There are many more methods in this class. See javadocs. */

...

For the complete documentation, always refer back to the javadocs.

Last modified 6 years ago Last modified on Jan 27, 2015, 3:16:54 PM