Support for Matlab/Simulink/RTW in RTAI User Space
==================================================

This directory contains the support files required to run in hard/soft 
real-time a code generated from a Matlab/Simulink/RTW model. The Matlab 
version supported is 6.5 Release 13. The support has been completely 
re-written using "net_rpc" and it is thus native to RTAI: no more VxWorks 
wrappers. The code is generated as a standalone executable, so Matlab/RTW 
is used only to build the Simulink model and to create the corresponding 
[*.c,*.h] files. Its external mode is now to be carried out wholly by 
RTAI-Lab.

If you are familiar with RTW, and you must, it will not be difficult to
understand what follows.

What you find in this directory
===============================

- rtai.tlc: is the Target Language Compiler file to be used for RTAI. 

- rtai.tmf: is the template Makefile to be used in Matlab/RTW. In this file 
	    you should check and prossibly modify only the following list 
	    of directories, in order to be compatible with your own 
	    configuration:
		LINUX_HOME = /usr/src/linux
		RTAI_HOME  = /usr/src/rtai

- rtmain.c: is the real time main program that allows the model to be 
	    correctly executed under RTAI.
    
- setup.m:  is a matlab script that simply adds the devices directory to the 
	    "matlab" path.

- devices/rtai_scope.c: is the Simulink S-Function that performs the 
			multi-trace real-time scopes

- devices/rtai_scope.mdl: is the Simulink Library of RTAI Scope

- examples/test.mdl: is a Simulink model to test the support.

How to install the support
==========================

- create under $(MATLABROOT)/rtw/c a directory called rtai
  (where $(MATLABROOT) is the root directory of Matlab, e.g.
  /usr/local/matlab)

- copy "rtmain.c"
       "rtai.tlc"
       "rtai.tmf"
       "setup.m"
  and the directory "devices" to $(MATLABROOT)/rtw/c/rtai

- from the Matlab session run "setup"

How to test the support
=======================

- open the test.mdl example

- generate the code from the RTW menu

- compile the code from the directory "test_rtai" (typing "make -f test.mk"); 
  in general a directory called "modelname_rtai" is created at the generation 
  stage, where modelname is the name of the Simulink model

- load the required rtai modules (you can use the script "loadrtai" in the 
  RTAI-Lab tree)

- run the real time code "./test [options]" (to see the list of options type 
      "./test --usage")

- run the RTAI-Lab (rtailab or xrtailab) to communicate with the real time 
  code locally or remotely

For the execution options available to run the RTW generated standalone code
read the file READ in the main RTAI-Lab directory.

A simple example is provided in the directory example found here. For real 
applications you might have to rely on material found in the directory 
lxrt/rtw. Apart from what said above RTAI-Lab usage is not different from
standard RTW external mode so all waht available in Matlab and within lxrt/rtw
can be used unchanged and any "already running" application you have can be 
supervised by RTAI-Lab just by remaking and executing it as an RTW standalone
model.

Lorenzo Dozio (dozio@aero.polimi.it)
2002 December 19.
