How to Work with CAN Communication on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 12 - MATLAB & Simulink
Video Player is loading.
Current Time 0:00
Duration 7:48
Loaded: 2.12%
Stream Type LIVE
Remaining Time 7:48
 
1x
  • Chapters
  • descriptions off, selected
  • en (Main), selected
    Video length is 7:48

    How to Work with CAN Communication on C2000 MCUs | Getting Started with C2000 Microcontroller Blockset, Part 12

    From the series: Getting Started with C2000 Microcontroller Blockset

    You will learn how to use CAN communication blocks available in C2000™ Microcontroller Blockset to transmit and receive data between two F28379D LaunchPads over CAN bus communication. A detailed step-by-step guide on how to build models in Simulink® to transmit and receive data via CAN bus communication for C28x MCUs are discussed.

    Published: 13 Jan 2025

    In this demo, let's see how to transmit and receive a signal via CAN communication. For that, I need two launchpads in which one acts as a transmitter and the other acts as a receiver. And the hardware setup is to have the CAN pins on both the launchpads connected together, that is, CAN high to CAN high and CAN low to CAN low.

    Having the hardware set up, let me open a blank Simulink model. Let's first build a CAN transmitter model. For that, I am adding a CAN transmit block. Since I am using F28379D Launchpad, I am selecting the same.

    To give an input to the transmit block, let me add a counter signal. Double clicking on the block, open its block parameter. Let me mention the upper limit 255 and sample time to 1.

    So the counter blocks count from 0 to 255 and then come back to 0, that is, the counter is reset to 0. And the count value increments at every sample time, that is, for every one second, the count value gets incremented by 1.

    Let me open the CAN transmit block. Let me select a CAN module B since the CAN B pins are exposed on the launchpad. And let the mailbox number be 1 and the message identifier be 1, 2, 3. Make sure to have the same message identifier number, both at the transmitter end and at the receiver end.

    Having done that, let me go to the configuration parameters by pressing Control key. Click on Hardware Implementation. Let me choose Ti Delfino F28379D Launchpad.

    Going to the Target hardware resources, make sure you have properly selected the component. Though it automatically gets detected before building, it's better to make sure that you have the proper component selected. To check that, go to the Device Manager. Click on Ports and check for the COM Port.

    It is COM26. And I have set the same over here. The communication between the two DSP happens through CAN. But still, the model, that is, the transmit model, gets built on the first DSP with the help of USB cable that is connected. So it is, again except on serial.

    Now, build, deploy, and start. You can click on the View diagnostics. You could see the model has been built successfully. Let me save this model for my reference.

    Let me open another blank Simulink model and create a receive model. For that, let me add a CAN receive and a scope block.

    Clicking on the CAN receive block opens its block parameter. Let me, again, choose CAN B, mailbox number as 1, and the message identifier number as 1, 2, 3. Same as that, we have set the transmit block with the sample time be B1. Make sure you have the same sample time of the transcript as well as the receive block.

    Let me have another DSP connected to the system by disconnecting the previous one. Make sure at a time you have only one DSP connected. That's because since the two boards are identical, the build can occur at either of the DSPs irrespective of the component that we are mentioning. So to avoid this confusion, let's have only one board connected. But if you are having two different boards, at that time, you can have both the boards connected to your PC.

    Now, let me go to the configuration parameter, navigating to the Hardware Implementation tab. Let me choose the board, F28379D Launchpad. The target had the resources. Click on external mode and make sure you have the proper component selected.

    In my case, for the second DSP, it's COM15. Let me click on OK. Let me save this model for my reference. And now run the model in the Monitor and Tune mode.

    Once you see the model starting to run in the Monitor and Tune mode, have both the boards powered up by connecting the boards via USB to your PC. And now let's open the scope to see the received signal. As you could see, the counter values increment from 0 to 255 and then drops to 0.

    To summarize, I had two DSP board. In the first board, I deployed the transmit model, that is a counter block and the transmit block and deployed into my microcontroller. Then I connected the other DSP board to my PC, where I ran the model in the monitor and tune mode.

    Having the CAN high and CAN low pins connected on both boards together, I am able to receive the signal via CAN communication. This concludes my demo on CAN communication. Thank you.