Arduino, Mac OS10.9 (Mavericks) and Matlab2013b

2 次查看(过去 30 天)
I found it tricky to get an Arduino-based robot package to talk to Matlab 2013b using Mavericks (OS 10.9). Here are my notes on my solution which borrows heavily on what others have already done. I suspect that the issues, and the solution, will apply to Arduinos in general.
Install support package for Arduino . This can be done in Simulink from the Tools menu by choosing Run on Target Hardware and then Install/Update Support Packages. I liked to first download the support package to a known directory and then rerun this process and install from the folder where I just downloaded it. I like to do it this way as I found that Simulink didn’t always recognize it was installed so this was a faster way to re-install the 2nd time around (i.e. no downloading).
Download Xcode . To get a simulink model to run on your target hardware (the Arduino on the MinSeg), you have to build your model into C code, compile into an executable and then deploy the executable to the target. The first two steps requires a Mac OS X C-compiler that is supported by Simulink. This is Apple’s Xcode. Search Google for it and then download it. It is free.
Configure Xcode . You need to download the command line tools for Xcode 5.0x. I think the purpose of these tools is to provide Simulink with an interface to access the compiler included with Xcode. These tools apparently used to come natively installed, but now they don’t. Here’s a link to describing how to do it: http://www.computersnyou.com/2025/2013/06/install-command-line-tools-in-osx-10-9-mavericks-how-to/
Patch Matlab to use Xcode 4.3 and higher . At the time of writing this, Matlab doesn’t yet have a patch for Xcode 5.0x. It also doesn’t have a patch for an version of Xcode that works with OS10.9. To begin a fix, Iinstall the "optsPatch10.8.patch” as described here: http://www.mathworks.com/matlabcentral/answers/94092
Edit the mexopts.sh to work with OS10.9 and Xcode 5.0x . The mexopts.sh file is an options file that tells the mex command some details that are user configurable. To find the file, go to Applications, select Matlab 2013b and choose “Show Package Contents”. Navigate to “bin” and the options file is there. You want to edit a few lines in here as described here: http://www.mathworks.com/matlabcentral/answers/103258#answer_112685. In short, the compiler now has a different name, so it needs to be changed, and the SDKroot directory has also changed.
Tell Matlab there is a new mex options file. To do so, type “mex -setup” at the command line. Choose 1 for the new options file and then choose y to overwrite the old file in the directory for which it looks for the options file (~/.matlab/R2013b/mexopts.sh). The overwrite is important - it won’t work without it.
Build Mac-compatible versions of S-functions . This is not an issue for the Arduino library but is an issue for the s-functions that come bundled with the MinSeg code. This code includes s-functions built for Windows 32 bit computers (.mexw32 files) but not for Mac 64 bit computer (.mexmaci64 files). Once everything is working properly, building these mac compatible mex files is simple. Open the s-function block in your simulink model, and choose Build in the upper right corner. If everything is working properly from the above steps, this should proceed without error.
Deploy Model to Hardware (i.e. Don’t use External Mode). At the time of writing, external mode could only be used with very long loop times, making any real-time control project impossible. Instead, write your model such that it outputs to serial the signals you are interested in recording or debugging. Then, deploy your model to the hardware and read in the serial signals using a separate program.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by