Home Technology Smart Display SmartDisplay Custom CAN protocol Introduction

SmartDisplay Custom CAN protocol Introduction

Preface

SmartDisplay currently supports the CANbus hardware communication interface and uses the CANopen software communication protocol. CANopen is a widely used industrial standard communication protocol based on the CAN bus, and is used in various fields such as medical equipment, vehicles, railway applications, or building automation. However, when using the CANopen protocol, as it is a communication between nodes, the client needs to implement the protocol on its host side, which may be a burden for those who want to simply use the CANbus. Therefore, to simplify the client's usage, we have designed a new Custom CAN protocol, which does not require the client to implement the CANopen protocol. Instead, it only needs to set up the data through a custom DBC file, easily linking the CAN ID/data with the Widget on the display, thus realizing real-time interaction. This interaction method can help the client better understand and control the data in the system, and achieve high flexibility and convenient maintenance.

Introduction

The main function of the Custom CAN protocol is to connect the CAN ID/data with the widgets on the displayer through the use of a DBC (CAN Database) file. The DBC file is an important data that defines the relevant information, such as the CAN ID and message format decoding, in the system. By using a user defined DBC file, it becomes easier to associate different CAN ID/data with the widgets on the displayer, enabling real-time interaction. For example, graphics or text on the displayer can be controlled through the CAN ID/data, and buttons or sliders on the displayer can be used to control the CAN data. This interaction helps the customers to better understand and control the data in the system, resulting in a flexible and maintenance-friendly solution.

DBC file Introduction

The DBC file is usually an ASCII plain text file that contains information about the physical signals transmitted on the CAN bus, including the CAN ID, name, scale ratio, and definition of the signal. The file is used to decode raw CAN data into meaningful values and map different CAN IDs to their corresponding signals. The DBC file provides the information needed to convert CAN message payloads into physical signal values.

Raw CAN Data Testing Data Example

raw-can-data-testing-data-example01

If you have a CAN DBC file and this file includes the decoding rules set for this CAN Id (0x181), you can decode the following information from the information in the DBC file.

raw-can-data-testing-data-example02

The main function of the DBC file is to describe the rules for decoding CAN messages and signals.
The following is a test data description excerpted from a DBC file

test-data-description-excerpted-from-dbc-file01

Based on the information from the DBC file excerpt, the following decoded information can be obtained:

test-data-description-excerpted-from-dbc-file02

From the above decoding rule setting, the previously obtained Raw CAN Data can be decoded into the following information.

test-data-description-excerpted-from-dbc-file03

With the above explanation, with the DBC file setting, we can correctly decode the actual values represented by the CAN ID and CAN Data. The DBC file contains the message and signal layout, which can parse the data and convert the raw data into physical values, allowing the system to understand the real message transmitted through CAN.

DBC Editor
A DBC file is typically an ASCII text file that contains information about physical signals transmitted on a CAN bus. These files are difficult to read and edit due to their formatting, but there are many DBC editor software available to address this issue. One commonly used DBC editor is Vector CANdb++ developed by Vector Informatik GmbH. This software helps users create and edit custom DBC files with ease. It provides a user-friendly interface for adding messages, signals, defining message and signal attributes such as message ID, start bit, length, scale, offset, etc.

dbc-editor

SmartDisplay GUI Builder – Explanation of Custom CAN Configuration

SmartDisplay GUI Builder provides you with an intuitive and user-friendly interface to easily create your own custom CAN projects. You just need to import your DBC file and map the signals/messages to the corresponding widgets and you will be able to display and interact with the widget on your SmartDisplay device. The operation is simple and flexible, satisfying your various needs and making your work more efficient. The following will introduce, step by step, how the SmartDisplay GUI Builder creates a Custom CAN project and sets the relationship between DBC and Widget.

● Create Custom CAN project
To create a Custom CAN project, input the project name, select the SmartDisplay device type, and under the protocol section, select Custom CAN ID (CANbus).

create-custom-can-project

● Import custom DBC File

import-custom-dbc-file

● Add Gauge and Horizontal Slider widget in the main page
Select the Gauge object and in the Gauge property page, set the Message to EEC1 and the Signal to EngSpeed in the CAN Signal field, indicating that this Gauge object is binding to EngSpeed. The display change of this Gauge object is from the EngSpeed value.

add-gauge-and-horizontal-slider-widget-in-the-main-page

Select the Horizontal Slider object, and in the Horizontal Slider property page, in the CAN Signal field, set the Message to HorizontalSliderMessage and the Signal to HorizontalSliderSignal1, representing the relationship between this Horizontal Slider object and HorizontalSliderSignal1. The change in the display of this Gauge object is derived from the value of HorizontalSliderSignal1.

add-gauge-and-horizontal-slider-widget-in-the-main-page02

● Simulate the interaction between CAN ID / CAN Data and Widget
Click icon:"Simulator With GUI" to start Simulator.

add-gauge-and-horizontal-slider-widget-in-the-main-page03

