Beruflich Dokumente
Kultur Dokumente
Supervisor:
M.J.G. vd Molengraft
Technische Universiteit Eindhoven Department Mechanical Engineering Dynamics and Control Technology Group Eindhoven, May, 2006
Contents
1. Introduction 1
2. 2.1. 2.2.
Installation Introduction Install Knoppix to the hard disk 2.2.1. General notes/hints regarding Knoppix 2.3. Installation steps in Linux 2.3.1. Mesa (display drivers) 2.3.2. EFLTK 2.3.3. A new patched kernel 2.3.4. Rtai 2.3.5. Scilab (source version) 2.3.6. Installing Scilab/Scicos & Rtai add-ons
2 2 2 3 3 3 4 4 5 5 6 7 7 7 8 8 10 12 12 12 13 13 14 16 16 17 18 20 21 21 23 23 27 27 28 28
Using Scilab and Scicos Differences compared to Matlab Scilab, generals hints and tips Scicos 3.3.1. General hints and tips 3.3.2. An example of working with Scicos 3.3.3. Notes 3.4. Creating and running real time programs 3.4.1. Building real time code 3.4.2. Loading modules 3.4.3. Running applications 3.4.4. Xrtailab
4. 4.1. 4.2.
Writing new blocks Block and code structure Steps needed to implement a new block 4.2.1. Customize the C code 4.2.2. Explanation of new block template 4.3. Example of converting existing Matlab S-function, implementation of TUeDACS 4.3.1. Modify the main file 4.3.2. Modify the code generation file: 4.3.3. Building the C code 4.3.4. Create the Scicos script 4.4. Building the pato01 model 4.4.1. Example of translating other blocks, DCT PD and Ref3 4.4.2. Not explained errors
ii
4.5.
Customizing blocks 4.5.1. Change appearance of blocks 4.5.2. Xrtailab labels Results
29 29 30 31 31 32 32 36 38 39
5. 5.1. 5.2.
The pato01 model Testing the pato01 model 5.2.1. Measurement on a dynamic system 5.2.2. Sample time errors 5.2.3. CPU usage Conclusions
6.
7.
References
40
Appendix A: errors and possible solutions Installation errors Kernel (make menuconfig) Kernel (make) Kernel (restarting using the new kernel) RTAI (make) Scilab (./configure) Scilab (make all) Rtai-lab (make install) General errors Starting an xwindow application (xlib) Running Scilab Using a universal Actuator/Sensor block (Scicos) Building a real time program (RTAI CodGen) Running a real time program Appendix B: software download locations
A.1 A.1 A.1 A.1 A.3 A.3 A.4 A.4 A.5 A.6 A.6 A.6 A.6 A.7 A.7 B.1
C.1
Appendix D: source codes examples Translated td_outports.c file Modifying the td_outports.sci script Generated functions of the DCT PD and the Ref3 block Appendix E: contents of CD
iii
1.
Introduction
Matlab is a well known computational software package with al lot of toolboxes, which can be used for many applications. It also contains Simulink and combined with the Real Time Workshop (RTW) it offers functionality to control real time processes. On the other hand, the disadvantage of the Matlab package is its price; it is very expensive. For that reason Scilab, an open source variant of Matlab, might be a good alternative. Scicos, a module of the Scilab package, offers similar functionality as Simulink. In this report migrating from Simulink to Scicos with respect to real time applications will be discussed. Currently the TUe Data Acquisition & Control System (the TUeDACS) is supported by Simulink RTW. This implementation allows users to use a block in Simulink representing the in- or output ports of the TUeDACS devices. By means of the real time workshop it is possible to build a real time program from a Simulink model containing the TUeDACS blocks. Such program can measure (sensor) inputs and control the target system using (actuator) outputs and control rules. In Scicos, also real time programs can be built. The goal of this project is to explore implementation possibilities for the TUeDACS devices in Scicos. As Scicos offers similar functionality as Simulink it might be possible to use Scicos for building the same kind of real time programs. For this exploration the pato01 setup is used as a case. Linux will be used as operation system because of its excellent real time properties, especially when combined with the Real Time Application Interface (RTAI) extension. This report contains three sections. The first section will describe the complete installation. Knowledge of Linux is not required; when everything is properly installed it is fairly self-evident. The TUeDACS disk with a working Linux distribution will be the starting point. In the second section, the usage of the new Scilab package will be explained. Knowledge of Matlab and Simulink will be assumed. In the last part describes how new Scicos blocks are programmed by translating existing Simulink blocks. These new blocks, including the TUeDACS blocks, are needed when trying to build the pato01 setup in Scicos.
2.
2.1.
Installation
Introduction
Before Scicos will run in combination with RTAI it is necessary to execute some installation steps. Here the installation as written down in [1] and adapted to the TUeDACS CD (Linux Live DVD for TUeDACS QAD/AQI devices) version 3.1 will be described. This is just a short list of the commands needed to execute when using the same CD. See [1] for more details. Of course these installation steps can be performed in combination with a different Linux distribution version but then (different) errors will occur. For easy reference the errors that may occur using the TUDACS CD and the possible solutions are described in appendix A. The user has to pass three significant installation steps. First, the Knoppix cd has to be installed to the hard disk. This may take some time. Then, in order to build and run real time programs after installing some drivers, two major installations steps in Linux have to be executed. In Scicos the user can build real time programs. These programs make use of the Real Time Application Interface (RTAI). In order to build and load the RTAI modules a new patched kernel must be installed. This patch comes with RTAI. So the next step is to build a new kernel. This also can take a while and may not work on the first try. The last step is to install RTAI and of course Scilab. Before starting, notice the difference in text formatting: This format means a command to execute. Just type these commands exactly in a console window. This format displays the name of a file, path, program or option. It can be seen as a quote. At last, this format stands for output code printed on the screen. It is generally used in appendix A to reflect an error code as seen in the console window.
2.2.
To install Knoppix to the hard disk make a Linux Swap, Ext3 and Fat32 partition. In Windows this can be achieved using a program like PartitionMagic. In Linux qtparted, a PartitionMagic clone, can be used. The Fat 32 partition is useful for exchanging files between both operating systems. Knoppix will be installed on the Ext3 (reformatted with the Reiserfs files system) partition. This is a list of commands needed to execute when using the same CD: Start Knoppix from the TUeDACS CD. Open Konsole (Terminal Program) and type: sudo knoppix-installer 2