OBD-II CAN PID Bitfield Decoder & Motorola C99 Extractor

Decode ISO 15765 OBD-II CAN frames using Motorola big-endian bit positions for engine RPM, coolant temp and vehicle speed.

Jump to results

Inputs

Captured payload
Classic CAN 8 bytes or CAN FD 16 bytes. Spaces are optional.
DBC signals
Signal 1
Signal 2
Signal 3
Signal 4

Results

Estimates
Decoded signals4
Data bytes
4 B
Engine RPM
2,000 rpm
Coolant temp
90 °C
Vehicle speed
80 km/h
Bit map · 64 bits
B0 · 04B1 · 41B2 · 0CB3 · 1FB4 · 40B5 · 82B6 · 50B7 · 3276543210 Bit 7 = 0 · Data bytes 0 Bit 6 = 0 · Data bytes 0 Bit 5 = 0 · Data bytes 0 Bit 4 = 0 · Data bytes 0 Bit 3 = 0 · Data bytes 0 Bit 2 = 1 · Data bytes 1 Bit 1 = 0 · Data bytes 0 Bit 0 = 0 · Data bytes 0 Bit 15 = 0 · unassigned 0 Bit 14 = 1 · unassigned 1 Bit 13 = 0 · unassigned 0 Bit 12 = 0 · unassigned 0 Bit 11 = 0 · unassigned 0 Bit 10 = 0 · unassigned 0 Bit 9 = 0 · unassigned 0 Bit 8 = 1 · unassigned 1 Bit 23 = 0 · unassigned 0 Bit 22 = 0 · unassigned 0 Bit 21 = 0 · unassigned 0 Bit 20 = 0 · unassigned 0 Bit 19 = 1 · unassigned 1 Bit 18 = 1 · unassigned 1 Bit 17 = 0 · unassigned 0 Bit 16 = 0 · unassigned 0 Bit 31 = 0 · Engine RPM 0 Bit 30 = 0 · Engine RPM 0 Bit 29 = 0 · Engine RPM 0 Bit 28 = 1 · Engine RPM 1 Bit 27 = 1 · Engine RPM 1 Bit 26 = 1 · Engine RPM 1 Bit 25 = 1 · Engine RPM 1 Bit 24 = 1 · Engine RPM 1 Bit 39 = 0 · Engine RPM 0 Bit 38 = 1 · Engine RPM 1 Bit 37 = 0 · Engine RPM 0 Bit 36 = 0 · Engine RPM 0 Bit 35 = 0 · Engine RPM 0 Bit 34 = 0 · Engine RPM 0 Bit 33 = 0 · Engine RPM 0 Bit 32 = 0 · Engine RPM 0 Bit 47 = 1 · Coolant temp 1 Bit 46 = 0 · Coolant temp 0 Bit 45 = 0 · Coolant temp 0 Bit 44 = 0 · Coolant temp 0 Bit 43 = 0 · Coolant temp 0 Bit 42 = 0 · Coolant temp 0 Bit 41 = 1 · Coolant temp 1 Bit 40 = 0 · Coolant temp 0 Bit 55 = 0 · Vehicle speed 0 Bit 54 = 1 · Vehicle speed 1 Bit 53 = 0 · Vehicle speed 0 Bit 52 = 1 · Vehicle speed 1 Bit 51 = 0 · Vehicle speed 0 Bit 50 = 0 · Vehicle speed 0 Bit 49 = 0 · Vehicle speed 0 Bit 48 = 0 · Vehicle speed 0 Bit 63 = 0 · unassigned 0 Bit 62 = 0 · unassigned 0 Bit 61 = 1 · unassigned 1 Bit 60 = 1 · unassigned 1 Bit 59 = 0 · unassigned 0 Bit 58 = 0 · unassigned 0 Bit 57 = 1 · unassigned 1 Bit 56 = 0 · unassigned 0

Select a bit to see its position and matching signals.

  • Data bytes
  • Engine RPM
  • Coolant temp
  • Vehicle speed

An asterisk marks an overlapping bit.

