Hi,
I am currently using simulink for simulation of aircraft and I have been
trying to use real time input (from a joystick, keyboard or mouse) to
change the control parameters whilst the simulation is running. I could
not find anything at all in Matlab, so i wrote a C program to do this
and compiled it to MEX. However, when the mex file is called, it seems
that all keyboard input is disabled. I would be extremely grateful for
anyone who has a solution.
Thanks in advance
Michael Crump
There are quite a few ways to do this, depending on how exactly you want to
implement things.
If you would like to control the parameters with the mouse and keyboard, you
can click on any block within Simulink and change parameters while it is
running. You can also create a MATLAB Gui with the set_param command as the
callback to change things.
There are some graphical solutions that are already done for you to make
this easier, such as the Dials and Gauges Toolbox. You can check out some
aircraft demos with a software joystick at:
http://www.mathworks.com/products/dialsgauges/
and one of our Connections Partners, Altia Design at:
http://www.mathworks.com/connections/product.cgi?id=14
As far as a physical joystick connection into the Simulink model, the best
way to do this is to write a C-MEX S-function that accesses the serial
port. Take a look at the documentation for S-functions in your Simulink
manual. Basically, you will place the call to access the data inside the
S-function and output this as a block inside of your Simulink model. Having
this inside of a S-function will allow you to change the joystick while the
simulation is running.
HTH.
Paul