Steps to configure a controller to read and write data via CAN bus, including importing and exporting configuration data using a CAN bus database file.
Exporting CAN Configuration Data
Importing CAN Configuration Data
What is CAN bus?
The Controller Area Network (CAN bus) is a serial communications protocol that efficiently supports distributed real-time control with a high level of security.
Controller Interfaces Options
The Q.station X controller is equipped with one CAN 2.0 port, while the Q.station 101 features two CAN 2.0 ports. Both support baud rates of up to 1 Mbps. Additional CAN ports can be added to the Q.station X via its USB ports using a CAN-to-USB adapter (e.g. PCAN-USB).
Controller Connection Details
Connectors
Q.station 101
On the Q.station 101, the CAN bus is connected to the available screw terminals on the controller.
Q.station X
Q.station X recommended mating connector: LEMO FGG.00.302.CLAD30Z
- Top pin: CAN Low
- Bottom pin: CAN High
PCAN-USB adapter
Connector pin assignment according to specification CiA 106.
D-Sub Connector
Assignment |
Pin |
CAN_V+ (optional) |
1 |
CAN_Low |
2 |
CAN_High |
7 |
CAN_GND |
3, 6 |
Cabling
We recommend using only shielded CAN bus cables, with the shield connected flat to the control cabinet frame. The shield acts as a Faraday cage, protecting the CAN twisted pairs from electrical noise. For effective shielding, it must be connected to an earth (GND) potential.
Gantner offers 2 types of CAN bus cable compatible with the Q.station X.
CAN bus cable with 120 Ω bus termination
- Article no. 603320, 3 m, LEMO to flying leads
CAN bus cable without bus termination
- Article no. 799138: 1 m, LEMO to flying leads
- Article no. 471626: 3 m, LEMO to flying leads
- Article no. 799037: 1 m, LEMO plugs on both sides
Bus Termination
A CAN bus termination (120 Ω each) must be installed at both physical ends of the CAN network. This termination can be implemented using external 120 Ω resistors placed between the CAN High and CAN Low lines at each endpoint.
The CAN port on the Q.station X controller is not internally terminated, allowing it to be daisy-chained with other CAN devices on the network.
The CAN port is located behind the controller’s galvanic isolation. As a result, resistance may be measured across the CAN High and CAN Low pins. This is normal and not indicative of a fault.
Reading CAN Messages
CAN signals are mapped to the controller via virtual variables, allowing for flexible integration and processing.
For importing CAN signals from a DBC file, please refer section Importing CAN Configuration Data.
-
Right-click Virtual variables and select Add > Append variables.
-
Enter the number of new variables to create and select OK.
-
Double-click the newly created variable to open the Variable settings. Enter the desired name and change the Type to Remote and Remote type to CAN.
-
In the Remote settings, select the Port and enter the CAN channel information.
Port
CAN 1 is the onboard CAN interface of the Q.station X (additional CAN interfaces can be connected via USB).
ID
The base ID is max. 11 bit (Hex 7FF), and the extended ID is max. 29 bit (Hex 1FFFFFFF).
Data format
Defines the format of the data in the CAN message, this has to be a valid format to interpret the data correctly.
Data bit start
A CAN frame consists of max. 64-bit of data and can include multiple CAN messages (for example, 2x 8-bit, 1x 16-bit, and 1x 32-bit messages), with this parameter the start bit of the message to read into the CAN frame is defined.
Data bit length
The maximum bit length of a CAN message is defined by the selected CAN data format but can also be less, for example: if the CAN data format is 16-bit, and the bit length is only 5, the missing bits will internally be filled up, or cut off to be able to convert it correctly.
Data byte order
The standard byte order of a CAN message is Little-endian (Intel), to switch the byte order select Big-endian (Motorola).
-
When complete, click OK. Make sure to write any changes to the controller by clicking Write in the Configuration toolbar.
Writing CAN Messages
- In GI.bench, right-click on the controller and go to Edit > Edit CAN Variables.
-
The following window will open. Here, you can choose whether the available variables should be written to one or, if multiple are available, several CAN interfaces.
The Name and CAN ID can be freely assigned. Note that names are limited to 20 characters or fewer. The data type can be selected either to match the requirements of the receiving device or to minimize data size, allowing more channels to be transmitted over the CAN interface.
Caution: The Minimum and Maximum values apply to the unscaled raw value of the selected data type. For example, if the Maximum is set to 1000 and a scaling factor of 0.1 is applied, the channel will only display values up to 100. Note that adjusting the scaling does not automatically update the Minimum and Maximum values. This can result in values being clipped due to an unintentionally restricted range. -
Navigating the CAN Variable Settings window:
Using the mouse:
- The first click selects a cell.
- The second click either opens the dialog or checks the selected cell(s).
- Shift + Click allows you to select multiple cells.
Using the keyboard:
- Use the arrow keys to navigate between cells.
- Press Enter to open the dialog or check the selected cell(s).
- Use Shift + Arrow keys to select multiple cells.
- If multiple cells are selected in the same column, you can move the selection horizontally across columns using the left and right arrow keys.
Example: The CAN Variable Settings window displays the structure of the CAN IDs and highlights potential issues such as overlaps:
Multiplexed channels can also be visualized in the overview:
- Configuring CAN outputs does not increase the number of variables in your controller.
- Creating a .DBC file will include the CAN outputs defined in this interface.
Exporting CAN Configuration Data
The CAN configuration can be exported as a .DBC file for import into an external device. All CAN inputs and outputs, whether remote variables or configured through the CAN variable settings interface, will be included in the .DBC file.
-
Highlight the controller and click Export.
-
Select CAN DBC file from the list and click OK.
Choosing the (only ouput variables) Option will only list CAN variables which are written to the CAN bus by the Q.station. The CAN DBC File option will list inputs and outputs.
-
Provide the DBC file name and save it at the desired location.
Importing CAN Configuration Data
-
Highlight the controller in the project window and click Import.
-
Select CAN DBC file from the list and click OK.
-
Click the three dots icon at the top-right corner to select a DBC file to import.
-
Select the CAN signals to import (use Ctrl + click for multi-selection).
-
The variables will be automatically added as Remote CAN virtual variables.
If the imported signal names exceed 20 characters, the user can choose to cut from the left, from the right, or not cut the name when creating CAN channels.