16-Byte CAN FD Motorola Big-Endian DBC Bitfield Decoder

Decode Motorola big-endian DBC signals across a 16-byte CAN FD BMS payload with a bit map, signed scaling and C99 extraction.

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
Pack voltage
51.2 V
Pack current
-20 A
State of charge
80 %
Minimum cell voltage
3.36 V
Bit map · 128 bits
B0 · 14B1 · 00B2 · FFB3 · 38B4 · 50B5 · 00B6 · 00B7 · 00B8 · 0DB9 · 20B10 · 00B11 · 00B12 · 00B13 · 00B14 · 00B15 · 0076543210 Bit 7 = 0 · Pack voltage 0 Bit 6 = 0 · Pack voltage 0 Bit 5 = 0 · Pack voltage 0 Bit 4 = 1 · Pack voltage 1 Bit 3 = 0 · Pack voltage 0 Bit 2 = 1 · Pack voltage 1 Bit 1 = 0 · Pack voltage 0 Bit 0 = 0 · Pack voltage 0 Bit 15 = 0 · Pack voltage 0 Bit 14 = 0 · Pack voltage 0 Bit 13 = 0 · Pack voltage 0 Bit 12 = 0 · Pack voltage 0 Bit 11 = 0 · Pack voltage 0 Bit 10 = 0 · Pack voltage 0 Bit 9 = 0 · Pack voltage 0 Bit 8 = 0 · Pack voltage 0 Bit 23 = 1 · Pack current 1 Bit 22 = 1 · Pack current 1 Bit 21 = 1 · Pack current 1 Bit 20 = 1 · Pack current 1 Bit 19 = 1 · Pack current 1 Bit 18 = 1 · Pack current 1 Bit 17 = 1 · Pack current 1 Bit 16 = 1 · Pack current 1 Bit 31 = 0 · Pack current 0 Bit 30 = 0 · Pack current 0 Bit 29 = 1 · Pack current 1 Bit 28 = 1 · Pack current 1 Bit 27 = 1 · Pack current 1 Bit 26 = 0 · Pack current 0 Bit 25 = 0 · Pack current 0 Bit 24 = 0 · Pack current 0 Bit 39 = 0 · unassigned 0 Bit 38 = 1 · State of charge 1 Bit 37 = 0 · State of charge 0 Bit 36 = 1 · State of charge 1 Bit 35 = 0 · State of charge 0 Bit 34 = 0 · State of charge 0 Bit 33 = 0 · State of charge 0 Bit 32 = 0 · State of charge 0 Bit 47 = 0 · unassigned 0 Bit 46 = 0 · unassigned 0 Bit 45 = 0 · unassigned 0 Bit 44 = 0 · unassigned 0 Bit 43 = 0 · unassigned 0 Bit 42 = 0 · unassigned 0 Bit 41 = 0 · unassigned 0 Bit 40 = 0 · unassigned 0 Bit 55 = 0 · unassigned 0 Bit 54 = 0 · unassigned 0 Bit 53 = 0 · unassigned 0 Bit 52 = 0 · unassigned 0 Bit 51 = 0 · unassigned 0 Bit 50 = 0 · unassigned 0 Bit 49 = 0 · unassigned 0 Bit 48 = 0 · unassigned 0 Bit 63 = 0 · unassigned 0 Bit 62 = 0 · unassigned 0 Bit 61 = 0 · unassigned 0 Bit 60 = 0 · unassigned 0 Bit 59 = 0 · unassigned 0 Bit 58 = 0 · unassigned 0 Bit 57 = 0 · unassigned 0 Bit 56 = 0 · unassigned 0 Bit 71 = 0 · Minimum cell voltage 0 Bit 70 = 0 · Minimum cell voltage 0 Bit 69 = 0 · Minimum cell voltage 0 Bit 68 = 0 · Minimum cell voltage 0 Bit 67 = 1 · Minimum cell voltage 1 Bit 66 = 1 · Minimum cell voltage 1 Bit 65 = 0 · Minimum cell voltage 0 Bit 64 = 1 · Minimum cell voltage 1 Bit 79 = 0 · Minimum cell voltage 0 Bit 78 = 0 · Minimum cell voltage 0 Bit 77 = 1 · Minimum cell voltage 1 Bit 76 = 0 · Minimum cell voltage 0 Bit 75 = 0 · Minimum cell voltage 0 Bit 74 = 0 · Minimum cell voltage 0 Bit 73 = 0 · Minimum cell voltage 0 Bit 72 = 0 · Minimum cell voltage 0 Bit 87 = 0 · unassigned 0 Bit 86 = 0 · unassigned 0 Bit 85 = 0 · unassigned 0 Bit 84 = 0 · unassigned 0 Bit 83 = 0 · unassigned 0 Bit 82 = 0 · unassigned 0 Bit 81 = 0 · unassigned 0 Bit 80 = 0 · unassigned 0 Bit 95 = 0 · unassigned 0 Bit 94 = 0 · unassigned 0 Bit 93 = 0 · unassigned 0 Bit 92 = 0 · unassigned 0 Bit 91 = 0 · unassigned 0 Bit 90 = 0 · unassigned 0 Bit 89 = 0 · unassigned 0 Bit 88 = 0 · unassigned 0 Bit 103 = 0 · unassigned 0 Bit 102 = 0 · unassigned 0 Bit 101 = 0 · unassigned 0 Bit 100 = 0 · unassigned 0 Bit 99 = 0 · unassigned 0 Bit 98 = 0 · unassigned 0 Bit 97 = 0 · unassigned 0 Bit 96 = 0 · unassigned 0 Bit 111 = 0 · unassigned 0 Bit 110 = 0 · unassigned 0 Bit 109 = 0 · unassigned 0 Bit 108 = 0 · unassigned 0 Bit 107 = 0 · unassigned 0 Bit 106 = 0 · unassigned 0 Bit 105 = 0 · unassigned 0 Bit 104 = 0 · unassigned 0 Bit 119 = 0 · unassigned 0 Bit 118 = 0 · unassigned 0 Bit 117 = 0 · unassigned 0 Bit 116 = 0 · unassigned 0 Bit 115 = 0 · unassigned 0 Bit 114 = 0 · unassigned 0 Bit 113 = 0 · unassigned 0 Bit 112 = 0 · unassigned 0 Bit 127 = 0 · unassigned 0 Bit 126 = 0 · unassigned 0 Bit 125 = 0 · unassigned 0 Bit 124 = 0 · unassigned 0 Bit 123 = 0 · unassigned 0 Bit 122 = 0 · unassigned 0 Bit 121 = 0 · unassigned 0 Bit 120 = 0 · unassigned 0

