CAN Receive not working (the Sample time parameter) ??

1 回表示 (過去 30 日間)
Xia 2014 年 7 月 18 日
回答済み: Shankar Subramanian 2015 年 5 月 27 日
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
Shankar Subramanian 2015 年 5 月 27 日
Hi Xia,
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.


Help Center および File ExchangeVehicle Network Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by