As engineers, we often like to see a piece of hardware work straight out of the box. This gives us that warm fuzzy feeling that we are starting development on a stable platform. We also like to prove that a unit is behaving properly when a previously working system starts acting odd. In both these cases, a simple loopback test to verify the hardware is still able to transmit and receive messages is a good place to start.
On a CAN HS (High Speed) network, you cannot just send a write command or receive command to the CAN interface. CAN requires the network to have at least two active nodes for successful communication. Otherwise, when the node transmits a message, the node does not receive an ACK frame. This will cause the node to generate an ERROR frame and then retransmit the message. This process will continue until the node reaches an Error Passive state.
CAN HS also requires that these nodes be connected on a properly terminated bus. This means 120 Ohm terminating resistor between CAN_H and CAN_L at the furthest points of the network backbone. This yields a measured resistance between CAN_H and CAN_L of 60 Ohms. If the bus is not properly terminated, reflection issues may arise interfering with transmission – especially at higher bit rates.
The Kvaser T-cannector v2 provides a quick CAN bus with proper termination so you do not need to create any special cables to test the Kvaser unit straight out of the box. When diagnosing an existing system, the Kvaser T-cannector v2 removes any of the system’s cabling from the test path in case this cabling has developed shorts or a terminator has failed.
To drive the test, Kvaser CanKing will transmit and receive the messages on the CAN bus. This prevents the need to create software before using the Kvaser unit. This also removes the system software application as a possible problem source when testing the hardware.
To perform the loopback test, you will need the following:
Two Kvaser HS channels. These channels can be on a single device like an USBcan Light 2xHS or you can have two Leaf Light v2 units attached to the same PC.
The following steps will walk you through the loopback test:
Connect the Kvaser unit(s) to the PC.
Connect the Kvaser unit’s male CAN connectors to the Kvaser T-cannector’s female CAN connectors. You will need at least two physical channels connected.
Set the Kvaser T-cannector’s terminator setting to 60 Ohms.
On the PC, launch the Kvaser CanKing application. Press the OK button on the Create a New Project Using Dialog with the Template radio button lit.
In the Templates dialog, choose the CAN Kingdom (2 channels) template and press the OK button. CanKing will now be displaying five windows: CanKing menu bar, CAN 1, CAN 2, Select Formatters, and the Output window.
The CAN 1 and CAN 2 windows show the channel associated with the window on the Bus Statistics tab in the Bus Parameters group. If the channels shown do not match the channels you attached to the Kvaser T-cannector, press the Bus Parameters tab for the CAN window. Use the CAN Channel drop down list to select the appropriate channel and press the Apply button. Then press the Bus Statistics tab.
Once you have both CAN windows set to the appropriate channel, press the CanKing Menu bar Play button. This will bring both channels bus on.
In the CanKing Menu bar, select the Messages -> Universal -> Universal menu item. This will open up the CAN Message window.
Enter the desired CAN identifier, a data length code (DLC), and the byte data values. A ‘$’ in front of the number means you are enter the value in hexadecimal instead of decimal. A ‘x’ after the identifier value means you wish to send a 29 bit identifier instead of an 11 bit identifier.
Press the CAN Message window Send button to transmit a message on the bus. You should see the message appear in the Output window twice – once where the message was transmitted on CAN 1 and once where the message was received on CAN 2.
You have now completed a simple loopback test. Some additional things you can do are:
Use the CAN Message Channel drop down list to choose which channel performs the transmission. This way you can test transmitting and receiving of both channels.
Use the CanKing Menu bar Messages -> Universal -> Traffic generator menu item to open the Traffic generator window. This window allows you to stress the channels but putting out bursts of messages or continuous random messages.
Use the Bus Parameters tab of the CAN windows to change the bit rate used. By default, the channels will be set to 250 kbits/s. You can move the bit rate up or down to match the bit rate used in your system. Don’t forget to press the Stop button before changing bit rates. And make sure you change the bit rate settings for both channels before going back on bus. The channels will not communicate if you have them set to two different bit rates and plugged into the same CAN bus.