Select a bit to see its position and matching signals.

  • Pack voltage
  • Pack current
  • State of charge
  • Minimum cell voltage

An asterisk marks an overlapping bit.

Decoded signal values
SignalEncodingRaw integerRaw hexPhysical
Pack voltageMotorola51200x140051.2 V
Pack currentMotorola-2000xFF38-20 A
State of chargeMotorola800x5080 %
Minimum cell voltageMotorola33600xD203.36 V
Generated C99 masks and functions
#include <stdint.h>

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

#define DBC_1_PACK_VOLTAGE_MASK UINT64_C(0xFFFF)
#define DBC_1_PACK_VOLTAGE_RAW(data) (( \
    (DBC_BIT((data), 8) << 0) | \
    (DBC_BIT((data), 9) << 1) | \
    (DBC_BIT((data), 10) << 2) | \
    (DBC_BIT((data), 11) << 3) | \
    (DBC_BIT((data), 12) << 4) | \
    (DBC_BIT((data), 13) << 5) | \
    (DBC_BIT((data), 14) << 6) | \
    (DBC_BIT((data), 15) << 7) | \
    (DBC_BIT((data), 0) << 8) | \
    (DBC_BIT((data), 1) << 9) | \
    (DBC_BIT((data), 2) << 10) | \
    (DBC_BIT((data), 3) << 11) | \
    (DBC_BIT((data), 4) << 12) | \
    (DBC_BIT((data), 5) << 13) | \
    (DBC_BIT((data), 6) << 14) | \
    (DBC_BIT((data), 7) << 15) \
) & DBC_1_PACK_VOLTAGE_MASK)
static inline double dbc_1_pack_voltage_physical(const uint8_t data[static 16]) {
    const uint64_t raw = DBC_1_PACK_VOLTAGE_RAW(data);
    const uint64_t value = raw;
    return (double)value * (0.01) + (0.0);
}

