A standby generator starts during a power cut, runs for forty minutes and stops on low oil pressure. The pressure had been falling for three weeks, and the engine controller had sent it on its network about twice every second for all of that time. Nobody was listening. A second site did connect a monitor, set it up wrongly, and the engine controller reported a communication fault and refused to start. This lesson shows how to read an engine’s CAN network with J1939, and how to do it without disturbing the engine. #CANbus #J1939 #GeneratorMonitoring
Learning Objectives
By the end of this lesson, you will be able to:
Explain how CAN nodes share one pair of wires by dominant and recessive bits and arbitration
Split a 29-bit J1939 identifier into priority, parameter group number and source address
Decode a parameter from the data bytes with its resolution and offset
Recognise the raw values that mean “not available” or “error”, and keep them out of a record
State why a monitor on an engine network must only listen, and what a wrong connection can do
Real-World System Problem: A generator that already measures everything
A diesel generator set has an engine controller that measures speed, coolant temperature, oil pressure and many other quantities to run the engine. It shares them with the generator set controller on the front panel over a CAN network, in the format of SAE J1939, at 250 kbit/s. The network is a pair of twisted wires inside the set, usually a few metres long.
Unlike a Modbus server, the engine controller does not wait for a question: it broadcasts each group of values at its own rate, whether anyone reads them or not. A monitor needs only to hear the frames and to know what the bytes mean.
This carries a risk that a Modbus bus does not have: the network is part of the engine’s own control and protection, and a device connected wrongly can disturb it. The task is to read everything and change nothing.
The engine network and a listen-only monitor
Fundamental Theory: From a CAN frame to an engine value
Two wires and two states
CAN (Controller Area Network, ISO 11898) uses a differential pair, CAN_H and CAN_L, like RS-485. The receiver reads the difference between the two lines, so noise that reaches both lines equally is rejected, as a wave lifts two boats side by side and leaves the distance between them the same.
The bus has two states. In the recessive state no node drives the bus: both lines rest near 2.5 V and the difference is about 0 V. In the dominant state a node drives CAN_H up to about 3.5 V and CAN_L down to about 1.5 V, a difference of about 2 V. Recessive is logic 1 and dominant is logic 0.
The two bus states (typical levels)
The rule that makes CAN work is this: if one node sends dominant while another sends recessive, the bus is dominant. A dominant bit always wins, and nothing is damaged.
Arbitration by identifier
A CAN frame has no address of a sender or a receiver. It begins with an identifier that says what the frame contains, followed by up to 8 data bytes and a 15-bit CRC. J1939 uses the extended frame format, with a 29-bit identifier.
Any node may start to send when the bus is idle. If two start together, each sends its identifier bit by bit, highest bit first, and reads the bus as it sends. A node that sends recessive and reads dominant knows that another node has a lower identifier: it stops at once and tries again after the frame. The other node notices nothing, and its frame arrives undamaged.
So the lowest identifier always goes first, and no time is lost. This is arbitration.
Termination
The pair is one line with a 120 Ω resistor between CAN_H and CAN_L at each end, and nodes on short stubs along it. The two resistors do two jobs: they stop reflections, and they pull the bus back to the recessive state when no node drives it. A CAN bus has no bias resistors.
With the power off, the two resistors are in parallel, so an ohmmeter between CAN_H and CAN_L reads about 60 Ω.
Reading with power off
Meaning
About 60 Ω
Two terminations: correct
About 120 Ω
One termination is missing
About 40 Ω
A third termination has been added
Acknowledge and error handling
The CAN controller chip in each node does the error handling, not your software. Every node checks every frame: the CRC, the frame format and the bit stuffing. (After five equal bits in a row, the sender inserts one bit of the opposite value, so that the receivers see an edge often enough to stay in step. Six equal bits in a row are therefore an error.) Two actions follow.
A node that receives a frame correctly sends one dominant bit in the acknowledge slot near the end of the frame. The sender needs at least one such bit. Without it, the sender repeats the frame.
A node that detects an error sends an error frame of six dominant bits. This destroys the frame for every node, and the sender repeats it.
Each controller counts its errors. With a transmit error count above 127 it becomes “error passive” and may no longer destroy frames. Above 255 it goes “bus off” and stops sending completely.
Now think of a monitor in normal mode with the wrong bit rate. To it, every frame on the bus looks wrong, so it destroys every frame with an error frame. The engine controller repeats, fails, and counts errors; it can reach error passive or bus off, and the other controllers report a communication fault. One wrongly set device has stopped the engine’s network.
Most J1939 engine networks run at 250 kbit/s, but some newer engines use 500 kbit/s (J1939-14). Take the rate from the engine maker’s documents before you connect. Do not find it by trying rates on a running engine.
Listen-only monitoring
A CAN controller has a mode made for this work, called listen-only or silent mode. In it the node receives frames and never drives the bus: no acknowledge bit, no error frame and no frame of its own.
The rule for a monitor on an engine network
A monitor on an engine network must be listen-only. It must not acknowledge and must not transmit, unless it has been designed and approved for that network by those responsible for the engine. A transmitting monitor, or a wrong termination, can stop the network of an engine controller.
Three practical points follow from the rule.
Set listen-only mode in the hardware configuration before the connector is plugged in, not after the software has started.
Listen-only mode needs another node that acknowledges. On most generator sets the generator set controller does this. If the engine controller is alone on the bus, a listen-only monitor does not change that, and the decision about what may acknowledge belongs to the maker of the controller.
Connect at the maker’s diagnostic connector with a short stub and an isolated interface. Do not cut or splice the engine harness. The connection is made by the generator’s service technician with the set stopped and locked out, and work on the generator’s power output is for a licensed electrician.
J1939 on top of CAN
CAN carries identifiers and bytes. SAE J1939 says what they mean. It has three ideas.
A parameter group is a set of related values that travel together in one frame. Each group has a parameter group number, the PGN.
A suspect parameter number, the SPN, names one value inside a group, with its position, resolution, offset and unit.
A source address is the address of the controller that sends the frame. The first engine controller has address 0.
The three groups used in this course, as defined in J1939-71:
PGN
Name
Parameter
Position
Resolution
Offset
61444 (0xF004)
Electronic Engine Controller 1
Engine speed, SPN 190
bytes 4 and 5, low byte first
0.125 rev/min per bit
0
65262 (0xFEEE)
Engine Temperature 1
Coolant temperature, SPN 110
byte 1
1 °C per bit
−40 °C
65263 (0xFEEF)
Engine Fluid Level/Pressure 1
Oil pressure, SPN 100
byte 4
4 kPa per bit
0
The 29-bit identifier
J1939 divides the 29 bits into six fields.
The 29 bits of a J1939 identifier
Priority (3 bits): 0 is the highest and 7 the lowest. It sits in the highest bits, so it decides arbitration first.
Reserved bit and data page (R and DP, 1 bit each): both 0 for the groups of this lesson.
PDU format, PF (8 bits), and PDU specific, PS (8 bits). PDU means protocol data unit.
Source address, SA (8 bits).
Building an identifier for a broadcast group
is the priority, PGN is the parameter group number and SA is the source address. This form holds when the PDU format is 240 or more.
For priority 3, PGN 61444 and source address 0: and , so the identifier is 0x0CF00400.
Taking the PGN out correctly
The PGN is not always the whole 18 bits. It depends on the PDU format.
The frame is a broadcast to every node. The PDU specific byte is part of the PGN (a group extension). Example: PF 0xFE and PS 0xEE give PGN 0xFEEE.
The frame is sent to one destination. The PDU specific byte is the destination address and is not part of the PGN. The PGN has 00 in that place. Example: PF 0xEA with any PS gives PGN 0xEA00.
All three groups of this lesson have a PDU format of 240 or more, so they are broadcasts. The common mistake is to take the middle 18 bits as the PGN for every frame, which gives a false PGN for every addressed frame.
Parameters, resolution and offset
A parameter is stored as an unsigned whole number, the raw value.
From raw value to engineering value
Two points differ from Modbus and cause most decoding errors.
Byte numbers start at 1. J1939 calls the eight data bytes byte 1 to byte 8. In code, byte 4 is data[3].
Low byte first. A two-byte parameter is sent with its low byte first. Modbus sends the high byte first. Engine speed in bytes 4 and 5 is .
The offset lets an unsigned byte carry negative temperatures: raw 0 is −40 °C and raw 40 is 0 °C.
Not available and error values
A frame always has 8 data bytes, and a controller may not have every parameter of a group. It fills the places it does not use with ones. The top of each raw range is therefore reserved.
Raw value
One byte
Two bytes
Valid data
0x00 to 0xFA (0 to 250)
0x0000 to 0xFAFF (0 to 64,255)
Reserved, not data
0xFB to 0xFD
0xFB00 to 0xFDFF
Error indicator
0xFE
0xFE00 to 0xFEFF
Not available
0xFF
0xFF00 to 0xFFFF
This fixes the range of each parameter: engine speed up to , coolant temperature from −40 to 210 °C, and oil pressure up to 1,000 kPa.
Broadcast rates
Each group has its own rate: engine speed changes quickly and is sent every few tens of milliseconds, temperatures about once per second, and pressures about once or twice per second. The exact rates are in J1939-71 and makers can differ, so measure the rate on your own engine.
One frame with 8 data bytes and a 29-bit identifier is 131 to 160 bits long with the gap after it, so it lasts 0.52 to 0.64 ms at 250 kbit/s. Even the fastest group uses a small share of the bus.
Because nothing is polled, silence is the only sign of a fault. A monitor should mark a value as stale when its group has not arrived for several of its normal periods.
Application 1: Decode three frames from the generator controller
Step 1: Identify each frame
Click to reveal the PGN and source of each frame
Read the identifier as four hex bytes. The last byte is the source address. The two bytes before it are the PDU format and the PDU specific byte. The first byte holds the priority, the reserved bit and the data page. ✅
Frame 1, 0x0CF00400. The bytes are 0C F0 04 00. The source address is 0x00. PF is 0xF0, which is 240, so the frame is PDU2 and the PGN is . ✅
Frame 2, 0x18FEEE00. The source address is 0. PF is 0xFE (254), so the PGN is . ✅
Frame 3, 0x18FEEF00. The source address is 0. PF is 0xFE, so the PGN is . ✅
Priority. The first byte divided by 4 gives the priority when the reserved bit and the data page are 0: for frame 1 and for frames 2 and 3. The speed frame has the higher priority. ✅
Step 2: Engine speed
Click to reveal the engine speed
Find the bytes. Byte 4 is 0xE0 and byte 5 is 0x2E. ✅
Join them, low byte first. Byte 5 is the high byte.
The raw value is 0x2EE0, which is below 0xFAFF, so it is valid data. ✅
Apply the resolution.
The engine runs at 1,500 rev/min. ✅
The wrong order, for comparison. Read high byte first, the bytes give 0xE02E, which is 57,390, or 7,173.75 rev/min. The value is inside the valid range of the parameter, so no range test in the protocol rejects it. Only knowledge of the engine does. ✅
Step 3: Coolant temperature and oil pressure
Click to reveal the two values
Coolant temperature. Byte 1 of frame 2 is 0x7A, which is 122. It is below 0xFA, so it is valid.
The coolant is at 82 °C. ✅
Oil pressure. Byte 4 of frame 3 is 0x69, which is 105, valid.
The oil pressure is 420 kPa. ✅
The other bytes. Every other byte in the three frames is 0xFF: “not available”. This controller does not send the other parameters of these groups. They are recorded as not available and are not decoded. ✅
The three frames, with the bytes that carry data
Step 4: Check against the frequency
Click to reveal the check
Speed and frequency of a synchronous generator. With poles and a speed in rev/min, the frequency is
The decoded speed gives exactly the system frequency. The wrong byte order would give 239 Hz. ✅
Check by encoding. Work backwards: , sent as E0 2E. . . These are the bytes of the capture. ✅
Check with the script. The Python script builds the three frames from the three values, prints the same identifiers and bytes, and decodes them to 1500 rev/min, 82 °C and 420 kPa. ✅
Check it at the set. With the set running, compare each decoded value with the generator set controller’s own display at the same moment: the speed to within a few rev/min, the coolant temperature to within 1 °C, the oil pressure to within one step of 4 kPa. Then confirm the monitor is silent. Its interface must report no frames sent and no errors, the set controller must show no new communication fault, and no frame in the capture may carry the monitor’s address as its source.
Application 2: Split identifier 0x18FEEE00 into its fields
Step 1: Write the 29 bits
Click to reveal the bits
Hex to binary. Eight hex digits are 32 bits: 0001 1000 1111 1110 1110 1110 0000 0000. ✅
Drop the three highest bits. An identifier has 29 bits, so the three highest bits of the 32 are not part of it. They are 000. The 29 bits are
1 1000 1111 1110 1110 1110 0000 0000. ✅
Step 2: Cut the fields
Click to reveal the six fields
Cut from the left: 3, 1, 1, 8, 8 and 8 bits.
Field
Bits
Value
Priority
110
6
Reserved
0
0
Data page
0
0
PDU format
1111 1110
0xFE = 254
PDU specific
1110 1110
0xEE = 238
Source address
0000 0000
0
The six fields use bits. ✅
PDU1 or PDU2. The PDU format is 254, which is not below 240. The frame is PDU2: a broadcast, and the PDU specific byte is part of the PGN. ✅
The PGN. With the reserved bit and the data page at 0,
This is Engine Temperature 1, sent with priority 6 by source address 0, the engine controller. ✅
Step 3: Check by building it again
Click to reveal the check
Use the identifier formula.
In hexadecimal, 419,360,256 is 0x18FEEE00. ✅
The same by hex pieces. and . Their sum is 0x18FEEE00. ✅
Step 4: An addressed frame
Click to reveal the split of 0x18EAFFF9
The fields. The bytes are 18 EA FF F9. Priority 6, reserved 0, data page 0, PF 0xEA = 234, PS 0xFF = 255, source address 0xF9 = 249. ✅
PDU1. PF is 234, which is below 240. The PDU specific byte is a destination address: 255, the address that means “all nodes”. It is not part of the PGN. ✅
The PGN.
This is the group that J1939-21 uses to request another group. A node at address 249 is asking every node for something. ✅
The common mistake. Taking all 18 bits gives , which is not a parameter group at all. A decoder with this mistake works for every broadcast group and fails on every addressed frame. ✅
What this frame tells a site engineer. Address 249 is transmitting. If that node is the monitor, it is not in listen-only mode and must be disconnected until it is. ✅
Verify It in Python
The script packs and unpacks an identifier with the PDU1 and PDU2 rule, builds and decodes the three frames, splits the two identifiers of Application 2, and prints the valid ranges. The plot shows engine speed decoded from a simulated capture of PGN 61444 at one frame every 20 ms, while a load is switched on at 1 s.
j1939_decode.py
"""J1939: pack and unpack the 29-bit identifier, decode three engine parameters."""
The script only decodes bytes. It opens no CAN interface and sends nothing. The load step in the plot is an invented curve.
Common Mistakes
Connecting a CAN interface in normal mode. It acknowledges frames and can send error frames. Set listen-only mode first, in the hardware configuration.
Switching on the 120 Ω termination of the interface. The network already has two, and a third brings the resistance between the lines to about 40 Ω.
Reading a two-byte parameter high byte first, as in Modbus. J1939 sends the low byte first.
Counting data bytes from 0 when the definition counts from 1. Byte 4 is the fourth byte, data[3] in code.
Decoding 0xFF or 0xFFFF as a measurement. They mean “not available”, and 0xFE means “error”.
Taking the PDU specific byte into the PGN when the PDU format is below 240. There it is a destination address.
Summary
CAN is a terminated differential pair with dominant and recessive bits. The lowest identifier wins arbitration, and the controller chips handle acknowledgement and errors.
The bus has 120 Ω at each end, about 60 Ω between the lines with the power off, and J1939 engine networks commonly run at 250 kbit/s.
A J1939 identifier holds priority, reserved bit, data page, PDU format, PDU specific and source address. The PGN includes the PDU specific byte only when the PDU format is 240 or more.
A value is the raw value times the resolution plus the offset. Bytes count from 1, and two-byte values come low byte first.
Raw values above 0xFA or 0xFAFF are not data. Record them as error or not available.
A monitor on an engine network is listen-only, adds no termination and never transmits unless it is designed and approved for that network.
Exercises
1. Build the 29-bit identifier for priority 6, PGN 65263 and source address 0.
Answer
PGN 65263 is 0xFEEF, with a PDU format of 0xFE, so it is PDU2. and . The identifier is 0x18FEEF00.
2. A generator set for a 60 Hz system sends identifier 0x0CF00400 with data FF FF FF 40 38 FF FF FF. Find the engine speed, and check it against 60 Hz for a 4-pole generator.
Answer
Bytes 4 and 5 are 40 38, low byte first, so the raw value is . The speed is . The frequency is , as expected.
3. Three frames with identifier 0x18FEEE00 have a first data byte of 0x9B, 0xFE and 0xFF. What should the monitor record for each?
Answer
0x9B is 155, valid, so the coolant is at °C. 0xFE is the error indicator: record “sensor error” and no number. 0xFF is “not available”: record that and no number. Decoding the last two would give 214 °C and 215 °C, both false.
4. The oil pressure of an engine is 390 kPa. What raw value can the controller send in PGN 65263, and what will the monitor show?
Answer
, which is not a whole number. The controller sends 97 (0x61), shown as 388 kPa, or 98 (0x62), shown as 392 kPa. The resolution of 4 kPa is the limit of this parameter, so a difference of 2 kPa between the monitor and a gauge is not a fault.
5. With the generator set stopped and its control power off, a technician measures 40 Ω between CAN_H and CAN_L. A week earlier the reading was 60 Ω, and a monitor was fitted in between. What has happened, and what is the correction?
Answer
Three resistors of 120 Ω in parallel give . The monitor’s own termination is switched on. Switch it off, and the reading returns to .
References
International Organization for Standardization, ISO 11898-1: Road vehicles, Controller area network (CAN), Part 1: Data link layer and physical signalling, 2015.
International Organization for Standardization, ISO 11898-2: Road vehicles, Controller area network (CAN), Part 2: High-speed medium access unit, 2016.
A generator with 4 poles supplies a 50 Hz system, so its engine runs near 1,500 rev/min. A frame from the engine controller carries the speed in two bytes, at 0.125 rev/min per count. They arrive as E0, then 2E. Which byte is the high byte?
See it: one identifier, eight bytes, one value
Part A: the 29-bit identifier
Priority
PDU format, PF
PDU specific, PS
Source address, SA
Kind of frame
PGN
Part B: the eight data bytes
Parameter
Raw value
Decoded value
Valid range
Part A cuts the 29 bits into the six fields of the lesson, from the left: 3, 1, 1, 8, 8 and 8 bits. The PGN follows the lesson's rule. With a PDU format of 240 or more, the PDU specific byte is part of the PGN. Below 240 it is a destination address, and the PGN has 00 in that place. Part B decodes the data bytes for the group that Part A has found, for the three parameters of the lesson. A raw value above the valid range gives no number. Each slider belongs to one group. When you move it, the page selects that group's identifier from the lesson and writes the value into its byte or bytes, so you see the encoding too. The first three buttons load the three captured frames of the lesson. The page only calculates. It is not connected to any engine network.
Check yourself
Three questions. Each wrong choice is a mistake people really make, so read the note after you answer.
1. A capture shows the identifier 0x18EAFFF9. Its PDU format byte is 0xEA, which is 234. What is the PGN?
2. A frame of PGN 65262 arrives with 0xFF in byte 1. Coolant temperature is 1 °C per bit with an offset of −40 °C. What does the monitor record?
3. A frame of PGN 65263 has the data bytes FF FF FF 69 FF FF FF FF. Oil pressure is in byte 4, at 4 kPa per bit. A program reads data[4]. What does it report, and what is the true value?
Watch it build: one frame, its check, and the monitor
The engine controller sends a frame. Every node checks its CRC, its format and its bit stuffing.
A node that received it correctly sends one dominant bit in the ACK slot.
A node that sees an error sends six dominant bits. The frame is destroyed and sent again.
Each controller counts its errors: above 127 it is error passive, above 255 it is bus off.
A monitor at the wrong bit rate destroys every frame. The engine controller can go bus off.
In listen-only mode the monitor only receives: no ACK, no error frame. The network does not change.
See it: two nodes start together
Goes first
Decided at identifier bit
The other waitsone frame, 0.52 to 0.64 ms
Each node sends its identifier and reads the bus at the same time. A 0 (dominant) beats a 1 (recessive), so the bus shows 0 if any node sends 0. A node that sends 1 and reads 0 stops at once. The winner never notices, and its frame arrives undamaged. The highest bit, 28, goes first.
Found this useful?
Discussion
No comments yet. Questions, results from your own build, a better way to explain it: all welcome.
Text size
←→
Previous and next card. On a turned card: Not yet, I knew it
SpaceEnter
Turn the card, show the answer
123
Overview, Recap, Test me
HomeEnd
First and last card
Esc
Close
← → or scroll · N notes · F full screen · B blank0:00
My notes on this page
Kept on this device only. Nothing is sent anywhere.
Tip: select words in the lesson, or tap a figure or an equation, to put a note right there.
Notes on earlier wording
The lesson has changed and these words are no longer in it. Your notes are kept, with the words you chose.