CAN communication in hardware design - use of DSView logic analyzer - CAN waveform test

CAN bus explanation

1. Basic concepts:

** CAN, Controller Area Network, Controller Area Network is a serial data communication bus developed to solve the data exchange between many control parts of the car. **

2. CAN bus level:

The can bus uses differential voltage to transmit data, which are CANH and CANL two buses. The signal level on the bus is divided into the differential voltage between these two wires.
Invisible level: The two lines are about 2.5V when they are static, and the voltage difference is 0. At this time, the state is expressed as logic 1, which is also called recessive.
Visible level: When there is a difference in the voltage value of the two lines, usually CAN_H=3.5V and CAN_L=1.5V, when the voltage difference is 2-3V, the state at this time is expressed as logic 0, also known as dominant.
The logic on the CAN bus is in the form of "wired and", the dominant level can cover the recessive level, so 0 can cover 1.

3. CAN data frame:

CAN communication is carried out through the following five types of frames: data frame (standard format and extended format, two types, divided into: frame start, arbitration segment, control segment, data segment, CRC segment, ACK segment, frame end), remote control frame (standard format and extended format), error frame, overload frame, frame interval
data frame - standard format:
1) start frame: SOF consists of only one dominant bit, marking the data frame and remote frame Initially, the node is allowed to send SOF only when the bus is idle.
2) Identifier: ID information to identify a certain point in the network, the standard frame is 11 bits, and the ID of the extended frame is 29 bits
3) Identifier extension: IDE, IDE bit is dominant, indicating that the data frame is in a standard format; IDE bit It is recessive, indicating that the data frame is in the extended frame format.
4) Remote sending request: The RTR bit must be "dominant" in the data frame, and "recessive" in the remote frame. It is a sign that distinguishes data frames from remote frames.
5) Data field: DLC, data length bits
6) CRC segment: This segment is used to check frame transmission errors, consisting of 15-bit CRC sequence and 1-bit CRC delimiter (bit for separation)
7) ACK Segment: This segment is used to confirm whether it is received normally. The ACK segment is composed of ACK slot (ACK Slot) and ACK delimiter 2 bits. The sending unit ACK segment: sends 2 recessive bits. The receiving unit ACK segment: receives the correct The unit of the message sends a dominant bit in the ACK slot to notify the sending unit that the normal reception is over, which is called sending ACK/returning ACK
8) The end of the frame:End of frame, the frame end segment indicates the end of the frame message, when the last bit of the EOF field is received and all of them are recessive bits, the message is considered valid. A dominant bit in the EOF field will cause the transmitter to repeat the message.
9) Standard frame and extended frame diagram:
insert image description here
insert image description here
insert image description here

4. CAN schematic design:

The single-chip microcomputer leads to the CAN transceiver, and connects to the terminal after passing through the protective device, as shown in the figure below:
insert image description here

5. PCB design:

The CAN differential wiring can control the impedance of 120, or it can not control the impedance. It is enough to thicken the wiring, and do a good job of separating the ground.
insert image description here

6. CAN circuit hardware test waveform:

1) Data received by CAN card:

insert image description here

2) Measure CAN high, CAN low, and CAN differential waveforms through an oscilloscope:

insert image description here
insert image description here
insert image description here
insert image description here

7. View the CAN waveform through the DSView logic analyzer:

1) DSView logic analyzer logic analysis connection:

The ground of channel 0 is connected to GND on the PCB, and channel 0 is connected to CANL, because the decoding of DSView is based on the logical high and low levels, and the change of CANL to ground level "consistent" with the logic.

2) DSView logic analyzer logic analysis settings:

The threshold voltage is set to 2V, the sampling time must be at least longer than the sending cycle, and the sampling frequency is set to the default 500KHz. Then click to start the analysis. After the waveform is obtained, decode it again, as shown in the figure below:
insert image description here

3) CAN waveform decoding:

After the appeal is completed, the following data will appear, corresponding to different data frames. What you can see from here is the same as the data received by the oscilloscope measurement and the CAN card.
insert image description here
insert image description here
insert image description here
The above information is mainly compiled by myself in PCB design and Internet search. If there
is any similarity or error, I hope you will leave a message and correct me, thank you! ! !
insert image description here

Guess you like

Origin blog.csdn.net/weixin_41808082/article/details/129008099