|
Example |
Top Previous |
|
Example1:
We are interesting in CAN ID=888 standard data frame, and CAN ID=999 extended data frame. It has 2 data, one is "uint16" (Little-Endian) and the other is "uint8" in CAN ID=888 standard data frame. So DLC will be 3 automatically. It has "int16" (Big-Endian) in CAN ID=999 extended data frame. So DLC will be 2 automatically. Please see screenshot of model below:
Please open "your CAN Controller library folder"/examples/example1_receiveData.slx (You must change USB serial Port number in CAN_setup block according to your physical USB port number)
Example2:
Every 300ms, long frames (CAN ID =555 standard data frame) will be coming. It has 3 data items of int32 type with Little-Endian. The first frame number is 0,
Please see screenshot of model below:
It has "Wait" 100ms block (we make assumption: long frames will be done within 100ms). This "wait" block will lead to actual sampling time=100ms besides simulated sampling time=0.1 sec. Please see "catchCANID" block help in library. "catchCANID" block will catch the last frame of CAN ID=555 standard long frames, and create one sampling time pulse. This pulse will create a function call signal by function call generator block. This signal triggers "Function call sub-system" ("Receiver long frame" block) to be called once.
Please see inside of "Function call sub-system" below:
"RxCANBusData" block will get long frames' data output. And at last , we use Demux block to divide vector to 3 variables which are displayed in 3 Scopes.
Please open "your CAN Controller library folder"/examples/example2_receiveData.slx (You must change USB serial Port number in CAN_setup block according to your physical USB port number)
Example3:
The same as Example2. However, we disable "Auto-refresh" in "CAN setup" block. We use "refresh" block manually when the last frame of long data frames coming. In example2, it has risk of missing some long frames if sampling time is exact between the middle of all long frames. This example 3 can avoid this situation.
Please see screenshot of model below:
. In CAN setup block, we disabled "Auto-refresh" function. And when we caught the last frame of "555" data frames, CatchCAN block will output one pulse. This pulse will give to 3 blocks. One block is 300ms wait which is the same as "long frames" broadcast period. And the 2nd block will create refresh. So all receiver frames will be updated. The 3rd block will create one "function call signal".This signal triggers "Function call sub-system" ("Receiver long frame" block) to be called once. The inside of "Function call sub-system" is the same as one in example2. "RxCANBusData" block will get long frames' data output. And at last , we use Demux block to divide vector to 3 variables which are displayed in 3 Scopes.
Please open "your CAN Controller library folder"/examples/example3_receiveData.slx (You must change USB serial Port number in CAN_setup block according to your physical USB port number)
|