#define DBC_2_PACK_CURRENT_MASK UINT64_C(0xFFFF)
#define DBC_2_PACK_CURRENT_RAW(data) (( \
    (DBC_BIT((data), 24) << 0) | \
    (DBC_BIT((data), 25) << 1) | \
    (DBC_BIT((data), 26) << 2) | \
    (DBC_BIT((data), 27) << 3) | \
    (DBC_BIT((data), 28) << 4) | \
    (DBC_BIT((data), 29) << 5) | \
    (DBC_BIT((data), 30) << 6) | \
    (DBC_BIT((data), 31) << 7) | \
    (DBC_BIT((data), 16) << 8) | \
    (DBC_BIT((data), 17) << 9) | \
    (DBC_BIT((data), 18) << 10) | \
    (DBC_BIT((data), 19) << 11) | \
    (DBC_BIT((data), 20) << 12) | \
    (DBC_BIT((data), 21) << 13) | \
    (DBC_BIT((data), 22) << 14) | \
    (DBC_BIT((data), 23) << 15) \
) & DBC_2_PACK_CURRENT_MASK)
static inline double dbc_2_pack_current_physical(const uint8_t data[static 16]) {
    const uint64_t raw = DBC_2_PACK_CURRENT_RAW(data);
    const int64_t value = raw & (UINT64_C(1) << 15)
        ? -INT64_C(1) - (int64_t)(DBC_2_PACK_CURRENT_MASK ^ raw) : (int64_t)raw;
    return (double)value * (0.1) + (0.0);
}

#define DBC_3_STATE_OF_CHARGE_MASK UINT64_C(0x7F)
#define DBC_3_STATE_OF_CHARGE_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_3_STATE_OF_CHARGE_MASK)
static inline double dbc_3_state_of_charge_physical(const uint8_t data[static 16]) {
    const uint64_t raw = DBC_3_STATE_OF_CHARGE_RAW(data);
    const uint64_t value = raw;
    return (double)value * (1.0) + (0.0);
}

#define DBC_4_MINIMUM_CELL_VOLTAGE_MASK UINT64_C(0xFFFF)
#define DBC_4_MINIMUM_CELL_VOLTAGE_RAW(data) (( \
    (DBC_BIT((data), 72) << 0) | \
    (DBC_BIT((data), 73) << 1) | \
    (DBC_BIT((data), 74) << 2) | \
    (DBC_BIT((data), 75) << 3) | \
    (DBC_BIT((data), 76) << 4) | \
    (DBC_BIT((data), 77) << 5) | \
    (DBC_BIT((data), 78) << 6) | \
    (DBC_BIT((data), 79) << 7) | \
    (DBC_BIT((data), 64) << 8) | \
    (DBC_BIT((data), 65) << 9) | \
    (DBC_BIT((data), 66) << 10) | \
    (DBC_BIT((data), 67) << 11) | \
    (DBC_BIT((data), 68) << 12) | \
    (DBC_BIT((data), 69) << 13) | \
    (DBC_BIT((data), 70) << 14) | \
    (DBC_BIT((data), 71) << 15) \
) & DBC_4_MINIMUM_CELL_VOLTAGE_MASK)
static inline double dbc_4_minimum_cell_voltage_physical(const uint8_t data[static 16]) {
    const uint64_t raw = DBC_4_MINIMUM_CELL_VOLTAGE_RAW(data);
    const uint64_t value = raw;
    return (double)value * (0.001) + (0.0);
}

Read Motorola DBC start bits on a 16-byte CAN FD frame

This synthetic BMS frame shows a signed 16-bit pack current and a cell voltage field in the second half of the payload. In the DBC convention used here, a Motorola start bit marks the most significant bit. In the diagram, each byte displays its high bit on the left.

Follow the bit positions from the DBC start and sign-extend the completed raw integer before applying scale and offset. The diagram and generated C99 helpers use the same positions. Use your capture’s message definition to confirm start bits, scaling and units.

Formulas

  • Motorola next position = current bit − 1 within a byte, or current bit + 15 on crossing its bit 0
  • Signed raw = unsigned raw − 2^length when the sign bit is set
  • Physical value = raw × scale + offset

Worked example

The word FF 38 gives signed raw −200 and −20.0 A at 0.1 A/bit. Start bit 71 addresses the most significant bit of the ninth byte. The next 16 bits give 0x0D20, or 3.36 V at 1 mV/bit.

Frequently asked questions

Does the DBC Motorola start bit point to the LSB or MSB?

It points to the MSB in the DBC convention this tool uses. Confirm the convention when copying a position from a logger UI.

Where is Motorola start bit 71 in a 16-byte payload?

It is bit 7 of zero-based byte 8, the ninth byte. A 16-bit signal there spans bytes 8 and 9.

When do I apply the scale to a negative current?

Extract the whole bitfield and interpret the signed raw integer first. Then apply the signal’s scale and offset.