Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am working on a complicated robotics project which involves MATLAB image processing algorithm and LEGO MINDSTORMS interface as well as an Arduino. The system works dependently in a sequence according to each reading either from the Arduino or to give a command to the LEGO bricks.

The question here is can I replace the processing from PC to another external microcontroller like Raspberry Pi for example but without converting the matlab code as installing MATLAB itself on the microcontroller to compile the code? If so, what microcontroller would be convenient for this and if no what is the best solution to control the system without the need of a PC.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Yes, there are a few processors powerful enough to run (some) programs written in the MATLAB language directly, replacing a PC.

So far, I only know 4 ways to do that:

If you have a motherboard powerful enough to run Linux, such as as BeagleBone or the Raspberry Pi or the Cubieboard, you could:

  • Install the open-source Octave tool, which can understand and execute many MATLAB-language programs directly. "Running Matlab Computer Vision on Raspberry Pi with Linux Octave. Part 1."(a)
  • Install the open-source Scilab tool, which can understand and execute some MATLAB-language programs directly.
  • Install the open-source FreeMat tool, which can understand and execute some MATLAB programs directly.

Often these approaches either don't bother producing any graphics at all on the embedded system, or use the open-source matplotlib library that is designed to be easy to use from within MATLAB as well as possible to run on any machine that can run Python -- even machines that can't run MATLAB.

While the Raspberry Pi can run (some) programs written in the MATLAB language using the above approaches, alas, the Raspberry Pi isn't quite PC-compatible enough to run MATLAB. "MATLAB for Linux on the Pi? No."(b)

If you have some "PC-compatible" (x86 processor) mini-PC, such as many PC104 and (all?) PCI-104 embedded systems, or the NUC, or the huge number of microATX and smaller motherboards, you could use any of the above options, or you could also:

  • Install MATLAB for Windows or MATLAB for Linux. "MATLAB for Linux system requirements"(c) (d) "Install Matlab in Linux" (e)

alternatives that don't quite meet that criteria

You probably already know that "running MATLAB code directly on a stand-alone microcontroller" is not that popular; other approaches include

  • Using MATLAB to develop Simulink models that run as stand-alone applications. "Raspberry Pi Support from Simulink" (f); "Run Simulink models on ... Arduino ... BeagleBoard ... Gumstix ... Raspberry Pi ... LEGO Mindstorms ..." (g) "Raspberry Pi Programming using Simulink"(h) (i) "MATLAB / Simulink on BeagleBone Black"(j) "Rapid BeagleBoard Prototyping with Matlab and Simulink"(k)
  • running MATLAB code on a PC that communicates back and forth with a microcontroller, to do things that neither one could do alone. "the MATLAB Support Package for Raspberry Pi Hardware"(l); "ThingSpeak Support from MATLAB ... with Arduino"(m)
  • Use MATLAB to try out a bunch of high-level algorithms and use that implementation to estimate how much RAM and processing power it needs, then later re-implement those algorithms from scratch to run stand-alone on practically any microcontroller with at least that much RAM and processing power. (Typically in Forth or C or C++, since practically every microcontroller has a compiler for those languages and hardly any other languages).
share|improve this answer
    
Thanks so much this was really helpful –  Ahmed Mesbah Aug 23 at 7:06

You can export C code from MATLAB using MATLAB CODER and compile that with a suitable compiler (or cross compiler). Any suitable platform probably has a C compiler available.

Whether the resources (such as RAM) are available on a microcontroller to run the code at all, and if at all, sufficiently fast, are other questions.

It's also possible to export hardware description language code from MATLAB if you need high speed, which can be used to program an FPGA.

The add-ons are not inexpensive if you're in a commercial environment (I think the academic terms are considerably more generous).

share|improve this answer
    
The problem here that I'm in a doubt that some functions MATLAB CODER cannot convert it into C and not supported by it so, can a microcontroller act as a PC in operating MATLAB and compiling the code or either installing an OS that support MATLAB?and if there any possibility how it could be done and through which microntroller?(this was specifically the question) –  Ahmed Mesbah Aug 22 at 13:53
    
No you cannot run MATLAB itself on a microcontroller unless the microcontroller is essentially a PC running an operating system supported by MATLAB. –  Spehro Pefhany Aug 22 at 13:54
1  
Ok thanks for your help –  Ahmed Mesbah Aug 22 at 13:59
    
Apart from 'plain' Matlab Coder, there is also the Embedded coder extension which is meant specifficaly for embedded MCUs/MPUs including AVRs. –  venny Aug 22 at 14:07
    
@venny He wants to run native code, not use MATLAB as a cross-development system. –  Spehro Pefhany Aug 22 at 14:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.