Nvidia Jetson Nano I2c issues in matlab/simulink

12 次查看(过去 30 天)
Hello dear community,
I want to read the I2C adress from my Nvidia Jetson Nano via the command scanI2CBus(jetsonObj,m 'i2c-1') in matlab.
My Laptop and the Nvidia Jetson Nano are in the same Network... Previous I have checked it with the command jetson('IP-Adress','name','password')
I have already installed all add-ons like Support Package for Nvidia Jetson, Matlab Coder, Instrument Control Toolbox...
However I get an error with the description: Unrecognized function or variable 'scanI2CBus'
I have tried it already with the proposed solution from https://de.mathworks.com/matlabcentral/answers/871283-jetson-nano-i2c-port-access but it still shows the error from above.
-----------------------------------------------------------------------
Regarding i2c I get errors like Unrecognized function or variable i2cdev.
I have only found solutions for rasperry pi and arduino, but nothing for Jetson Nano.
Has anybody a solution for this problem? I would be very thankful for any support.
Thanks
Burak

回答(1 个)

Rushikesh
Rushikesh 2024-10-9
Hello Burak,
I found out that MATLAB does not support ‘scanI2CBus’ function yet for NVidia Jetson as mentioned in MATLAB documentation.
But a workaround I have found out is to use ‘system’ function which let you execute command in the Linux command shell on NVIDIA hardware. To perform an I2C bus scan on the Nvidia Jetson Nano using system commands, you can use the ‘i2cdetect’ utility, which is part of the ‘i2c-tools’ package.
Example:
% Command to scan the I2C bus
command = 'i2cdetect -y 1';
% Execute the command on the Jetson Nano
[status, cmdout] = system(hwObj, command);
Hope this helps.
  2 个评论
Burak Balci
Burak Balci 2024-10-9
Hello Rushikesh ,
Thank you for the answer. I have already been able to find out the I2C address via the Jetson Nano. However, I have the difficulty to controll the Jetson Nano via Simulink and I2C. I will give you more details to understand the problem better.
As part of a university research project, we are working in a small group to develop an autonomous model vehicle that will be controlled via Simulink and Nvidia Jetson Nano.
The hardware is already fully assembled and we would now like to carry out initial tests to control the pins for the steering servo and motor. To operate the steering servo and the motor, we have connected a PWM driver between the Jetson Nano and the corresponding components. To do this, we use pins 3 and 5 to connect the PWM driver via I2C.
In Simulink, we found that reading and writing values is only available for GPIO pins, which excludes pins 3 and 5. We encountered similar problems in the Mathworks forum, but the proposed solutions did not help us (see https://de.mathworks.com/matlabcentral/answers/871283-jetson-nano-i2c-port-access).
If we enter in the Matlab command window regarding I2C, we always get the error message: “Unrecognized function or variable i2c...”.
In contrast to Jetson Nano, there are already blocks for Arduino Nano and Raspberry Pi.
Are there already solutions for our specific application and if so, what do they look like?
We would be very grateful for any support and advice.
Thanks
Burak
Rushikesh
Rushikesh 2024-10-10
As per my knowledge, as of now MATLAB/Simulink does not support 'I2C' commands for Jetson nano. But you can control PWM Driver from Jetson nano in real time using Jetson linux terminal.
You can use 'i2cset' and 'i2cget' commands in jetson linux terminal to read and write to/from I2C registers.They are available in same 'i2c-tools’ linux package.
Additionally, if you still want to control it from simulink, you can use MATLAB Function Block to execute 'i2cget' and 'i2cset' commands using 'system' function (that will run those commands on linux terminal) and can pass/get data to/from Simulink.

请先登录,再进行评论。

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by