Decoded signal values
SignalEncodingRaw integerRaw hexPhysical
Data bytesMotorola40x44 B
Engine RPMMotorola80000x1F402,000 rpm
Coolant tempMotorola1300x8290 °C
Vehicle speedMotorola800x5080 km/h
Generated C99 masks and functions
#include <stdint.h>

/* Pass a validated payload of at least 8 bytes. */
#define DBC_BIT(data, b) ((uint64_t)(((data)[(b) / 8] >> ((b) % 8)) & 1u))

#define DBC_1_DATA_BYTES_MASK UINT64_C(0xFF)
#define DBC_1_DATA_BYTES_RAW(data) (( \
    (DBC_BIT((data), 0) << 0) | \
    (DBC_BIT((data), 1) << 1) | \
    (DBC_BIT((data), 2) << 2) | \
    (DBC_BIT((data), 3) << 3) | \
    (DBC_BIT((data), 4) << 4) | \
    (DBC_BIT((data), 5) << 5) | \
    (DBC_BIT((data), 6) << 6) | \
    (DBC_BIT((data), 7) << 7) \
) & DBC_1_DATA_BYTES_MASK)
static inline double dbc_1_data_bytes_physical(const uint8_t data[static 8]) {
    const uint64_t raw = DBC_1_DATA_BYTES_RAW(data);
    const uint64_t value = raw;
    return (double)value * (1.0) + (0.0);
}

#define DBC_2_ENGINE_RPM_MASK UINT64_C(0xFFFF)
#define DBC_2_ENGINE_RPM_RAW(data) (( \
    (DBC_BIT((data), 32) << 0) | \
    (DBC_BIT((data), 33) << 1) | \
    (DBC_BIT((data), 34) << 2) | \
    (DBC_BIT((data), 35) << 3) | \
    (DBC_BIT((data), 36) << 4) | \
    (DBC_BIT((data), 37) << 5) | \
    (DBC_BIT((data), 38) << 6) | \
    (DBC_BIT((data), 39) << 7) | \
    (DBC_BIT((data), 24) << 8) | \
    (DBC_BIT((data), 25) << 9) | \
    (DBC_BIT((data), 26) << 10) | \
    (DBC_BIT((data), 27) << 11) | \
    (DBC_BIT((data), 28) << 12) | \
    (DBC_BIT((data), 29) << 13) | \
    (DBC_BIT((data), 30) << 14) | \
    (DBC_BIT((data), 31) << 15) \
) & DBC_2_ENGINE_RPM_MASK)
static inline double dbc_2_engine_rpm_physical(const uint8_t data[static 8]) {
    const uint64_t raw = DBC_2_ENGINE_RPM_RAW(data);
    const uint64_t value = raw;
    return (double)value * (0.25) + (0.0);
}

#define DBC_3_COOLANT_TEMP_MASK UINT64_C(0xFF)
#define DBC_3_COOLANT_TEMP_RAW(data) (( \
    (DBC_BIT((data), 40) << 0) | \
    (DBC_BIT((data), 41) << 1) | \
    (DBC_BIT((data), 42) << 2) | \
    (DBC_BIT((data), 43) << 3) | \
    (DBC_BIT((data), 44) << 4) | \
    (DBC_BIT((data), 45) << 5) | \
    (DBC_BIT((data), 46) << 6) | \
    (DBC_BIT((data), 47) << 7) \
) & DBC_3_COOLANT_TEMP_MASK)
static inline double dbc_3_coolant_temp_physical(const uint8_t data[static 8]) {
    const uint64_t raw = DBC_3_COOLANT_TEMP_RAW(data);
    const uint64_t value = raw;
    return (double)value * (1.0) + (-40.0);
}

