CAN communication in NVIDIA Jetson Nano

Hi,
I am trying to interface a IMU sensor that has CAN communication with NVIDIA Jetson Nano and visualize the data in simulink and use the data in my model.
But as the NVIDIA Jetson Nano doesn't have inbuilt CAN interface, I would like some inputs on how this can be done using the MATLAB/Simulink support packages for NVIDIA Jetson.
Can some one give me inputs on how I can integrate CAN communication in a Jetson Nano and use the data over CAN within my Simulink Models.
Thank you

 Accepted Answer

Hi Vasanth,
Unfortunately, on Jetson Nano there are no built-in CAN controllers. You can refer to this post on the NVIDIA blog. In the post they confirm that there are no CAN controllers on Jetson Nano. In addition, they provide a CAN solution through SPI interface, you can follow that approach if you want CAN only IMU integration. IMU sensors can be interfaced through I2C as well. The current sensors we support through Simulink uses I2C. I suggest if you are not concerned about the interface then you can take advantage of these sensor blocks in the support package "MATLAB Coder support package for NVIDIA Jetson and NVIDIA DRIVE Platforms".
Thanks,
Ramakrishna

8 Comments

Hi Ramakrishna,
Thank you for the reply.
I want to interface via CAN only as the sensor supports only that and also I have other control units that send their data via CAN which I would like to bring into Simulink as inputs to my models developed and run it on NVIDIA Jetson Nano.
I went through the blog that you shared, and my doubt here is once I use a MCP2515 CAN shield and use SPI to interface with NVIDIA Jetson Nano and follow the steps given in the blog, what are the next steps to visualize that CAN data within Simulink and use it as inputs to my model. Can you walk me through the steps ? Are there any blocks/functions that I can use to achieve the same?
Also instead of using MCP2515 CAN shield, can I use CAN-USB converters and use the Serial write/read block within Simulink to read and write CAN messages. If yes, my doubt over there is, how do I selectively extract specific CAN ID data with the Serial write/read blocks from the CAN message pool that is coming in ? Is there a way around that ?
And during my research, I came across setting up Virtual CAN, Will this be of any use to solve the issue ?, Can you give me some insight on what basically is the use case of Virtual CAN?
Regards,
Vasanth Krishnan
Hi vasanth,
Please find my responses below.
what are the next steps to visualize that CAN data within Simulink and use it as inputs to my model. Can you walk me through the steps ? Are there any blocks/functions that I can use to achieve the same?
If this approach creates the availability of CAN interfaces on the Jetson then you can directly use those interfaces. usually, when you connect CAN controllers then you will see can0, can1, etc. interfaces. In this case, you can use CAN Receiver and CAN Transmitter blocks of the support package.
Also instead of using MCP2515 CAN shield, can I use CAN-USB converters and use the Serial write/read block within Simulink to read and write CAN messages. If yes, my doubt over there is, how do I selectively extract specific CAN ID data with the Serial write/read blocks from the CAN message pool that is coming in ? Is there a way around that ?
Yes, you can use, the USB CAN device most of the times creates the interfaces can0, can1, etc. You can use the exisitng CAN blocks in the support package to access devices connected to these interfaces.
I came across setting up Virtual CAN, Will this be of any use to solve the issue ?, Can you give me some insight on what basically is the use case of Virtual CAN?
Virtual CAN is asoftware emulated CAN interface, it is not a physical interface but helps to validate the CAN workflows without connecting the actual CAN hardware. This helps in prototyping/modelling our CAN based workflows before incorporating into the actual/bigger workflows.
Thanks,
ramakrishna
Hi Ramakrishna,
Thank you for the response, it was really helpful.
I have created the can0 and can1 now with two SPI CAN shield interfaces and checked the same with ifconfig.
But while executing a very simple communication check like the following, by connecting the CAN H and CAN L of the shields together,
I am getting the following error,
I am not able to figure out how to debug and rectify this. What is the reason for this error ? The steps I followed are similar to the second half of " https://uk.mathworks.com/help/coder/nvidia/ug/jetson-can-bus-traffic-sign-detection.html ".
Can you give me some insights on the same ?
Regards,
Vasanth Krishnan
Hi Vasanth,
In this case, some of the external mode signals need dynamic memory, so we should configure the Simulink accordinlgy. Can you disable the 'Static memory allocation' setting in the Code Generation->Interface->External mode configuration, if enabled.
Thanks,
Ramakrishna
Hi Ramakrishna,
I am not able to find that option in the settings. Can you share some screenshots of the same ?
The following are the options available in my settings,
Can you please point out to the particular option ?
Thank you,
Vasanth Krishnan
Hi Vasanth,
Do you have "Embedded coder" installed? if not then these setting will not be available.
Thanks,
Ramakrishna
Hi Ramakrishna,
I have rectified the error and its now working good. I got the CAN working in the Jetson Nano both via USB-CAN as well as SPI and I am able to visualize the data within Simulink.
Thank you for your inputs,
Vasanth
Hello Vasanth,
could you share your setup with the SPI communication? I am thinking of using the jetson nano with some CAN devices and want to find out how to do it. My main concerns are:
  • What CAN shield are you referring to? When I search for "MCP2515 CAN shield" as you mentioned, I only see shields for Arduino.
  • To which pins on the jetson nano should the shield be connected?
  • How did you configure the CAN receive and CAN transmit blocks in your model?
Thank you for your help.

Sign in to comment.

More Answers (0)

Categories

Find more on Get Started with GPU Coder in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!