SAE J1939 is a standardized communication protocol widely used in heavy-duty vehicles, such as trucks, buses, and agricultural machinery. It operates over a Controller Area Network (CAN) bus, enabling seamless communication between various Electronic Control Units (ECUs). This protocol is essential for networking, diagnostics, and data exchange in modern vehicles, ensuring interoperability between components from different manufacturers.
SAE J1939 uses the CAN bus physical layer, which typically connects to a 9-pin Deutsch connector (commonly used in heavy-duty vehicles). Below is the pinout for the Deutsch connector:
Pin | Signal | Description |
---|---|---|
1 | Ground (GND) | Ground connection for the CAN bus |
2 | CAN_L | CAN Low signal |
3 | Shield | Shielding for noise reduction |
4 | Battery (+) | Positive power supply |
5 | CAN_H | CAN High signal |
6 | Reserved | Reserved for future use |
7 | CAN Termination | Optional termination resistor connection |
8 | Key Switch Power | Power controlled by the ignition switch |
9 | Reserved | Reserved for future use |
Below is an example of how to use an Arduino UNO with an MCP2515 CAN module to communicate using SAE J1939:
#include <SPI.h>
#include <mcp_can.h>
// Define the SPI CS pin for the MCP2515 CAN module
#define CAN_CS_PIN 10
// Initialize the MCP_CAN object
MCP_CAN CAN(CAN_CS_PIN);
void setup() {
Serial.begin(115200); // Start serial communication for debugging
while (!Serial);
// Initialize the CAN module at 250 kbps (SAE J1939 standard baud rate)
if (CAN.begin(MCP_ANY, 250000, MCP_8MHZ) == CAN_OK) {
Serial.println("CAN module initialized successfully!");
} else {
Serial.println("Error initializing CAN module.");
while (1);
}
// Set the CAN module to normal mode
CAN.setMode(MCP_NORMAL);
Serial.println("CAN module set to normal mode.");
}
void loop() {
// Example: Send a J1939 message with PGN 65280 (0x00FF00)
unsigned char data[8] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08};
unsigned long id = 0x18FF00E5; // 29-bit identifier (PGN + source address)
if (CAN.sendMsgBuf(id, 1, 8, data) == CAN_OK) {
Serial.println("Message sent successfully!");
} else {
Serial.println("Error sending message.");
}
delay(1000); // Wait 1 second before sending the next message
}
No Communication on the CAN Bus:
Error Frames on the CAN Bus:
Arduino Fails to Initialize the CAN Module:
Message Not Received by Other ECUs:
Can SAE J1939 be used with 12V systems? Yes, SAE J1939 is compatible with both 12V and 24V systems, commonly found in light and heavy-duty vehicles, respectively.
What is the maximum cable length for a J1939 network? The maximum recommended length is 40 meters, but this may vary depending on the baud rate and cable quality.
Is SAE J1939 backward compatible with CAN 2.0A? No, SAE J1939 uses the extended 29-bit identifier, which is not compatible with the 11-bit identifier used in CAN 2.0A.
Can I use SAE J1939 for non-automotive applications? Yes, while it is designed for heavy-duty vehicles, SAE J1939 can be adapted for other industrial applications requiring robust communication over CAN.