In this tutorial we explain how to configure your Jaguar motor controllers for use in CAN mode, an advanced way to communicate with your motor controllers. We cover creating your cables and re-flashing the Jaguar firmware. These are the procedures and methods we followed to create our wiring for the 2011 season. We had zero issues/problems with our CAN wiring throughout the entire season (2 Regional competitions, 3 off season competitions, an numerous demonstration events).
What is CAN?
CAN stands for Controller Area Network and is an industry standard protocol to allow devices to communicate with one another. CAN is most commonly found on devices and sensors used in the automotive industry. CAN devices are connected to one another through a bus in a daisy chained fassion, which means each device on the CAN bus is wired sequentially to one another. Since all the devices are talking over the same wires, each devices on the bus must have a unique identification number.
For more background information on CAN click here.
CAN Vs. PWM:
The first difference between CAN and PWM is the wiring. This might seem obvious, but it's an important point to consider when deciding which mode of operation will work best for your team. All teams are familiar with PWM wiring. In this mode all motor controllers require a PWM cable to be run to them from the digital side car. Using CAN can greatly simplify this wiring since each device is linked to the next in line, only one chain of cables needs to be created. Wires only need to be as long as the next device in the chain. This can reduce the rats next of cables around the digital side car significantly.
In addition to simplifying wiring layout, creating the cables is also MUCH simpler with CAN. CAN cables are made with standard phone jacks and phone cables. You can literally create a new CAN cable in under a minute. No more splicing together PWM cables to get one long enough to fit your needs. CAN cables are also more reliable, they WILL NOT PULL OUT. When was the last time the cable on your house phone randomly pulled out or didn't seat correctly? Wiring with CAN is a wire-once and forget-it kind of operation. No more checking every PWM cable is seated before each match!
Besides wiring differences, there are a number of advantages to using the Jaguars in CAN mode as it makes a number of powerful software features available to you. It does not however change the output response of the Jaguar. In general, using the Jag in CAN or PWM mode will result in the same performance of the motor controller. CAN mode will make more features available on the software side of things.
When using a Jaguar over CAN you have the following modes of operation available to you:
- Voltage Control Mode
- Speed Control Mode
- Position Control Mode
- Current Control Mode
When controlling a Jaguar through Pulse Width Modulation you're able to manipulate its speed and direction through a PWM signal. In this mode of operation the motor controller outputs a percentage of its available input voltage to the motor. This controls the speed of the motor. The polatiry of that voltage determines whether the motor spins forward or reverse. A comparable mode of operation is available on the Jags in CAN mode. It is called Voltage Control Mode, or Percent VBus mode in LabVIEW. In this mode of operation the Jaguar takes an input from 1.0 to -1.0 similar to when it is controlled through PWM. This is the simplest mode of operation and should only require modification to initialization code.
The Jag can also locally implement closed loop control through CAN in Speed and Position control modes. In these modes, a closed loop controller is implemented directly on the Jaguar. No closed loop control need be implemented on the cRIO. In these modes position sensors need to be wired directly to the Jaguar. Wiring for both a potentiometer and quadrature encoder are shown shown in the figure below. Note: both types are shown wired, but only one type of sensor can be used at a time.
Figure 1 - External Sensors for Closed Loop Control
To use these modes the Jaguar needs to be initialized in either Speed or Position control mode, told wether a position sensor is connected, told the calibration values for that position sensor (e.g. ticks/revolution), and the PID gains for the closed loop control.
The last mode of operation is the Current Control Mode. In this mode the Jaguar will target a specific current value using its internal current sensor. No additional sensors or wiring are required to support this mode of operation. TIs manual states that small DC motors may not be suitable for use in this mode of operation. TIs datasheet states that the current sensor within the black Jag is accurate to ±1 A when motor current is ≥ 8A, and is accurate to ±2A when motor current is < 8A. The black Jaguar can supply 40A continuous max, 60A for 2 seconds, and 100A peak. The Internal PID controller will be utilized in this mode to target a commanded current value.
Note: If you plan to use the Jag in a closed loop control mode please make sure you set asside ample time to test and debug this functionality. Have a fall back plan ready!
Ordering Parts Required:
The parts required to make these cables are very common. You should be able to purchase these parts at your favorite electrical component supplier. Where possible, we have provided links to the monoprice parts which we use for our wiring. We've chosen monoprice for our cabling as they have the best prices on the components required without sacrificing quality. Do your research and planning before you buy to verify the parts you order will fit your teams needs. If you have found other options please share your findings in the comments below.
Bill of materials:
Our order from monoprice consisted of the following:
Item Description Link Qty Unit Price ($)
4 conductor phone cable (50ft) (monoprice) 1x 1.82
6p6c phone Jacks (50 count) (monoprice) 1x 1.76
DB9 to RJ12 modular adapter (monoprice) 2x 0.62
Ratchet Type Crimpers (monoprice) 1x 13.83
USB to Serial Adapter (monoprice) 1x 5.54
Total: 24.19 + S&H
Note: 6 conductor phone cable will also work fine but is not required to make any of the cables.
You will also need to purchase a few 100Ω resistors. If you're not already placing an order with an electronics supplier, radioshack is probably your best bet.
Adjust the quantities listed to fit your teams need. This is what we ordered for our 2011 robot and this was more than enough to wire up one robot.
Figure 2 - CAN Wiring
There are a few different cables that need to be made.
- DB9 (serial) to RJ12 cable (with terminating resistor)
- Jumper cables to go between the Jaguars
- Terminating resistor
1. Creating the DB9 to RJ12 Cable:
- Pin 2 on the DB9 to pin 6 on the RJ12 connector
- Pin 3 on the DB9 to pin 1 on the RJ12 connector
- Pin 5 on the DB9 to pin 5 on the RJ12 connector
- 100Ω resistor leg1 to pin 3 on the RJ12 connector
- 100Ω resistor leg2 to pin 4 on the RJ12 connector
This configuration will connect the computer's serial communication lines to the Jaguars serial communication lines (the outside pair on the Jag's right hand connector). Since this will be the first device on the CAN bus, we need a terminating resistor added across the Jaguar CANH and CANL pins.
This first cable is the most important and most involved. All the others are quite simple. Take your time making this cable and double check all your connections.
2. Creating the jumper cables:
If you are connecting more than one Jag to the bus, you'll need to link the devices together as shown in Figure 2. The cable required to do so is a straight through cable shown in Figure 4.
Figure 4 - CAN Jumper Cable
Only 4 conductors are required for these cables since the serial communications, on pins 1 and 6, are not carried between Jags. The following pinout can be followed to create the jumper cables:
- Pin 2 to Pin 2
- Pin 3 to Pin 3
- Pin 4 to Pin 4
- Pin 5 to Pin 5
3. Creating the terminating resistor:
The final part that needs to be made is the terminating resistor. Simply connect a 100Ω resistor to a phone jack, across the middle two pins - 3 and 4. We have found that crimping directly to the resistor legs can create unreliable conenctions and in some cases the resistors legs can short after the crimp is made. We like to solder wire to the ends of the resistor, and crimp the connector to the wires. After testing it we coat the whole thing in hot glue for strain relief. If the diameter of the resistor leads are sufficiently small enough this step may not be necessary.
The following resources may be helpful in describing how to make the wiring:
Flashing the Jags:
Flashing the JAGs needs to be done from a computer over a serial connection. Most computers no longer have a serial (DB9) connector on them, so you may require an older computer or a USB to serial adapter (see the bill of materials above).
After you create your wiring you will need to re-flash all the Jaguar motor cntrollers you wish to use over CAN.
Flashing should be done with the BDC-COMM utility from TI. You will also need the latest firmwares for the Jags you are flashing (Black and Tan jags require different firmwares). Firmware revision 92 is the latest official version on TIs website. This is the firmware from the 2011 season. Expect a new release for the 2012 season as beta test teams were testing revision 93. Both BDC-COMM and firmwares are available from the TI website. Links are located in the "Related Products" > "TI Software" section. A mirror of the files is available here - BDC_COMM: (v92), Firmware: (v92).
To reflash your Jaguar
Note: Stay clear of the no-name serial to USB adapters on ebay. We've spent hours trying to figure out what was wrong with our Jags only to find out it was a faulty RS232 adapter. The drivers for these components are usually unreliable. It's not worth the few $ saved. This one from monoprice works reliably and is around the same price point as the cheapies. Also, if you plan to use the adapter with Windows 7, make sure reliable drivers are available or have an XP machine ready to fall back to.
FIRST Team 2168 has made an effort over the past few years to identify and debug issues that our team and others have had with Jaguars and CAN. If you're having trouble getting things to work, using the following steps will help localize and ultimately solve CAN problems. Note: This section is actively being developed.
Not sure if your USB to RS232 adapter is working?
- Run a loopback test. This will verify that your adapter, drivers, and OS are all playing nice. This is done by conencting the RX and TX lines to one another and having the computer transmit data onto the COM port.
- Expect reliability issues when using off brand USB to RS232 adapters with Windows Vista and 7. Your best bet is to try to get things working in XP first, preferrably on a computer which has a serial port built in.
When connected to the Jaguar(s), the Jaguar status light flashes yellow (can't establish communications)
- Verify your CAN cables are made correctly.
- You should be able to hold two ends next to each other and see a mirrored wire pattern.
- All metal contacts on a cable end should be crimpped such that they are fully depressed into the conductors. If you inspect closely, you should be able to see little metal spikes piercing each wire's conductor.
- Verify your USB to Serial Adapter is made correctly
- Verify your terminating resistor is made correctly
- Measure 100 ohms across the two middle pins on the phone jack.
- Verify you're plugged into the left connector (labeled IOIO) on the first Jaguar in the chain
- Verify pins 1 and 6 in the left connector (labeled IOIO) are not damaged on the first Jaguar in the chain.
When connected to multiple Jaguars, one or more (not all) Jag status lights flash yellow
- Verify the wiring immediately before the Jaguar in the chain thats not communicating is correct
- Verify the connectors on the offending Jag are not defective
- Verify the connectors on the upstream Jag are not defective.
Every other Jaguar status light flashes yellow
- CAN Cables are made backwards. CAN Cables must match Figure 4.
Jaguar status light flashes Red regardless of command issued
- The Jaguar is in a faulted condition. RMA the Jaguar if possible.
If these steps don't work for you, or you have a suggestion to make this guide better, please don't hesitate to contact us.
- FIRST Team 348s CAN guide - this is another great resource to use when getting started with CAN on the Jags
- Texas Instruments site for the Black Jaguar - links to documentation, firmware, and BDC-COMM
- Texas Instruments site for the Tan Jaguar