MATLAB: Real Time Simulation and HIL

MATLABreal timesimulinkSimulink Real-Time

Hi
I am currently working on real time simulation and hardware in loop simulation. I have only some knowledge about this. I have an ARDUINO mega and uno board. I am average with simulink. I have matlab 2012a.
Can you please help me how to start and what all things will be required. I don't want to use xPC target due to budget issue. So please suggest how can i start with HIL and real time simulation.
Cheers!!
[Merged information from duplicate question]
Please suggest me how can i perform hardware in loop and real time simulation using matlab and simulink.
I am pretty good with simulink and currently learning matlab.
I want to perform these things for my quadrotor.
PLEASE HELP !!! 🙂

Best Answer

without getting into some of the loaded terms of 'real-time' and 'HIL' and what that means to folks...
Assume you want to put algorithms on some target processor (you call out that you have some arduinos), and you want that platform to execute that algorithm in 'real-time' while talking to hardware (potentially both inputs and outputs)...
With R2012a, go ahead and run the targetinstaller to get some of the Run on Target Hardware support: http://www.mathworks.com/products/simulink/simulink-targets/ Here is a video of the install process: http://www.mathworks.com/products/simulink/simulink-targets/videos/introduction-to-simulink-support-for-target-hardware.html
Note that even these arduionos can have more feature rich support from MathWorks tools, such as the Embedded Coder support package: http://www.mathworks.com/matlabcentral/fileexchange/30277 There was a previous post/answer for more infor on some of the differences.
There is not RTOS running on the arduino, but there is an overrun flag that flips a bit in case the processor isn't keeping up, so at least you know it isn't keeping up and try to change something. You will get more fidelity/capability as you move to RTWT, xPC Target, and then potentially other embedded platforms. It is true that xPC Target is the support from MathWorks for full featured and commercial strength offerings, especially when paired with Speedgoat hardware to form xPC Target Turnkey. There are also many third party options (and you can look at the connections program for those).
Lastly generally the application and requirements drive the real-time and HIL solution needed, which would likely push you in one of the directions that folks have suggested.
Good luck and have fun learning!
HTH Dan