Frequently Asked Question

Video: 7.3. CAN bus
Last Updated 2 years ago


Press "Ctrl + F" to find the keyword of your interest.

If you wish to have a direct link access to the video timestamps, please follow these instructions.

Found this video helpful? Why not take the whole HIL Specialist course? A Certificate is waiting for you for free at HIL Academy.

Would you or your organization benefit from having these videos narrated in your native language? Contact us and let us know if you wish to contribute.

TRANSCRIPT

00:00:02

Hello everyone! In this lesson, we will be looking at how to implement the CAN  

00:00:06

bus protocol in the Typhoon HIL toolchain.You can see how this component fits into  

00:00:11

the family of available components in the Typhoon HIL toolchain here.  

00:00:15

For this lesson, we will focus exclusively on CAN Setup, Send, and Receive components, as other CAN  

00:00:21

components feature similar configurations.CAN bus stands for Controller Area Network  

00:00:26

protocol. It is a bidirectional serial bus communication method that allows electronic  

00:00:31

subsystems to be linked together and interact within a network. At the physical layer,  

00:00:36

it uses differential transmission on a twisted-pair wire, also known as a two-wire. 

00:00:42

CAN is a multi-master protocol, which means that any node can initiate communication in  

00:00:46

the network. Finally, to be able to communicate, each node in the network  

00:00:51

must operate in the same bitrate and at least two nodes or more must be present in  

00:00:55

the network so that it can work properly.CAN bus messages are small (at most eight  

00:00:59

data bytes) and are protected by a checksum.There is no explicit address in the messages.  

00:01:05

Instead, each message carries a numeric value ID which controls its priority on the bus and  

00:01:10

may also serve as an identification of the contents of the message. 

00:01:14

Two standards are defined for CAN bus message specification:  

00:01:18

CAN 2.0A, which has an 11-bit identifier, and CAN 2.0B, which has a 29-bit identifier. 

00:01:25

Only HIL devices with dedicated CAN controller hardware can implement CAN bus communication.  

00:01:30

These are currently HIL404, 604, and 606 devices. Each of these has two CAN controllers embedded  

00:01:38

that can be physically accessed through standard 9 pin D-sub connector in the back of HIL device.  

00:01:43

Both CAN 2.0A and CAN 2.0B standards are supported here.  

00:01:47

Also, it is important to mention that handling of Remote frames is currently not supported. 

00:01:52

Now let s look at some of the components that comprise the CAN communication protocol in  

00:01:56

the Typhoon HIL Control Center toolchain.The first component is CAN setup. It can be  

00:02:02

found under the Communication section of the Library Explorer, inside the CAN bus  

00:02:06

section. This block is used to configure the CAN controllers settings for the chosen HIL device.  

00:02:12

Exactly one CAN setup component must exist in the model when using CAN protocol. 

00:02:17

If you double click on the component, it opens the properties window shown here. From this  

00:02:22

dialog window you can specify the baud rate and the execution rate for each CAN controller. 

00:02:27

Once our setup is configured, we can focus on the messages we want to send with specific CAN  

00:02:32

controllers. For this, we use the CAN send component. By opening the properties window,  

00:02:38

we can choose which controller to use. We can also specify the data input to the component: either  

00:02:43

the dialog window here or an imported DBC file.If we chose Dialog window as our data input,  

00:02:50

we can also specify the message ID, the standard to follow, the message length  

00:02:54

and how it is going to be transmitted (on event or on timer). Additionally, we can define our  

00:03:00

messages manually by clicking the add symbol button at the bottom of the properties window.  

00:03:04

Here we can define the name, length, byte order, data type, scale, offset,  

00:03:10

and other options about the message specification. Once the messages are fully defined, we can click  

00:03:16

the refresh button and it will show all messages defined in the signal information block. 

00:03:24

The CAN receive component is similar to the CAN send component.  

00:03:28

In order to receive a message and unpack it correctly, it is important to specify  

00:03:32

it properly in the signal information section of the property s windows. 

00:03:44

Instead of defining the messages manually, both CAN Send and CAN Receive components can import  

00:03:49

DBC files to define the messages. The process of defining messages through DBC files is the  

00:03:55

same for both components, so let s look at how to implement it using a Send component. 

00:04:00

The DBC file type is primarily associated with CANdb by Vector Informatik GmbH.  

00:04:06

The file name extension .DBC is used to store all information that describes the network. 

00:04:11

To load a DBC file, we must choose CANdb file for the Data input property and navigate to the  

00:04:17

desired file using the Import DBC file button. If the file is parsed correctly, the Choose  

00:04:23

message combo box will be automatically populated with the message names from the file. Choosing  

00:04:28

different messages will change the message and signal parameters in the dialog as shown here. 

00:04:33

A loopback test is a useful way to check that a system and its  

00:04:36

data transmission hardware is working. For a controller area network linked to a device,  

00:04:42

a message loopback to the same test device is simple to achieve if it has two CAN adapters,  

00:04:46

as is the case for HIL404, 602+, and 604. Here you can see how to wire two CAN adapters in the HIL  

00:04:54

device in order to perform a loopback from CAN adapter 1 to CAN adapter 2 and vice-versa. 

00:04:59

At its simplest, CAN bus wiring is very straightforward.  

00:05:02

It is a case of joining the two CAN wires from each adapter together correctly. The CAN high  

00:05:07

data line from one CAN adapter is connected to the CAN high data line of the next CAN adapter,  

00:05:12

and likewise for the CAN low data line.The basic CAN wiring for a DB9 connector is  

00:05:18

to join pins 7 together, transmitting CAN high, and pins 2 together, transmitting CAN low. For  

00:05:24

bench testing low baud rate CAN buses, the network will usually work without a termination resistor  

00:05:29

at 100k baud or less. However, for higher speed networks and long cables, a 120-ohm termination  

00:05:36

resistor is required at each end of the CAN bus, wired between the CAN high and CAN low lines. 

00:05:41

With this we conclude our introduction to CAN bus protocol in the Typhoon HIL toolchain.  

00:05:46

In the next lesson, we will be looking at some practical applications through  

00:05:50

the demonstration of a multi-protocol gateway.

Please Wait!

Please wait... it will take a second!