After launching the simulator, you can drag the EngSpeed slider at the bottom to simulate the Host sending EngSpeed data. Observe the change in the Gauge on the simulator and also view the changes in CAN ID and CAN Data from the Message Log on the right. You can also operate the Horizontal Slider on the simulator to simulate the data sent by the Device.

add-gauge-and-horizontal-slider-widget-in-the-main-page04

● Update SmartDisplay device setting.
After verifying the function through the simulator, if there are no problems, you can connect to the device and upload the project settings to the SmartDisplay device.

add-gauge-and-horizontal-slider-widget-in-the-main-page05

Wait for the upload and update to finish.

add-gauge-and-horizontal-slider-widget-in-the-main-page06

● Verify the interaction between the Device CAN ID/CAN Data and the Widget.
After uploading the project to the device side, you can verify the functionality of the SmartDisplay device. Connect to the device side using the GUI Builder, then click "Test Device" to test the interaction between the host and device side.

verify-data-and-the-widget

Test Device Window

Through this test window, you can simulate the host sending the corresponding CAN ID and CAN Data according to the DBC configuration. Pull down the EngSpeed slider to simulate the host sending the EngSpeed data, observe the change of the device gauge, and also see the change of the CAN ID and CAN Data from the Message Log on the right. You can also operate the device's Horizontal Slider to verify whether the data sent by the device meets the requirements.

test-device-window

Actual display of the SmartDisplay device

actual-display-of-the-smartdisplay-device

Custom CAN command introduction

The following will describe the command protocol used by Custom CAN. Through these commands, the Host device can easily control the SmartDisplay, including switching pages, adjusting the brightness, or making the buzzer emit sound.

The following are the CAN ID settings used by the command protocol:

  • CAN Id format:29 bit
    CAN Id:0xEF0000 + 0x7B00 (default channel id. This can be modified through the GUI Builder.)

The following table is the basic data format of Send Command

Header Byte (1 Byte) Length (1 Byte) Payload (N byte) CRC (2 Byte)
Fixed value:0x53 (S) Value = 4 + Payload length
Payload max size: 250
For data content and length, please refer to Send Command Payload Modbus CRC16
 

The following table is the basic data format of Response Command

Header Byte (1 Byte) Length (1 Byte) Payload (N byte) CRC (2 Byte)
Fixed value:0x52 (R) Value = 4 + Payload length
Payload max size: 250
For data content and length, please refer Response Command Payload Modbus CRC16
 

● Command Payload
The following is the explanation of each command payload.

  • Set Brightness:0x6
    Send Command
Command Code 1 Byte 0x6
Brightnes 1 Byte Brightness value
 

Response command

Command Code 1 Byte 0x6
Error Code 1 Byte 0:Success
1:Failed
  • Set Buzzer: 0x7
    Send Command
Command Code 1 Byte 0x7
Cycle 1 Byte Cycle value
High 1 Byte High value
Low 1 Byte Low value
 

Response command

Command Code 1 Byte 0x7
Error Code 1 Byte 0:Success
1:Failed
  • Set Page Index:0x8
    Send Command
Command Code 1 Byte 0x8
Page Index 1 Byte Page Index value
 

Response command

Command Code 1 Byte 0x8
Error Code 1 Byte 0:Success
1:Failed
  • Get Page Count: 0xA
    Send Command
Command Code 1 Byte 0xA
 

Response command

Command Code 1 Byte 0xA
Error Code 1 Byte 0:Success
1:Failed
High 1 Byte Page Count value
  • Get Current Page Index:0xF
    Send Command
Command Code 1 Byte 0xF
 

Response command

Command Code 1 Byte 0xF
Error Code 1 Byte 0:Success
1:Failed
Page Index 1 Byte Page Index value
  • Set Device State:0x20
    Send Command
Command Code 1 Byte 0x20
Device State 1 Byte 0: ConfigMode
1: DisplayMode
 

Response command

Command Code 1 Byte 0x20
Error Code 1 Byte 0:Success
1:Failed

● Transmission example
  • Set brightness to 90

transmission-example-set-brightness-to-90

  • Switch Page Index to 1.

When switching page, you need to first set the Device State to ConfigMode, and then send the page switching command. After the page switching command is completed, set the Device State to Display Mode again to complete the page switching command. The command sequence is as follows:

transmission-example-switch-page-index-to-1

Conclusion

With the Custom CAN protocol, customers can freely and unrestrictedly define the setting of CAN ID and CAN Data through the standard DBC file. Then, with the SmartDisplay GUI Builder, they can bind the relationship between the Message/Signal and Widget. It's that simple, a custom CAN HMI is done. No complex CAN protocols (such as CANopen, J1939...) or settings are needed for seamless integration with the SmartDisplay Device. Are you impressed? Hurry up and download the SmartDisplay GUI Builder. Before purchasing the SmartDisplay, you can try out the simulator to confirm if it meets your needs!

Back to List
go top
close