Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use SAE J1939: Examples, Pinouts, and Specs

Image of SAE J1939Design with SAE J1939 in Cirkit Designer

Introduction

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.

Explore Projects Built with SAE J1939

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!

Common Applications and Use Cases

Technical Specifications

Key Technical Details

Pin Configuration and Descriptions

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

Usage Instructions

How to Use SAE J1939 in a Circuit

  1. Connect the CAN Bus: Use a CAN transceiver (e.g., MCP2551 or SN65HVD230) to interface the microcontroller with the CAN_H and CAN_L lines.
  2. Power the Circuit: Ensure the CAN bus is powered with the appropriate voltage (typically 12V or 24V in vehicles).
  3. Termination Resistors: Place 120-ohm termination resistors at both ends of the CAN bus to prevent signal reflections.
  4. Microcontroller Setup: Configure the microcontroller to use the CAN protocol with a 29-bit identifier and the appropriate baud rate (250 kbps or 500 kbps).
  5. Message Transmission: Use the J1939 protocol stack to format and send messages. Each message includes a Parameter Group Number (PGN), source address, and data payload.

Important Considerations and Best Practices

Example: Connecting SAE J1939 to an Arduino UNO

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
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. No Communication on the CAN Bus:

    • Verify the wiring connections, especially CAN_H and CAN_L.
    • Check the termination resistors (120 ohms at both ends of the bus).
    • Ensure all devices on the network are configured with the same baud rate.
  2. Error Frames on the CAN Bus:

    • Inspect the cable shielding and grounding to reduce EMI.
    • Confirm that no two devices have the same address.
  3. Arduino Fails to Initialize the CAN Module:

    • Ensure the SPI connections between the Arduino and MCP2515 module are correct.
    • Verify the MCP2515 module's crystal frequency (e.g., 8 MHz) matches the library configuration.
  4. Message Not Received by Other ECUs:

    • Double-check the message ID and PGN formatting.
    • Confirm that the receiving ECU is configured to accept the specific PGN.

FAQs