Raspberry pI work together with arduino

12 次查看(过去 30 天)
It is possible combine the arduino and the raspberry pi in the same project of simulink in MAtLAB. Can I do a project in my windows pc, but I want to control the arduino, that arduino is connect on the raspberry pi????

采纳的回答

Murat Belge
Murat Belge 2014-4-15
The easiest way to do what you describe is to use the MATLAB interface for Raspberry Pi together with a Simulink model running on Arduino. Download and install MATLAB Support Package for Raspberry Pi Hardware and Simulink Support Package for Arduino Hardware first and foremost.
Create a model that runs on Arduino and receives commands via a Serial Receive block. Deploy this model to your Arduino board. Then connect your Raspberry Pi and Arduino boards using serial protocol. You can connect an Arduino to a Raspberry Pi using serial in a couple of ways. The following site describes different methods: http://conoroneill.net/connecting-an-arduino-to-raspberry-pi-for-the-best-of-both-worlds/. I personally used option 4.
You can then connect to your Raspberry Pi from MATLAB using the raspi API, create a serialdev object and send commands to your Arduino over Raspberry Pi. Make sure that when you create a serial object, you use '/tty/AMA0' as the port and specify the correct baud rate (usually 9600). The Simulink model running on the Arduino will receive serial commands you sent from your host PC running MATLAB. It is up to you to define what the model running on Arduino does with the serial commands you sent.
  1 个评论
paul
paul 2014-4-16
thanks for the answer, its a good idea
But I have other question, Can I use raspberry pi with simulink, out of the local network???
the idea is I want to work with the raspberry pi in my office using simulink, but the raspberry pi is connected in my home

请先登录,再进行评论。

更多回答(2 个)

Murat Belge
Murat Belge 2014-4-21
Yes you can. You need to ensure that your work computer can communicate with your Raspberry Pi connected to your home network. This usually means that you need to do port forwarding on your home network to direct the TCP traffic intended for Raspberry Pi. The Support Support Package for Raspberry Pi Hardware uses the following ports:
SSH: TCP/22
Raspi interface: TCP/18725 and UDP/18725
Simulink External Mode: TCP/17725 (user settable)
You need to port forward incoming Ethernet traffic coming to your home network for the above protocol/port pairs to your Raspberry Pi. You also need to find the IP address of your home network. Read the following section in the documentation to setup your Raspberry Pi to send you an e-mail indicating its IP address: http://www.mathworks.com/help/simulink/ug/configure-raspberry-pi-hardware-to-email-ip-address-changes.html
You can also subscribe to a dynamic DNS service and register your Raspberry Pi to have access using only the host name.

Ryhor Prakapovich
Ryhor Prakapovich 2016-7-22
编辑:Ryhor Prakapovich 2016-7-22
Hello, two wonderful examples you can see in the following projects:
In the second project was developed by the software serial interface Block for Simulink Support Package for Raspberry Pi Hardware!

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for Arduino Hardware 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by