MATLAB Answers

arduino code not working with MCR

2 views (last 30 days)
A
A on 30 Nov 2016
Commented: Jamie Rodgers on 4 Nov 2018
I was able to successfully run my Arduino-based code in MATLAB- but when I tried to compile the code and run under MCR, it returns errors about Arduino. Does MCR not support Arduino? (2016B)

  0 Comments

Sign in to comment.

Answers (1)

Sid Jhaveri
Sid Jhaveri on 5 Dec 2016
Unfortunately, the support package for arduino is not deployable as of now. The developers are aware of this issue. They may consider providing support in a future release of MATLAB.

  1 Comment

Jamie Rodgers
Jamie Rodgers on 4 Nov 2018
Its a bit pathetic that this functionality is not supported. You have to ask what is the point of an arduino support toolbox that ties up a whole matlab licence if you want to actually do anything with it? I ran into exactly the same problem, and am annoyed at the effort to deploy the undeployable that I wasted until I found this answer. We were trying to use an arduino to control some hardware, and wanted to write (and deploy) a matlab GUI to create a user interface. We wanted to run this on alot of systems, and didn't fancy forking out £2K for a matlab licence for each one, for what was basically a straightforward instrumentation app, not a complete SDK.
Anyway we resolved the problem by not using the Matlab arduino support add in at all. (If it can't be deployed it is a waste of time frankly, imo).
Instead we used the arduino inbuilt IDE (free software) to create an individual sketch file for each of the individual low level commands that we needed to actuate via the GUI (e.g set pin 10 to high). This was quite easy to do once we did a modicum of research into the aduino language. If you can program matlab, arduino is within your capability.
Then we created stand alone binaries (bin files) from each of the sketch files in the arduino IDE.
Then we built matlab functions that used 'system' command to invoke these bin files as needed, and created higher level matlab functions that used sequences of these 'bin' files to create the more sophisticated operations we wanted.
Finally, we built our GUI in Guide and included filepaths to the bin files that we were using within the code.
We deployed the matlab code and then dropped the bin files to the filepaths that the system commands were targetting.
Bingo.
It was a bit of a kerfuffle to set up, but not hugely so, and the final application does exactly what we need, and doess it very well. Fewer problems than with the original GUIs we used from the mathworks interface that used the Arduino support add in in fact.
It is a bit pathetic that Mathowrs don't support deployment of their hardware add ins though! The cynic in me might suggest they are counting on selling licences off the back of people developing the apps they need and finding that these won't work when deployed?

Sign in to comment.

Tags