CAN Receive not working (the Sample time parameter) ??
1 回表示 (過去 30 日間)
I am using MATLAB R2012b, and I am playing with the demo for the Vehicle Network Toolbox which is called "demoVNTSL_CANCommunication".
I changed some parameters. I changed the block "CAN Transmit ID 500" 's Message period to "0.250", so it will send message 4 time 1 second. And I changed the block "CAN Receive" 's "Sample time" to "0.5" and "Number of messages received at each timestep" to "1", which means it receives only 2 messages per second even though the 4 messages being sent per second. But the simulation result shows it is still receiving 4 messages per second, as shown in the capture image.
Why is that? Basically what I want to do is control the frequency of message receiver. For example, there are 10 messages being sent on the CAN bus per second, but the receiver will only pick one of them per second.
回答 (1 件)
Shankar Subramanian 2015 年 5 月 27 日
Setting the number of messages received per timestep does not drop the messages queued from transmit. It still receives them at the subsequent timestep. The Transmit block ensures that the data gets transmitted at the right wall-clock time. However, the receive still runs in Simulink simulation time and returns data every timestep. The differing aspect here is that CAN Transmit block "Message Period" is real-wall-clock time and CAN Receive blocks "Sample time" is simulink simulation timestep.