The Freeform CAN application has a restriction in assigning variables in that they cannot start in the middle of one byte then cross a byte boundary and end in another byte.
Take a look at the Freeform CAN Video Tutorial before starting.
Message Visualizer:
The message visualizer helps keep track of your bit assignments.
Partial Bytes:
If you have a variable representing a switch state for example that is two (2) bits long, both bits must be in the same byte. They can use any one of the bits but must be consecutive and not cross over into another byte.
Whole Bytes:
If you have a variable that is a multiple of eight (8) bits long it must start and stop on a whole byte boundary. As an example allowable bit assignments would be 0-7, 0-15, 0-31, for 8, 16, and 32 bit variables.
Splitting Variables Across Byte Boundaries:
Many times the device you need to communicate with transmits data that is not an even multiple of eight bits and starts and stops in the middle of a byte. In this case create 8 bit or 16 bit variables on whole byte boundaries to be used as temporary holding places for the data. Using a calculation event extract the desired data bits and reassemble them in the right order in the final data variable.
To perform this operation use a combination of bitwise AND operations to mask off bits that are not used and bitwise Shift operations to move the bits into the right location. Reassemble the data using a weighted multiplier on the higher order segments if needed. Note: Freeform CAN variables become double data types once they become a system variable so masking operations need to extend to all 32 bits.
The following Powervision example shows how this is implemented. Read the notes in the configuration tab and in each calculation event.
Download Example - Freeform CAN Crossing Byte Boundaries PV450 2.9.23044
Comments
0 comments
Please sign in to leave a comment.