Can input channel examples, 32 appendices – MoTeC PDM30 User Manual
Page 35
32
Appendices
CAN Input Channel Examples
Sample received CAN message used in examples below
Byte
0
1
2
3
4
5
6
7
Value (hex)
00
00
F3
21
40
00
CC
8A
Channel Extraction Examples
Offset
Data Size
Mask
Byte 2
8bit
FF
Resulting channel: 0xF3 masked with 0xFF = 0xF3
Offset
Data Size
Mask
Byte 2
8bit
02
Resulting channel: 0xF3 masked with 0x02 = 0x02
Offset
Data Size
Alignment
Divisor
Byte 3
16bit (signed)
Normal
100
Resulting channel: 0x2140 / 100 = 85
Offset
Data Size
Alignment
Divisor
Byte 3
16bit (signed)
Swap Bytes 100
Resulting channel: 0x4021 / 100 = 164
Offset
Data Size
Alignment
Divisor
Byte 2
16bit (signed)
Normal
100
Resulting channel: 0xF321 is negative (-3295) so channel is clamped to 0
Offset
Data Size
Alignment
Mask
Divisor
Byte 6
16bit (unsigned)
Swap Bytes 0FFF
25
Resulting channel: (0x8ACC masked with 0x0FFF) / 25 = 110