How do I Interleave Two Different CAN Messages on the Same Channel?

1 次查看(过去 30 天)
I am looking to send multiple interleaved messages on the same CAN Channel, with one message being sent at some discrete set of times (0, 40, 80, etc.) and another message being interleaved on the same channel, sending at another set of discrete times (20, 60, 100, etc.). I have tried making use of the Periodic Message transmission, but the messages simply send at the same time.
How do I go about interleaving the message in the desired fashion?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2019-4-22
I wanted to preface this by mentioning that Vehicle Network Toolbox is not a true real time simulation software. As such, we cannot guarantee that the messages being generated by the CAN Transmit in Simulink will necessarily be perfectly transmitted at the specified rates. For slower sample rates, this is usually not an issue, but for very rapid sampling this can become more apparent. Also since the transmission rate will be tied to the simulation, the more computationally intensive your simulation is, the more likely it is that the messages could lag.
That being said, I have attached an example model that demonstrates how you can interleave messages of different types on the same channel. The model name is "interleavedExample.slx".
Essentially the model works as follows. There are two different messages being sent to the same channel, MathWorks Virtual 1, Channel 1. Each message is packed and transmitted inside one of the enabled subsystem blocks in the model.
Enabled Subsystem Reference:
When each subsystem is enabled, it will be active, packing and sending the data in the form of the specified message type at the sample rate of the signal being fed into the subsystem (0.02 seconds in our case).
Each subsystem is governed by it's own pulse generator block, telling the subsystem when to activate and deactivate.
These pulse generator blocks are what enforce the delay between the subsystems and govern the interleaving. They are configured to alternate every 0.02 seconds, which creates the desired interleave timing for the messages.
One final thing that you need to configure is to set the pacing of the simulation so that it approximates real time. To do this you need to enable Simulation Pacing, found here:
Once this is set then you should be able to run the model and see the counter data being sampled by the alternating messages:

更多回答(0 个)

标签

尚未输入任何标签。

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by