The can bus and AT command.
Overview
The goal is to hook up CAN devices and analyze the data, aiming to create a functioning demonstrator, such as an automotive dash instrumentation. The challenge lies in the complexity of the CAN bus and the lack of support for many Chinese-manufactured components.
Key Points
- CAN bus consists of two wires: CAN_H and CAN_L for bi-directional data transmission.
- Communication speed ranges from 50 Kbps to 1 Mbps.
- Distance can range from 40 meters at 1 Mbps to 1000 meters at 50 kbps.
- CAN messages contain an identifier (CAN ID) and data.
- Identifier length can be 11 or 29 bits.
- Data size can be from 0 to 8 bytes.
- CAN_H and CAN_L act as a differential line.
- A 120-ohm resistor is used at the ends of the CAN network.
Comparison of CAN over SPI & I2C
| Parameter | SPI | I2C | CAN | |-----------|-----|-----|-----| | Speed | 3Mbps to 10Mbps | Standard: 100Kbps, Fast: 400 Kbps, Highspeed: 3.4Mbps | 10KBps to 1MBps (depends on wire length) | | Type | Synchronous | Synchronous | Asynchronous | | Number of Wires | 3+ (MISO, MOSI, SCK, SS1, SS2…SS(n)) | 2 wires (SDA, SCL) | 2 wires (CAN_H, CAN_L) | | Duplex | Full Duplex | Half Duplex | Half Duplex |
CAN Protocol Applications
- Automotive
- Industrial machines
- Agriculture
- Medical Equipment
Problem
- Lack of support and instructions for Chinese-manufactured CAN components.
- Difficulty in getting devices to come online and communicate.
- Need for a common language and interface UI.
Solution
- Use standardized higher layer protocols such as CANopen, DeviceNet, and SAE J1939.
- Utilize devices from reliable manufacturers like KVASER and PEAK.
- Use software from resources like https://www.csselectronics.com/ for better understanding and development.
Parts
- KVASER Leaf Light HS V2 CAN Bus Network USB D-Sub KV-00685-0 Interface semipro (expensive, found used)
- i-PCAN USB to CAN Adapter Compatible Original PEAK IPEH-002022 Support INCA (cheap working clone)
Steps
1. Purchase reliable CAN bus devices. 2. Develop a touch screen interface using compatible software. 3. Ensure a complete system that can receive data, display it, and respond with adjustments.
Notes
- The CAN standard does not specify how to handle messages larger than 8 bytes or how to decode raw data.
- Higher layer protocols like OBD2, CANopen, and J1939 are based on the CAN standard.
- A twisted pair cable is used for CAN communication.
- The CAN signal is represented by the potential difference between CAN_H and CAN_L.
- The line needs to be balanced and tied to the same potential, typically with a 120-ohm resistor at the ends.