How to address Rasperry Pi conection when usin Simulink in Connected IO mode?

조회 수: 2 (최근 30일)
Jon Remen
Jon Remen 2021년 12월 15일
댓글: Jon Remen 2021년 12월 16일
Hi,
Normally, to connect the raspberry to Matlab/Simulink you need to use the raspi command, e.g.:
mypi=raspi(ipaddress,name,pw);
Once the connection is made, you just have to use mypi to address the Raspberry board.
On the other hand, if you want to use Simulink in Connected IO mode, you have to clear your connection with the Raspberry, and when running the model Simulink will make a connection with the Raspberry.
If I try run mypi=raspi once Simulink is running it says that a connection already exits, so there is no variable in the workspace addressing the Raspberry.
My question: While running Simulink in Connected IO mode how can I address that connection (mypi), for example, to use readDigitalPin(mypi,pinNumber) on an App Designer application? Is it even possible?
Thanks in advance.

답변 (1개)

Prasanth Sunkara
Prasanth Sunkara 2021년 12월 16일
Hi Jon,
You can only have one connection to the Pi, either from MATLAB Connected I/O(through r = raspi()) or Simulink Connected I/O. But not both at the same time. If you attempt to make connection to the same Pi from MATLAB while Simulink IO is running, you would see the error you mentioned above. Vice-versa would also cause an error.
Under the hood both MATLAB and Simulink Connected I/O, communicate with Pi using same technology. The communication channel allows only one connection at a time to avoid any conflicting commands send to Pi from two different places. Hence it is not possbile to do both.
If you want to control your Pi through MATLAB simultaneously, please use a Simulink workflow that does not use the same communication channel as that of Connected I/O. You can use either Simulink Monitor & Tune workflow(aka external mode) or a complete model deployment.
-Prasanth
  댓글 수: 1
Jon Remen
Jon Remen 2021년 12월 16일
Hi Prasanth,
First of all, thank you for answering.
I may have explained myself wrong, but understanding that you can't make multiple connections to the same board I wanted to know if there was a way to make a communication object of the existing connection, created when using Simulinc in Connected IO mode.
I looked further and finally found that instead of the raspi command, you can use the raspberrypi (r = raspberrypi()) command to address the existing connection.
Still, thank you for your time.
-Jon

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Raspberry Pi Hardware에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by