I’m a bit confused on how to interpret the table of CAN messages. Specifically, these are the columns that confuse me: Start byte, Signal Type, Bits, Factor, Offset
https://docs.odriverobotics.com/v/latest/can-protocol.html#id2
Lets say I want to set the input torque through CAN. Here’s what it says
CMD ID : 0x00E
Start byte : 0
Signal Type : IEEE 754 Float
Bits : 32
Factor : 1
Offset : 0
So CAN accepts an array of 8 unsigned 8 bit integers (at least I think so). How do I take “0.521” and send that across CAN? More generally, what do I need to know in order to interpret the table so that i understand how to send this as the CAN payload.
Apologies for the delay.
Usually, you will need to use memcpy
to copy the bit representation of a float into 4 bytes to send on CAN.
More than one signal can fit in the 8 bytes of a CAN message. In fact, it can be done bit-by-bit, so up to 64 bits are available. To make it fairly easy, most of our signals are floating point, and they’re all byte aligned - so you just copy the floating point data directly into the buffer (don’t cast, do a byte copy) and send it.
Start Byte: Which of the 8 bytes in the CAN data array is the first byte of the value placed
Signal Type: When the far end reads it, how will it interpret the bytes
Bits: Length of the data, in bits
Factor: How much the data should be scaled at the far end
Offset: How the data will be offset at the far end.