#define DBC_4_VEHICLE_SPEED_MASK UINT64_C(0xFF)
#define DBC_4_VEHICLE_SPEED_RAW(data) (( \
    (DBC_BIT((data), 48) << 0) | \
    (DBC_BIT((data), 49) << 1) | \
    (DBC_BIT((data), 50) << 2) | \
    (DBC_BIT((data), 51) << 3) | \
    (DBC_BIT((data), 52) << 4) | \
    (DBC_BIT((data), 53) << 5) | \
    (DBC_BIT((data), 54) << 6) | \
    (DBC_BIT((data), 55) << 7) \
) & DBC_4_VEHICLE_SPEED_MASK)
static inline double dbc_4_vehicle_speed_physical(const uint8_t data[static 8]) {
    const uint64_t raw = DBC_4_VEHICLE_SPEED_RAW(data);
    const uint64_t value = raw;
    return (double)value * (1.0) + (0.0);
}
Generated Python 3 decoder
# Pure Python 3 CAN decoder for a 8-byte payload.
FRAME_LEN = 8

def dbc_1_data_bytes_physical(data: bytes) -> float:
    if len(data) < 8:
        raise ValueError("Expected at least 8 payload bytes")
    raw = (int.from_bytes(data[:8], "big") >> 56) & 0xFF
    return raw * (1.0) + (0.0)

def dbc_2_engine_rpm_physical(data: bytes) -> float:
    if len(data) < 8:
        raise ValueError("Expected at least 8 payload bytes")
    raw = (int.from_bytes(data[:8], "big") >> 24) & 0xFFFF
    return raw * (0.25) + (0.0)

def dbc_3_coolant_temp_physical(data: bytes) -> float:
    if len(data) < 8:
        raise ValueError("Expected at least 8 payload bytes")
    raw = (int.from_bytes(data[:8], "big") >> 16) & 0xFF
    return raw * (1.0) + (-40.0)

def dbc_4_vehicle_speed_physical(data: bytes) -> float:
    if len(data) < 8:
        raise ValueError("Expected at least 8 payload bytes")
    raw = (int.from_bytes(data[:8], "big") >> 8) & 0xFF
    return raw * (1.0) + (0.0)

def decode_frame(data: bytes) -> dict[str, float]:
    return {
        "dbc_1_data_bytes": dbc_1_data_bytes_physical(data),
        "dbc_2_engine_rpm": dbc_2_engine_rpm_physical(data),
        "dbc_3_coolant_temp": dbc_3_coolant_temp_physical(data),
        "dbc_4_vehicle_speed": dbc_4_vehicle_speed_physical(data),
    }

Map OBD-II Mode 01 response bytes in standard Motorola big-endian order

ISO 15765-4 passenger vehicle diagnostics and EV drivetrain CAN gateways pack multi-byte values in big-endian (Motorola MSB-first) order. Using Motorola start bits (7 for byte 0, 31 for byte 3, 47 for byte 5) keeps firmware unpackers synchronized across bit-packed sensor fields.

Click any bit cell in the 64-bit interactive grid to trace how big-endian bit masks walk downward inside each byte before jumping upward across byte boundaries, then copy the self-contained C99 inline helpers.

Formulas

  • OBD-II RPM = ((256 × A) + B) ÷ 4 → 0x1F40 (8,000) × 0.25 = 2,000 rpm
  • Coolant temperature = byte − 40 → 0x82 (130) − 40 = 90 °C
  • Motorola byte-aligned MSB start bit = (byte_index × 8) + 7

Worked example

Payload 04 41 0C 1F 40 82 50 32 extracts 4 PCI data bytes, 2,000 rpm engine speed (0x1F40 × 0.25), 90 °C coolant temperature (130 − 40) and 80 km/h vehicle speed.

Frequently asked questions

Why does a Motorola 16-bit signal at byte 3 use start bit 31 instead of 24?

Vector DBC Motorola convention indexes from the most significant bit of the starting byte (3 × 8 + 7 = 31) and walks downward to byte 4 bit 32.

Can I add EV battery state-of-health or UDS response bytes to the same grid?

Yes. Add rows in the DBC signals table or extend the hex payload to 16 bytes for CAN FD diagnostic responses.

Do the C99 extractors avoid unaligned pointer casts?

Yes. The generated DBC_BIT macro reads individual bytes from a uint8_t buffer so it stays portable and strict-aliasing safe on Cortex-M and RISC-V MCUs.