Article directory
1. Preliminary preparation
First of all, you need to install the software for making DBC files, and CANdb++ is used here. Since the blogger has just started to learn about automotive electronics, if there are other commonly used software for making DBC files, please leave a message in the comment area.
The second is the message that needs to be made, that is, the communication protocol. Including message name (Msg Name), message ID (Msg ID), message sending type (Msg Send Type), message cycle time (Msg Cycle Time (ms)) message length (Msg Length Byte), signal Name (Signal Name), Signal Description (Signal Description), Arrangement Format (Byte Order), Start Byte (Start Byte), Start Bit (Start Bit), Signal Send Type (Signal Send Type), Signal Length (Bit Length), data type (Data Type), precision (resolution, Resolution), offset (offset), physical maximum value (Singal Value Max (phys)), physical minimum value (Signal Value Min (phys)), bus (Hex) minimum value (Signal Min Value (Hex)), bus maximum value (Signal Value Max (Hex)), initial value (Initial Value (Hex)), unit (Unit), invalid value (Invalid Value ( Hex)) Signal Description (Singal Value Description), etc. Here the blogger simply lists a message by himself.
Msg Name | Msg ID | Msg Send Type | Msg Cycle Time(ms) | Msg Length Byte | Signal Name | Signal Description | Start Byte | Exchange Word | Start Bit | Signal Send Type | Bit Length | Data Type | Resolution | offset | Signal Value Min(phys) | Singal Value Max(phys) | Signal Min Value(Hex) | Signal Value Max(Hex) | Initial Value(Hex) | Unit | Singal Value Description |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CAR | 0x0404 | Cycle | 10 | 8 | Enable | engine enable | 0 | Motorola LSB | 2 | Cycle | 1 | Unsigned | 1 | 0 | 0 | 1 | 0x0 | 0x1 | 0x1 | 0: disable; 1: enable | |
CAR | 0x0404 | Cycle | 10 | 8 | Speed | Engine speed | 2 | Motorola LSB | 16 | Cycle | 16 | Unsigned | 0.25 | 0 | 0 | 16000 | 0x0 | 0x3E80 | 0x0 | rpm |
Second, create a new DBC file
3. Add message (Msg)
After the creation is complete, click "Message" on the left to create a new message.
According to the communication protocol, fill in the relevant information of the message.
其中“Type”有两种,一种是“CAN Standard”,标准的CAN。一种是“CAN Extended”,扩展的CAN。
The ID value range of the standard frame is 0x0~0x7FF, while the ID of the extended frame can be larger. The CAN standard frame and the extended frame are only different in the length of the ID, so as to expand more CAN nodes and better support the upper layer protocol. If the "Type" is selected incorrectly, an error will be reported if the ID exceeds the range.
Among them, DLC (Data Length Code) is the length of the sent message.
The created message is as follows
4. Add the signal
Before introducing how to add signals, first introduce the big and small endian modes and how to create a new value table.
4.1 Big and small endian mode
To put it simply, Intel is a little-endian model (Little-Endian little-endian sequence), and Motorola is a big-endian model (Big-Endian big-endian sequence).
Little endian mode - the low byte is stored in the low address end, the high byte is stored in the high address end
Big endian mode - the low byte is stored in the high address end, the high byte is stored in the low address end
To give a simple example, for example, you need to store 0x12 34 56 78
When storing in big-endian mode , the low byte is placed at the high address, and the high byte is placed at the low address.
0x12 | 0x34 | 0x56 | 0x78 when stored
When storing in little-endian mode , the low byte is placed at the low address, and the high byte is placed at the high address.
0x78 | 0x56 | 0x34 | 0x12 when stored
4.2 Create a value table
The value table is used to indicate the meaning of the median value of the signal. Click "View" and select "Value Tables".
The created value table is as follows
4.3 Adding a signal
Click "Singal" on the left, right-click the blank space on the right, and select "New".
Add signals according to the requirements of the communication protocol. Add a signal description in the "Comment" window.
- Byte Order
This is the arrangement format, there are two types. One is little endian and the other is big endian. Regarding the little-endian mode and the big-endian mode, there will be corresponding supplementary introductions below. - Uint
unit, no need to write - Factor
corresponds to the accuracy and resolution in the communication protocol (Resolution) - Minimum and Maxmum
physical minimum and physical maximum - Value Table
is a table of values used to indicate the meaning of each value. Need to create it yourself.
The created engine enable signal is as follows
The created engine speed signal is as follows
5. Associated signals and messages
After creating the signal and message, you need to add the signal to the message. Click "Message" on the left again. Select "Signal", click "Add" below to add a signal, and add the signal created above.
6. Set the message sending type and period
Double-click to open the newly created message, select the "Attributes" window, and set the sending type and cycle of the message according to the communication protocol.
Seven, edit the communication matrix
- Double-click the created Message (message), select "Layout"
- Click "Add..." to add the signal, and add the signal according to the start byte and start bit specified in the communication protocol