MATLAB Answers

sarthak
0

Real Time Simulation and HIL

Asked by sarthak
on 9 Jun 2012
Latest activity Commented on by benn nguyen on 29 Dec 2013
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 !!! :)

  1 Comment

Hi sarthank iam interesting in the same topic also iwould perform it on a quadrotor for my graduation project so i wonder if you found some thing useful or not ? did you perfprm HIL using arduino only without xpc target?

Sign in to comment.

3 Answers

Answer by Dan Lluch on 11 Jun 2012
 Accepted 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

  2 Comments

sarthak
on 12 Jun 2012
Can i use xPC target..by making another desktop as target pc because i dont have xPC turnkey..its expensive...i have heard that i can use another pc as target pc..can u please tell me smthing about this???
:)
TAB
on 12 Jun 2012
Yes, you can use other desktop computer (laptop is not recommended) as xPC target. Host PC and Target PC can be connected over ethernet or COM. For detailed configuration see
http://www.mathworks.com/help/toolbox/xpc/gs/f1-21609.html

Sign in to comment.


Answer by Ryan G
on 11 Jun 2012

Depending on how important actual real-time is vs quasi real-time you could use the pacer block from the Aerospace blockset.
For guaranteed real time you could also try real-time windows target.

  0 Comments

Sign in to comment.


Answer by Kaustubha Govind on 11 Jun 2012

AFAIK, the only HIL solution directly available from MathWorks is xPC Target. Please refer to the xPC Target documentation about setting up.
There is currently no MathWorks solution for HIL with Arduino targets, and I'm not aware of any third-party solution either.

  1 Comment

Rtwt supports hil (normal/external simulation)
"Real-Time Windows Target™ provides a real-time engine for executing Simulink® models on a Microsoft® Windows® PC and blocks that connect to a range of I/O boards. It enables you to create and control a real-time system for rapid prototyping or *hardware-in-the-loop* simulation"

Sign in to comment.