Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
8 years, 10 months ago.
F401RE Simulink/Matlab communication
Is it possible to establish a duplex communication between Simulink and F401RE board? I would like to run a program in Simulink and send data to f401re board that controls a real hardware. F401RE boards measures the analog signals and sends the read values to the Simulink.
I am new to all this and having difficulties with the programming. however , I have got the two F401RE boards to communicate with each using SPI. But, I am really struggling with the matlab communication part.
Ideally some sort of SPI communication between Matlab or Simulink and F401RE will be very helpful. I will appreciate your suggestions.
1 Answer
8 years, 10 months ago.
A serial port is the simplest way assuming it's fast enough. An FTDI TTL level USB serial cable will normally give you 921600 baud without any issues. If you need more speed then use the F401RE as a USB serial device, that will give you more bandwidth than a physical serial port.
SPI would be faster but the hardware for the PC side of an SPI link is harder to find. Serial ports and/or serial over USB has the advantage that just about everything supports it and the hardware is easy to find.
Dear Andy,
Thanks for the information. Is there any example project or similar that I can use as a platform to build my program. I am new to all this and having difficulties with the programming. I have however got the two F401RE boards to communicate with each using SPI. But, I am really struggling with the matlab communication.
I have followed some code example describing Matlab, RPC etc https://developer.mbed.org/cookbook/Interfacing-Using-RPC
However, there are errors in the example projects and also F401RE does not seem to be defined in the example project.
posted by 04 Jan 2016I'd skip RPC, the examples are all out of date and don't work with the current libraries.
There are lots of examples of how to send and receive data over a serial port. It's slower to send values are text but that does make the matlab side of things a lot easier, matlab has all the required support built in as standard.
This thread https://developer.mbed.org/forum/helloworld/topic/2579/ is showing communication between two mbeds over serial. There is no reason why the sender can't also be a receiver at the same time.
https://developer.mbed.org/cookbook/Interfacing-with-Matlab#serial-communication gives details of using a raw serial protocol to talk to an mbed from matlab.
posted by 04 Jan 2016Thank you. With your suggested link, Matlab script/code can receive data from F401RE https://developer.mbed.org/cookbook/Interfacing-with-Matlab#serial-communication
However, this method does not seems to be stable. Matlab runs for a little while and then it fails to receive data.
For duplex communication, I tried putting fprinf command in the matlab code, but could not succeed. I Will continue to search for possible ways to establish two way communication.
posted by 04 Jan 2016