Home
RTAI-Lab tutorial - Roberto Bucher
Contents
1. General 4 ShowsHide FP PausefRun Y Grid onoff Grid Color Bg Color Sec Div 01 xj Y Points Time N Points 1000 Filename SCOPE Save Help Close 1Main RTAI Lab developer person to contact for technical questions roberto bucher at supsi ch see page 46 Contents 1 Introduction 1 1 RTIAI Lab tool chain 1 2 Commercial software 2 1 Requirements eE a aa E E A EE ELE a a Da AERE a Ae a G an d de de a 2 1 1 Hardware requirements 2 1 2 Software requirements 2 2 Mesa library ee 239 EPLIKU e eaan rd E A el aia Be ace A 2 4 Linux kernel and RTAI patch 25 Comedilib lt ssa aaa os aa aa ee e a ee a O A a ee A 20 RIAMISTPass tata a ad atar aa A E ACTA A E O 28 COME e 0000 80 a ae he e RR RA E a am cs A a ew ee 2 9 RIA 2nd Pass 2 2 fGen a we Odd ba wee e Bee ahead A 2 10SCICOSLAD fen a kes e wee ee a a a e e A 2 11 RIAI Lab add ons to Scicoslab 4 4 2 12 User configuration for scicoslab 4 4 2 13 Load the modules lt 3 Development with RTAI Lab 3 1 Boot Linux RTAl 8 2 Stat SOCOS e eea a ehh a ae Ae a a A A A a a A 3 3 RIAI Lib palette o ee 3 4 Real time sinewave step by step 9 42 Compile cece AER aaa e ee A ea Bee hale a 343 AA i 22 shod SS tes Sah hs ed Ded Gra es ap BO Bee Bd SE et de a aa 3 4 4 Change paraMeters
2. 4 Figure 14 a Block diagram of Fig 12 modified to display the response to a square wave b Resulting plot showing square wave and step response red line Note This figure was assembled by exporting the block diagram to Postscript and converting it with pstoedit f fig The plot was directly exported to Xfig format Both figures were then merged using Xfig and the numbering on the axes was enlarged using Xfig s Update button 27 Modify the block diagram so as to simulate the response to a square wave input Fig 14h e Left clock Period 3 Init time 0 e Square wave generator Amplitude 1 e Scope Ymin 4 Ymax 4 Refresh period 10 Buffer size 20 e Menu Simulate Eval generates Fig 14p 4 3 3 Real time model and simulation Modify again the block diagram using blocks from the RTAI Lib palette Fig 14p e Replace the left clock and square wave generator with an RTAI Lib Square block Set Square block parameters Amplitude 1 Period 6 Impulse width 3 Bias 0 Delay 0 Replace the multiplexer and scope with an RTAI Lib Scope block Set input ports 3 Menu Diagram gt Region to Super Block frame all blocks except the clock You then obtain Fig 14p e Open Super Block Menu Diagram gt Rename and set diagram name to rtex3 Close Super Block window Menu RTAI gt RTAI CodeGen and compile In a terminal type rtex3 v In another terminal
3. Figure 20 xrtailab lets you adjust trace offset and color as well as units division Here the square wave input is set to orange The output signal white features a slight overshoot Finally return to the block diagram open the superblock add a Comedi D A block under the Scope and connect it similarly Fig PTh Close the window and RTAI CodeGen the superblock Connect the analog output and analog ground of your signal acquisition and generation hardware to a real oscilloscope For example with the National Instruments PCMCIA DAQcard 6024E connect pins 22 DACOOUT and 55 AOGND In one terminal Fig 21f xrtailab v In another terminal Fig 21H dcmot v You should now see something that looks like a square wave on your oscilloscope Settings vertical 500mV div horizontal 250ms div In xrtailab connect open the scope adjust visualization parameters in a similar manner to the oscilloscope You can grab the scope s window corner to enlarge the display 32 a c ot Ttnetter zadig Shell No 3 Konsole Click to open block or make a Link 45 shel No 2 shenno 3 shen Diagram Edit Sivulosa Objest Misc RIAL ent Target is running Scope closed Target ie nee Real time Internal clock i OneShot Jl 1 ji Priority RUN FOR EVER TARGET STARTS COMEDI dev comedi0 DAQCard 6024E opened COMEDI dev comedi
4. B Reference standard parallel port References C About this document Bug reports C i Aboutthe authors C 2 Bug reports suggestions C 3 Software licenses C 4 AcknowledgemMentS o o D_ Useful files and links 1 Introduction This tutorial shows how to install use and customize a fred open source Computer Aided Control System Design CACSD and real time control tool chain called RTAI Lab Apart from being a tool to develop real time control systems RTAI Lab also lets you integrate real time controllers and simulators generated by Mathworks Matlab Simulink Real Time Workshop and or the open source Scicoslab CodeGen CACSD software suite Furthermore RTAI Lab lets you 1 1 Develop and execute real time software in a local remote distributed way Monitor a controller s local remote distributed execution Change a controller s parameters on the fly RTAI Lab tool chain The RTAI Lab tool chain is based on 1 2 Scicoslab Scicoslab is an open source CACSD software for numerical computation Scicoslab in cludes Scicos a block diagram editor that can be used to create simulations and automatically gener ate and compile code See www scicoslab org and www scicos org Comedi Comedi provides the drivers library functions and an API to interact with signal acquisition hardware Hundreds of devices are supported See
5. ee 345 StopiexeculabDlel s sses ica a a aR Re ee Pd 4 Examples A EEO ae denis ye ce aie he ess ee ee A Skee ey Ae ha ates as E AS tee hn ah ch ty de a ne te 4 2 Semaphores s mace aak soi u a E a DA A ee 4 3 1 Discretize the system oaaao a 3 2 Block diagram and simulation aaa ooo 3 3 Real time model and simulation 44 DC Motor contral a a a a R a O a a a E A a a A 4 1 Motor position model 4 2 Digital mode 4 3 Digital Control ii ee ewe de ees oe ee eee ea hae Chee ee a RAS 4 4__RIAI Lab controlle AA A AY AA 5 Custom blocks 5 1 Overview of Scicos blocks o mo 5 2 Hardware example parallel port LED blinker 5 2 1 Parallel port LED circuit oo o 5 2 2 Create the environment for the new blocks 5 2 3 Generate the interface files 5 2 4 Compile the interface files 0 oo e e 5 2 5 Generate the implementation files 5 2 6 Compile the implementation files 5 2 7 Integrate the new files in the Scicoslab environment 0000 YY YO 01010 AAS 5 2 8 The template Makefile for the new files 5 2 9 Create a scicos block palette for the new files 5 3 Scicos C block data structure A Notes on Linux configuration and installation A 1 Kernel configuration A 2 Configuring the GRUB boot manager A 3 udev and RIAI
6. You can adjust the semaphore s name SEM and IP address 127 0 0 1 localhost See also RTAI API documentation for function rt_sem_wait SEM signal Increment a semaphore s value If the resulting value is not positive then the first task in the semaphore s waiting queue is allowed to run You can adjust the semaphore s name SEM and IP address 127 0 0 1 localhost See also RTAI API documentation for function rt_sem_signal C RTAI This is a generic block that lets you edit C code It is based on Scicoslab s C Block2 found in the Others palette When you click on the C RTAI Block a dialog window opens where you can edit block parameters such as the name of the main function that it will contain the number of inputs and outputs for data and events and various parameters see section 5 3 and also Campbell Chancelier and Nikoukhah 2006 section 9 5 After clicking on OK a second window opens with a code skeleton to edit It is best to copy paste code from your favorite editor into this window When you click on OK the code is compiled and linked If your code is relatively large we recommend that you program your own block instead of using C RTAI Block see section 5 3 4 Real time sinewave step by step In this example you use Scicoslab to draw a block diagram that generates a sinewave You automati cally generate and compile a real time executable You test the program and visualize the sinewave with xrtai
7. see Appendix B Add module names to etc modules Debian e g pcmcia if you use a laptop with a signal acquisition card and execute update modules Debian Reboot computer into newly compiled kernel Comedilib cd usr local src cvs d pserver anonymous cvs comedi org cvs comedi login cvs d pserver anonymous cvs comedi org cvs comedi co comedi cvs d pserver anonymous cvs comedi org cvs comedi co comedilib cd comedilib Read software installation requirements in README CVS and verify that your packages automake etc are up to date with automake version sh autogen sh Note you may ignore warnings and reminders configure sysconfdir etc Note pay attention to warnings and possibly remedy to these by installing extra software packages make and make install Note installation places comedi h and comedilib h in usr local include You will later have to overwrite these header files with those from Comedi see Sec 2 8 make dev This step creates the dev comedi 0 3 device inodes Optional calibration tool comedi_calibrate Install packages from your favourite Linux distribution 1ibboost program options dev and libgs10 dev See also RTAI manual Sec 4 7 8 RTAI 1st pass This is usually straightforward For more details download a draft of the RTAI User Manual 2006 You will need packages libxmu dev and libxi dev 1 2 3 ONO gt cd usr src rtai make xconfig Of
8. www comedi org RTAI The Real Time Application Interface RTAI is distributed as a package with a patch to apply to the Linux kernel RTAI inserts a sub kernel where prioritized hard real time tasks can run FIFOs and shared memory can be used to transfer data between real time and user space processes See www rtai org RTAI Lib RTAI Lib is a palette of Scicos blocks that let you design block diagrams with sensors and actuators It provides an interface to RTAI and signal acquisition hardware Block diagrams that use RTAI Lib can be compiled into RTAI execuatble software It is included in the RTAI package xrtailab xrtailab is an oscilloscope like software that can connect to your real time executables It lets you visually monitor signals and real time events using gauge scope and LED mock ups xrtailab also lets you adjust parameters of the real time executable while it runs It is also part of RTAI Commercial software All software used for RTAI Lab is free and Open Source The RTAI Lab tool chain represents an alternative to the commercial software listed below Scicoslab Mathworks Matlab Simulink Comedi drivers supplied by signal acquisition hardware vendors but most vendors don t supply Linux drivers RTAI gt LynxOS from Lynuxworks MontaVista Linux QNX VxWorks etc RTAI Lib gt Mathworks Real Time Workshop xrtailab gt LabView TNo purchase cost See licenses in Appendix
9. User configuration for scicoslab 4 4 Every RTAI Lab user must launch the previous make with e make user or edit the HOME Scilab 4 x scilab with exec SCI contrib RTAI loader sce These lines add e Menu RTAI to the Scicos diagram editor with items CodeGen and gt Set Target e Palette RTAI Lib to menu Edit gt Palettes To add Scicoslab to the executable path you must either cd usr local bin ln s usr lib scicoslab gtk 4 x bin scilab scilab or add usr lib scicoslab 4 4 bin to the PATH variable in your bash_profile and or bashrc or rel evant shell start up file 2 13 Load the modules To compile and execute real time RTAI Lab programs you must boot the Linux RTAI kernel If all goes well your acquisition hardware will be detected try cardct1 info for kernels less that 2 6 13 or pccardctl info otherwise You then load RTAI and hardware related modules Note that which modules to load depends on your RTAI kernel configuration We recommend to initially load the modules manually and possibly later configure your system to load these modules at boot time using system files or commands depending on your Linux distribution and hardware such as etc modules update modules etc modutils etc hotplug or etc udev and or a manually launched script To manually load the modules you will have to be root or use sudo You can check the progress by issuing dmesg commands or tail f var log messages For example on a
10. card drivers usr local src comedi comedi drivers RTAllwww rtal org Draft of RTAI User Manual www rtai org gt Documentation Reference Documents somewhat outdated but useful stuff Hannes Captain Mayer s notes www captain at rtai php Real Time Linux tutorial based on RTAI www isd mel nist gov projects rtlinux Links to several articles describing RTAI projects RTAI internals www aero polimi it rtai documentation articles paolo dissecting html RTAI history www rtai org gt Documentation Articles RTAI History Documentation usr realtime share doc rtai 3 3 Loadable modules are in usr realtime modules e Automatic control PI control with RTAI linuxgazette net 1 18 sreejith html Control tutorials for Matlab and Simulink www library cmu edu ctms Hint It would be great if someone wrote a Scicoslab version Matlab files associated to the book Digital control of dynamic systems Franklin et al 1998 www mathworks com support books book1464 html Hint lt would be fantastic if someone translated the book s m files to Scicoslab e Miscellaneous links 47 RTAI XML project to monitor RTAI tasks from various OS s artist dsi unifi it rtaixml Moodss graphical monitoring application moodss sourceforge net Note it would be interesting to adapt Moodss to work with RTAI Matplotlib python 2D plotting library matplotlib sourceforge net Qt interface to Ma
11. clock should be contained in the region Right resulting Super Block ode4 Uses a 4th order Runge Kutta formula RK4 The source code for these functions is available in SCILAB macros RTAI RTAICodeGen_ sci Sci coslab s ODE functions are detailed in section 3 2 of Campbell et al 2006 and also in Sallet 2004 e Step between sampling Indicates the number of computational sub sampling points used for various functions such as ODE functions The default is 10 scilab 4 0 Scilab Consortium Inria Enpc scilab 4 0 scilab 4 0 Scilab Consortium Inria Enpc A ea ee ae ea eee Consortium Scilab INRIA ENPC scilab 4 0 Copyright c 1989 2006 Consortium Scilab INRIA ENPC Startup execution loading initial environment gt scicos Startup execution shared archive loaded loading initial environment Link done shared archive loaded gt scicos Link done shared archive loaded cp usr realtime share rtai scicos rtmain c Link done gcc 0 DNDEBUG Dlinux DNARROWPROTO D_GNU_SOURCE 02 I usr local shared archive loaded scilab 4 0 routines I I usr realtime include 02 I usr src linux Link done include Wall Wstrict prototypes pipe I usr realtime include scico s DMODEL Untitled c o rtmain o rtmain c gcc 0 DNDEBUG Dlinux DNARROWPROTO D_GNU_SOURCE 02 I usr local scilab 4 0 routines I I us
12. it a try anyway If you know of other laptops that have this problem or know how to solve the problem please notify us A quick way to test whether your computer will easily work with RTAI is to download an ISO image from issaris homelinux org takis projects rtai livecd and conduct some latency tests Note that failing to boot the CD or run the tests does not necessarily mean your computer cannot run RTAI 2 1 2 Software requirements We assume that your Linux system is based on one of the available distributions such as Debian Fedora Mandriva Red Hat Slackware Suse Ubuntu etc and that you have suitable software development li braries installed to compile a Linux kernel as well as graphical development libraries Your working environment and list of packages should enable you to compile and install software as root Ensure that your distribution is up to date with the latest versions of development software such as automake gt 1 7 autoconf libtool bison and doxygen 2 2 Mesa library New Linux distributions in particular Ubuntu already contain usable Mesa libraries 2 3 EFLTK library EFLTK is needed by xrtailab EFLTK is part of the EDE project ede sourceforge net You will need pack ages gettext flex and svn 1 2 4 cd usr local src svn co https ede svn sourceforge net svnroot ede trunk ef1tk svn co https ede svn sourceforge net svnroot ede trunk ede cd efltk autoconf configure disa
13. laptop with a National Instruments DAQCard 6024E PCMCIA card see hardware specific comments indicated by signs below here s how to load the modules insmod usr realtime modules rtai_hal ko insmod usr realtime modules rtai_up ko or rtai_lxrt ko insmod usr realtime modules rtai_fifos ko insmod usr realtime modules rtai_sem ko insmod usr realtime modules rtai_mbx ko insmod usr realtime modules rtai_msg ko insmod usr realtime modules rtai_netrpc ko ThisNode XXX XXX XXX XXX Note that you may have to load more modules in usr realtime modules depending on what blocks you use in your application It may be useful to write a shell script to load these modules after you boot RTAI 12 3 Development with RTAI Lab Real time software development with the RTAI Lab tool chain is done with the Scicoslab block diagram editor and associated palettes of blocks including the RTAI Lib palette Some testing of the real time executable can be done with xrtailab New Scicos blocks may be programmed using the Scicoslab language and their executable component programmed in C see section B MES scilab 4 0 scilab 4 0 scilab 4 0 Scilab Consortium Inria Enpc _ Untitled a Click to open block or mal Diagranf Edit Sinulate Object Misc RIAL stos Startup executi loading initi x x sinusoid read from
14. make menuconfig Menu General verify default directories e Installation directory usr realtime e Kernel source directory usr src linux Menu General optionally select RTA Documentation HTML PDF Menu Machine x86 adjust Number of CPUs default 2 Exit xconfig menuconfig and save configuration make and make install IMPORTANT Add usr realtime bin to the PATH variable in etc profile or your home directory s bashrc 2 7 RTAI tests Load RTAI related modules Section 2 13 insmod modules rtai_hal to rtai_fifos You should measure your system s latency to real time interrupts cd usr realtime testsuite kern latency run This launches a periodic task The default period of 100000 ns is defined by DEFAULT_PERIOD in usr src rtai testsuite kern latency latency module c and can be redefined upon module insertion see below Watch lat min ns and overruns Load your computer s CPU e g use multimedia applications If overruns becomes greater than zero then you might try to lenghten the period e Type ctrl c to stop execution e insmod modules of Section 2 13 from rtai_hal ko to rtai_fifos ko e insmod usr realtime modules rtai_lxrt ko insmod latency_rt ko period 1000000 display Overruns should either remain at zero or increase much more slowly If they are still increasing then stop execution and reload latency_rt ko with a longer period Stop execution ctrl c rmmod latency_rt You may compare
15. on a remote host is currently limited by the UDP packet size 1500 bytes Mbx Send Ovw Sends a message to a mailbox possibly overwriting what is already in the mail box You can adjust the number of message input ports 1 mailbox name MBX and mailbox IP address 127 0 0 1 localhost See also RTAI API documentation for function rt_mbx_ovrwr_send Mbx Rev no bik Receives a message only if the whole message can be passed without blocking the calling task However if the mailbox is on a remote host the calling task may be blocked You can adjust the number of message output ports 1 mailbox name MBX and mailbox IP address 127 0 0 1 localhost See also RTAI API documentation for function rt_mbx_receive_if Mbx Rev blk Receives a message The calling task will be blocked until all bytes of the mes sage arrive or an error occurs You can adjust the number of message output ports 1 mailbox name MBX and mailbox IP address 127 0 0 1 localhost See also RTAI API documentation for function rt_mbx_receive Mbx Send if Sends a message only if the whole message can be passed without blocking the calling task However if the mailbox is on a remote host the calling task may be blocked You can adjust the number of message input ports 1 mailbox name MBX and mailbox IP address 127 0 0 1 localhost See also RTAI API documentation for function rt_mbx_send_if FIFOout and FIFOin Multichannel FIFO You can adjust the nu
16. plant Figure 19 Simplified DC motor control loop You will have to e Clock Period 0 001 e Replace Scicos s square wave generator with RTAI Lab s real time Square block e Unfactorize the controller s transfer function with Numerator z 450 z 2 765 z 325 125 Denominator z z7 2 0 28 z 0 686 e Replace the plant s continuous model by a discretized model Numerator z 0 001 z 0 001 Denominator z z72 1 9425 z 0 9425 e Replace Scicos s scope by RTAI Lab s real time scope input ports 2 e Menu Diagram gt Region to Super Block frame all blocks except the clock 31 T T T T T T T T 0 40 0 41 0 42 0 43 0 44 0 45 0 46 0 47 0 48 0 49 0 50 New color Open superblock and Menu Diagram gt Rename dcmot Menu RTAI RTAI CodeGen In a terminal type dcmot v In another terminal type xrtailab In xrtailab connect to target alt c open the scope manager and show the scope In the Scopes Manager you can click on Trace tabs to adjust each trace s color Fig 20 Disconnect and stop the real time task by clicking on the red button _ RTAL Lab Graphical User Interface File View Help o a sas ja gt 9 De a ae scopes Manager o nn DPE General Trace 1 Y Show Hide EHA CS TA A oe ma mo ma ma Baw Help Close E Units Diw 1 xj E 0 7925 9 z Trace Color Trace Offset 0 0370 E OK 4 Cancel
17. the system with a sampling time of 1 ms gt s poly 0 s gt G 20 s 2 4 s G 4s s gt Gc syslin c G gt T 0 001 gt Gd ss2tf dscr tf2ss Gc T Gd 0 0000100 0 0000100z 0 9960080 1 996008z z The system s discrete time transfer function is therefore 10z 10 22 1 9962 0 996 G z 107 4 3 2 Block diagram and simulation Replicate the block diagram of figure 12 you will use palettes Sources Sinks Linear and Branching O v v _ num z Bas A den z on Figure 12 Scicos block diagram to simulate the step response of a discretized plant e Clock block set Period 0 001 Init time 0 e Step block set step time 1 Initial value 0 Final value 1 e Gain block set gain to 2 26 e Discrete SISO transfer function set numerator to 0 00001 0 00001 z set denominator to 0 996008 1 996008 z z72 e Feedback gain block set gain to 1 e Scope block set Ymin 1 Ymax 3 Refresh period 5 Buffer size 20 e Menu Simulate gt Setup set Final integration time 5 e Menu Simulate Eval Use Scicos to visualize the system s response to a square signal menu Simulate Run produces the plot of figure 13 square wave generator gt 3 a v num z gt AN deny gt lt a
18. type xrtailab In xrtailab connect to target alt c open the scope manager and show the scope In the Scopes Manager you can click on Trace tabs to adjust each trace s color Fig 15 RTAI Lab Graphical User Interface File View Help lola aa aja ol HE aaa m General Trace 2 Trace 3 M Show Hide Sec Div 1 y V Pause Run Oneshot Run y Points Time N Points 1000 Time s 1 0 Grid Color Filename SCOPE Bg Color Save M Grid onoff Help Close Target bucondis Figure 15 xrtailab Scopes Manager and scope displaying real time plots of the block diagram shown in Fig 14p 28 4 4 DC Motor control In this example we show how to adapt a Simulink block diagram to Scicos and RTAI This example is based on the Control Tutorials for Matlab and Simulink hosted at Carnegie Mellon University and University of Michigan 1998 Please refer to the DC Motor position modeling in Simulink example Sections 7 2 and 10 2 of also provide in depth information on using Scicos for control 4 4 1 Motor position model A T PRENERA EE E E EE ETE EEEE E ARAS 3 0 00 0 02 0 04 0 06 0 08 0 10 0 12 0 14 0 16 0 18 0 20 Figure 16 a Continuous time model of DC motor position as described at www library cmu edu ctms b Open loop step response of DC motor 4 4 2 Replicate the model of Fig 16h Menu Edit gt Conte
19. window e There is an RTAI Lib palette 13 3 3 RTAI Lib palette RTAI Lab provides the Scicos RTAI Lib palette Fig 2 To display the palette from Scicos click on menu Edit Palettes a pop up opens then click on RTAI Lib which should be listed at the bottom of the pop up E v v v v Scope Mbx Send Ovw COMEDI A D SEM wait Sine gt gt SCOPE gt MBXI comedi0 CH 0 P gt SEM1 Vv Vv Vv v x S uare st Meter eas no blk ls COMEDIDA SEM signal q METER gt comedi0 CH 0 gt SEMI v v z Led Mbx Send if COMEDI DI CRTAI a gt Step LED a MBX1 comedi0 CH 0 P Block v v y extdata Mbx rev blk COMEDIDO test dat MBXI1 PB comedi0 CH 0 v v Vv v SENSORS ACTUATOR 7 Fifoout Fifoin SENS ACT 0 0 Figure 2 The RTAI Lib palette featuring from left to right columns inputs outputs mailboxes hardware interfaces and semaphores The blocks are more or less arranged in thematic columns 1 Inputs function generators sine square step read data file programmable generic sensor 2 Outputs displays oscilloscope meter LED programmable generic actuator 3 Mailboxes send message and overwrite receive without blocking task receive unconditionally send message if task timing permits and FIFO boxes 4 Comedi hardware drivers A D D A digital input digital output 5 Semaphores and more wait signal programmable generic C block If you have correctly installed RTAI Lab you can find the source code for the blocks in u
20. your latency results with those published at issaris org takis projects rtai Benchmarks 2 8 Comedi In case of difficulties please refer to the INSTALL file in the comedi directory and to the documentation at IMPORTANT Make any edits that may be requested in usr src rtai base arch i386 patches README especially if they apply to the Linux kernel s config because it is read by Comedi s configure script See also earlier note in Sec 2 4 if you use a PCMCIA card 1 2 3 NO oR cd usr local src comedi sh autogen sh configure or possibly configure with linuxdir usr src linux with rtaidir usr realtime or configure with linuxdir usr src linux with rtaidir usr realtime enable kbuild with PCMCIA acquisition card configure with linuxdir usr src linux with rtaidir usr realtime enable pcmcia Note Towards the end of the output pay attention that either CONFIG_IPIPE CONFIG_RTHAL or CONFIG_ADEOS is set to yes This reflects what is set in usr src linux config make make install installs the comedi kernel modules make dev cp include linux comedi h include linux comedilib h usr include cp include linux comedi h include linux comedilib h usr local include ln s usr include comedi h usr include linux comedi h ln s usr include comedilib h usr include linux comedilib h Load RTAI and Comedi modules Section 2 13 10 Configure Comedi to work with you data acquisitio
21. 0 closed Target e been stopped TARGET END zadig Panot Scope Square l 5 a sa ime SCOPE controller plant AO Channel O Range 10 00 Y 10 00 v Model dcmot Executes on CPU mi Sampling time 1 a ieia s Target is running COMEDID A H comedid CH 0 RTAI Lab Graphical User Interface tnetter zadig Shell No 2 Konsole Eile View Help shen lll shell No 2 shel no 3 ol e a aj ala gt el ale a ale a Parameter Value e OWS General Trace ue Block demot IPARAM 2 Parameter Value 0 Nine of cls j 7 Show Hide Sec Div 025 y ue 1 0001 7 stocks domo ipmenta in Parameter Value OneShot Run I Points Time Number of rows et ap Number of cols 1 N Points 1000 Value 1 000000 Y Grid on off Number of target real time scopes 1 Time s Pune oF tra 2 Filename SCOPE lumber o i i Sampling times 0 001000 ena Color Number of target real time logs 0 Number of target real time leds 0 Bg Color Save Number of target real time meters 0 Number of target real time synchronoscopes 0 at demot is correctly connected Target demot d Figure 21 Signal generation and visualization on an oscilloscope a Add a Comedi A D block and connect it Close the window b R
22. 00 points SENSOR Generic sensor input You can adjust the number of outputs 1 and an identifier SENS Following that another dialog box opens where you can enter C code This code is compiled and linked after clicking on OK Although the dialog box has basic editing functions similar to Emacs we recommend that you edit your code in a separate editor and then copy paste it into the dialox box 2 Outputs Scope Meter and LED are output blocks that send data to xrtailab displays Scope xrtailab multichannel oscilloscope You can adjust the number of inputs 1 and the scope s name SCOPE Meter xrtailab single channel meter You can adjust the meter s name METER LED xrtailab multichannel multi LED block Each LED switches ON if the input is positive You can adjust the number of inputs LEDs 1 and the LED block s name LED ACTUATOR Generic actuator output This block is similar to the SENSOR block You can adjust the number of inputs 1 and an identifier ACT 3 Mailboxes Mailboxes let real time tasks exchange arbitrarily seized messages Their advantage is that there is no need to size mailbox buffers to cater for unusually large messages Message passing may be interrupted by real time constraints See usr src rtai doc generated html api group__mbx html and Local task blocking may occur when exchanging a packet between a local host and a mailbox on a remote host Furthermore packet transmission to a mailbox
23. 3 and frequency Value 1 from 1 to 2 Hz The scope reveals an undersam pled sinewave that results from the real time executable s clock being set to only 10 Hz 21 4 Examples In this section we provide a few basic examples that show how to e Use FIFOs e Use semaphores e Represent a continuous time plant as a discrete time model 4 1 FIFOs FIFOs provide a way of passing data to other tasks and programs Design the diagram of figure Ph a b oo l oe Pol Lod S ine ifoout 4 EE Figure 9 Preliminary diagram of a task that outputs sinewave data to a FIFO An external program is then used to read the data from def rtf0 e Click on Simulate gt Eval to ensure all blocks are registered You may change parameters in the Sine block e Set clock period to 0 01 e Frame a Superblock around Sine and FIFOout e Open the Superblock and click menu Diagram gt Rename Replace Untitled with fifo1 e Close the Superblock s window e Diagram gt Save As fifol cos e Menu RTAI gt RTAI CodeGen and click on the superblock to generate code and compile it to produce the executable fifo1 Now copy the program and compile it with gcc o readfifo readfifo c readfifo c Read a FIFO and print its data include lt stdio h gt include lt unistd h gt include lt sys types h gt include lt sys stat h gt include lt fcntl h gt include lt signal
24. Appendix B if you wish to extend this example 5 2 2 Create the environment for the new blocks First you can create a folder structure where you can put all the new files In this example we create a new folder called ScicosPP which contains two subfolder devices and scicosdev under develop in my home directory 35 5 2 3 Generate the interface files After moving in the subfolder scicosdev we can create the two interfaces files for our new blocks rtal_pport_out sci function x y typ x 0 y 0 typ 015 select job case plot then exprs arg1 graphics exprs pinout exprs 1 paddr exprs 2 standard_draw arg1 case getinputs then x y typ standard_inputs arg1 case getoutputs then x y typ standard_outputs arg1 case getorigin then x y standard_origin arg1 case set then x argl model arg1 model graphics argl graphics exprs graphics exprs while t do ok pinout paddr exprs getvalue Set block parameters Parallel port PIN 0 7 Parallel port Address list vec 1 str 1 exprs if ok then break end if exists inport then in ones inport 1 else in 1 end out model graphics ok check_io model graphics in out 1 rtai_pport_out job argi arg2 if ok then graphics exprs exprs model rpar model ipar pinout hex2dec strsubst paddr 0x gt gt model dstate x graphics graphics x model
25. C 3 page 46 Note that you can still use commercial software and use RTAI RTAI Lab as a target see RTAI Target HOWTO and RTAI UbuntuGutsy Matlab in Appendix D If you think you have sufficient funds to purchase commercial software you will then buy a better GUI better documentation support that you can pay for and the possibility to consult with the vendor in case of problems especially if you work for a large company On the other hand upgrades with bug fixes are expensive should be budgeted and included in your real time software s multi year maintenance and extension plan These costs represent a financial burden even for companies with a few hundred employees and only a few licenses The advantage of using exclusively Open Source software in the RTAI Lab tool chain is that you or a subcontractor can customize it You probably already know that That s why softwares that constitute the RTAI Lab tool chain are developed 2 Installation The full installation requires several software packages to be downloaded from their development servers and compiled from source Since RTAI RTAl Lab and Comedi are undergoing strong development we recommend that you do not rely on precompiled packages provided by Linux distributions The following sections provide detailed instructions to install order is important and must be followed If you are installing on an Ubuntu based distribution you may also refer to www rtai org RTAILAB RTAI UbuntuGuts
26. Counter generator D Chinary file p g Modulo 3 gt v sawtooth generator gt scicos Scicos window with RTAI menu __RTAI Lib_ Sources Sinks Linear Aa pm read from ator inputfle Non_linear Events Threshold Others Branching Electrical ThernoHydraulios DldBlocks DemoBlocks RTAI Lib X seg r Scope p Mx send Ow COMEDI A D SEM wait p Sine SCOPE MBX comediO CH 0 P X v v x X Meter Mbx Revnoblk COMEDI D A Square METER MEX ee CO ne te LED y Step Tp mme fame GRAS x X Mbx Send if daa FOO HRP RRE X x SENSOR ACTUATOR SENS pm ACT Figure 1 Scicoslab Scicos and 2 palettes Sources and RTAI Lib Note the addition of the RTAI drop down menu button to the standard Scicos window The most important block in the Sources palette is the red clock 3 1 Boot Linux RTAI Boot Linux RTAI Load associated modules section 2 13 3 2 Start Scicos To launch Scicoslab type at a shells command prompt scicoslab At Scicoslab s prompt type scicos This opens the Scicos window in which you will draw block diagrams For a tutorial on Scicos check http www scicos org TUTORIAL tutorial html RTAI Lab modifies 2 aspects of Scicos Fig 1 e There is an RTAI menu towards the right of the Scicos
27. RTAI Lab tutorial Scicoslab Comedi and real time control Roberto Bucher 1 Summary Simone Mannori Thomas Netter 2 May 24 2010 RTAI Lab is a tool chain for real time software and control system development This tutorial shows how to install the various components the RTAI real time Linux kernel the Comedi interface for control and measurement hardware the Scicoslab GUl based CACSD modeling software and associated RTAI Lab blocks and the xrtailab interactive oscilloscope RTAI Lab s Scicos blocks are detailed and examples show how to develop elementary block diagrams automatically generate real time executables and add custom elements Untitled RTAL Lib Palette may be used to copy blocks or regions Click to open block or make a link y ANGLE IN SBLK L achd 68 FORCE IN SELK Lachi33 P Y COMEDI DATAIN Tpressente act 65 Be COMEDI DATAIN Ranglesch3 30 me COMEDIDATAI R force achd 28 hd COMEDI DATAIN E pressure ach 60 jx e rz COMEDI D A m medii CH 0 te RTAI Meter A RIAL Meter Scope Actuator E v Sine e Mater SUR SCOPE i x x x x Mbx Ri bN Square p Metre PI cor z x i LED Mbxicvblk Step ppp e cure COMEDI DO Be comedi CH 0 ier Interface nm
28. TAI CodeGen on the Super Block c Execute the real time task dcmot v d xrtailab v xrtailab adjust units div and sec div f Visualize the signal on an oscilloscope ensure all grounds are well connected The laptop is a Fujitsu P 2040 featuring a Transmeta Crusoe TM 5800 CPU Data acquisition hardware National Instruments PCMCIA DAQCard 6024E 33 5 Custom blocks Custom Scicos blocks can be programmed added to palettes and used to generate real time code In section 5 2 we present an example where part of the code is generated from templates In section 5 2 2 we show how to create blocks from scratch and add them to the Scicoslab RTAI Lab installation Finally we explain how palettes are created Note that Chapter 9 5 of Campbell et al 2006 provides much information on Scicos blocks See www scicos org 5 1 Overview of Scicos blocks A Scicos block is defined by two functions e A Scicos interfacing function It is coded in Scicoslab language and compiled A block s code specifies The block s graphical appearance The number of data inputs and outputs The number of event inputs and outputs Dialog windows to adjust appearance inputs and outputs and computation parameters e A computational function lt is coded in a separate C file it used to be enclosed with in a dedicated getCode function after the Scicos interfacing function It is this code that is compiled and executed for simulations or eve
29. b s documentation effort e The Swiss National Science Foundation Thomas Netter is partly supported by a grant of the FNS SNF 46 D Useful files and links RTAl Lab www rtai org RTAILAB and waw ata supsi ch bucher Pre installation source of RTAI Lab Scicos blocks usr src rtai rtai lab scilab macros RTAI Makefile to compile Scicos RTAI Lab blocks usr src rtai rtai lab scilab macros RTAI Makefile Post installation location of RTAl Lab Scicos blocks usr local scilab 4 0 macros RTAI RTAI Lib Scicos blocks contain C code that make calls to C functions located in usr src rtai rtai lab scilab devices C prototypes are in devices h Associated C library is 1ibscib1k a installed in usr realtime 1ib Install on Ubuntu Matlab by Arno Stienen www rtai org RTAILAB RTAI UbuntuGutsy Matlab txt Use Windows Matlab Simulink RTW for design and RTAI RTAI Lab as a target by Giampiero Campa www rtai org RTAILAB RTAl TARGET HOWTO txt Scicoslab www scicoslab org www scicos org Tutorials www wolffdata se scilab htm www scicos org T UTORIAL tutorial htm French publications www saphir control fr articles Scicoslab start up file that includes a pointer to RTAI Lib palette HOME Scilab scilab 4 4b7 scilab Scicoslab installation usr lib scicoslab gtk 4 4 Code of standard Scicos blocks usr lib scicoslab gtk 4 4 macros scicos_blocks e Comedi www comedi org Code of acquisition
30. ble mysql disable unix0DBC emake emake install Edit etc 1d so conf and add a line with the path usr loca1 1ib on a line Execute sbin 1dconfig to update the library database Linux kernel and RTAI patch cd usr src Download RTAI at least version 3 8 of either Stable numbered http www rtai org e g rtai 3 8 tar bz2 tar xjvf rtai 3 8 tar bz2 ln s usr src rtai 3 8 rtai Experimental hot stuff beware cvs d pserver anonymous cvs gna org cvs rtai co vulcano see also https gna org cvs group rtai Check kernel version numbers of available RTAI patches ls usr src rtai base arch x86 patches and look for kernel version numbers in hal 1inux lt kernel version gt patch Kernel 2 6 xx The versions supported by this RTAI release can be found in the RTAI 3 8 base arch x86 patches directory 1 Download a vanilla linux 2 6 xx xx tar bz2 from http www kernel org 2 Unpack the kernel tar xjvf linux 2 6 xx xx tar bz2 ln s usr src linux 2 6 xx xx linux 3 Patch the kernel cd usr src linux patch p1 lt lt rtaidir gt base arch x86 patches lt kernel version gt patch make xconfig Or make menuconfig Configure the kernel See details in Appendix A make make modules_install oN DOA make install Update your boot loader either 1ilo or grub 2 6 Lilo edit etc lilo conf and execute lilo Grub edit boot grub menu 1st Debian or etc grub conf Fedora
31. block gt outptr 0 unsigned char val val inb block gt ipar 1 1 val 0x80 val val gt gt block gt ipar 0 if val amp 0x08 y 0 1 0 else y 0 0 0 static void end scicos_block block void rt_pport_in scicos_block block int flag if flag 1 set output inout block 3 else if flag 5 termination end block else if flag 4 initialisation init block 3 You must create a new C library with the implemementation code of your new blocks The following Makefile can be used to perform this task LIB libmysci a all LIB RTAIDIR shell rtai config prefix SRC wildcard c OBJ SRC c 0 DBG g CC_FLAGS c DBG I I RTAIDIR include 02 o c cc CC_FLAGS lt LIB 0BJ ar r LIB 0BJ install LIB sudo cp LIB RTAIDIR 1lib clean rm f LIB 0BJ where libmysci is the name of your new library Now simply launch make and make install to generate the library and copy it into the RTAI folder usually under usr realtime lib 5 2 7 Integrate the new files in the Scicoslab environment In order to be able to use the new blocks in the Scicoslab environment you must add the following line in the scilab file load home bucher develop ScicosPP scicosdev lib 5 2 8 The template Makefile for the new files By compiling the Scicoslab block diagram contai
32. del scicos_model model sim list rt_pport_in 4 model in if exists outport then model out ones outport 1 else model out 1 end model evtin 1 model rpar model ipar pinin hex2dec strsubst paddr 0x gt model dstate model blocktype d model dep_ut t f exprs sci2exp pinin paddr gr_i xstringb orig 1 orig 2 Pport_out string pinout paddr sz 1 sz 2 fill gr iF xstringb orig 1 orig 2 Pport_in string pinin paddr sz 1 sz 2 fi11 x standard_define 3 2 model exprs gr_i end endfunction 5 2 4 Compile the interface files First you must create the following buildmacros sce file This source file is licensed as described in are also available at if isdef genlib f then Scilab http www scilab org This file is part Copyright C 2007 2008 INRIA Allan CORNET lt allan you should have received as part of this distribution x standard_define 3 2 model exprs gr_i end endfunction of Scilab cornet inria fr gt This file must be used under the terms of the CeCILL the file COPYING which The terms http www cecill info licences Licence_CeCILL_V2 en txt exec SCI modules functions scripts buildmacros loadgenlib sce end toolbox_dir pwd genlib pportdev toolbox_dir f At where pport is th
33. e it is necessary that Scicos evaluate all blocks This is done when you click on a block adjust its parameters and then click on OK A general way to have all blocks evaluated is to select menu Simulate Eval You must do this Eval operation every time you add a block to a diagram and omit inspecting its internal parameters Create super block Menu Diagram gt Region to Super Block You must draw an elastic frame around the Sine and Scope blocks excluding the Clock figure 4 left First click above left of the Sine block then click again below right of the Scope block The region then becomes a Super Block Fig 4 right 3 4 2 Compile Set target You may optionally click on menu RTAI gt Set Target and then middle click on the Super Block to compile A dialog box opens where you may modify e Target This is the Makefile s basename See description below e Ode function This is one of the ordinary differential equation functions available in Scicoslab The default is ode4 Possible values are ode1 Uses Euler s method RK1 ode2 Uses Heun s method RK2 also Known as the Improved Euler method 17 Click to open block or make a link Click to open block or make a link Scope Sine SCOPE Figure 4 Left preliminary RTAI Lib block diagram during Region to Super Block framing All blocks except the
34. e alt c In the Task Identifier field type IFTASL and click on the OK button Open and display an LED LED1 should blink at 1 Hz Open the parameters manager type alt p Increase Value 1 of RPARAM 1 from 1 to 2 and press Enter By doing this you have increased semsig s Sine frequency from 1 to 2 Hz LED1 should now blink at 2 Hz Disconnect from semsig type alt d Connect again to semwait type alt c Set Task Identifier to IFTASK Open again an LED and a scope The LED now blinks at 2 Hz and the sinewave has twice as many kinks 24 RTAI Lab Graphical User Interface Eile View Help o a ssaa o seo aap General Y Show Hide Sec Div 0 1 Pause Run OneShot Run Y Points Time N Points 1000 Time s 1 0 Grid Color Filename SCOPE Bg Color Save Help Close M Grid on off 4 Target semwait Figure 11 xrtailab scope display of the sinewave generated by the semwait Superblock the waiting task The green LED reflects the state of the LED block in the semsig Superblock the signalling task The waiting task operates only when the SEM wait semaphore is positive light green LED The result is a jerky sinewave synchronized to the semsig task s semaphore 25 4 3 From continuous to discrete time 4 3 1 Discretize the system Say a continuous time feedback system includes a plant modeled by the transfer function 20 oy s2 445 Use Scicoslab to discretize
35. e name of your new interface library The following Makefile can be used to compile the files 36 install sl nw f buildmacros sce clean rm f bin lib names 5 2 5 Generate the implementation files RTAI Lab provides the usr realtime bin gen dev script to generate a C skeleton for new RTAI Lab de vices Move to the folder devices and insert the following two files pport_out c COPYRIGHT C 2007 Roberto Bucher roberto bucher supsi ch This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 59 Temple Place Suite 330 Boston MA 02111 1307 USA include lt machine h gt include lt scicos_block4 h gt include lt sys io h gt static void init scicos_block block E block gt ipar 0 block gt ipar 0 static void inout scicos_block block double u block gt inptr 0 unsigned char val val inb b
36. elect as needed Keep other default selections If you recompile the kernel to add some features you need also to recompile install and check both RTAI and Comedi A 2 Configuring the GRUB boot manager This section gives an example to configure the GRUB boot manager s configuration file usually located in etc grub conf Fedora Core II distribution or etc grub grub conf Debian distribution See also www gnu org software grub grub conf Note that you do not have to rerun grub after making changes to this file NOTICE You have a boot partition This means that all kernel and initrd paths are relative to boot e g root hd0 1 kernel vmlinuz version ro root dev hda3 initrd initrd version img boot dev hda default 2 timeout 10 splashimage hd0 1 grub splash xpm gz The original F C II Generic Modular Non Realtime Kernel title Fedora Core 2 6 5 1 358 root hd0 1 kernel vmlinuz 2 6 5 1 358 ro root LABEL rhgb quiet initrd initrd 2 6 5 1 358 img RTAI patched Kernel title Linux 2 6 23 14 RTAI 3 3 root hd0 1 kernel vmlinux 2 6 23 14 rtai VERY useful memory tester program title Memtest86 root hd0 1 42 kernel memtest86 1 11 title Windows XP Home rootnoverify hd0 0 chainloader 1 A 3 udev and RTAI udev is a dynamic device detection scheme see www kernel org pub linux utils kernel hotplug udev html that is used by several Linux distributions and works with the 2 6 Li
37. gister 5 Data 3 Out Data Bit Pin Name Fun Register 6 Data 4 Out Bab TT jase D Etoo a89 e j v Data 5 Out Data o 2 Data 0 Out Data 8 Data 6 Out Data 1 3 Data 1 Out Data 9 Data 7 Out Data 2 4 Data 2 Out Data 10 nAck In Status 3 5 Data 3 Out Data 11 Busy In Status Yes 4 6 Data 4 Out Data 12 P_Out _End In Status 5 7 Data 5 Out Data 13 Select In Status 6 8 Data 6 Out Data 14 nAuto In Out Control Yes 7 9 Data 7 Out Data 15 Error In 3 O RE Re eee aa alee ee eee eee 16 nInit In Out Control 17 nSelect In Out Control Yes BASE 1 Status Register 18 25 Ground Gnd Bit Pin Name Fun Register Hardware Inverted wana nanan nnn nnn nn nnn nnn nnn nnn nnn nnn nnn nnn nana nanan wee l In Out TTL level input Open Collector output o Reserved Out TTL level output 1 Reserved In TTL level input 2 Reserved 3 15 Error In Status Hardware Inverter the in out voltage level is inverted respect to 4 13 Select In Status normal logic 5 12 P Out End In Status 6 10 nAck In Status 7 1 Busy In Status Yes BASE 2 Control Bit Pin Name Fun Register Hardware Inverted Y a a o 1 nStrobe In Out Control Yes 43 Bone 14 16 17 nAuto nInit nSelect En_IRQ nACK In Out In Out In Out Control Control Control Yes Yes 44 a En_DATA_READ unused unuded References Stephen L Campbell Jean Philippe Chancelier and Ramine Nikouk
38. gnal SEM wait LED Sine SEM SEM gt LED y Y LED g Scope gt LEDI Sine SCOPE Figure 10 Preliminary diagram of two tasks that use semaphores Left the signalling task uses a sinewave to increment a semaphore Right the waiting task reads the semaphore and produces an output only when the sinewave in the signalling task is positive Open the left Superblock and Diagram gt Rename it to semsig Note you might have to Dia gram Replot to recenter the diagram Warning do not put a dash in the name of a block RTAI CodeGen has problems with that Close the window Put a name tag under the Superblock Object gt Identification click on the left Superblock and set ID to semsig Open the right Superblock and rename it to semwait Close the window Save the diagram to sem cos RTAI gt RTAI CodeGen the left Superblock RTAI gt RTAI CodeGen the right Superblock In a terminal type semsig v n IFTASL d LED In a second terminal type semwait v e In a third terminal type xrtailab v In xrtailab Connect to semwait type alt c and set the Led identifier field to LED Open and display an LED click on the light bulb button then check Show Hide The signalling task s LED should blink every second Open and display a scope You should see the waiting task s truncated sinewave scrolling in a jerky manner every second Fig 11 Disconnect from semwait type alt d Connect to semsig typ
39. h gt static int end 22 struct data F float t float u 1 static void do_end int dummy end 1 int main void 4 2 int fifo struct data val if fifo open dev rtf0 O_RDONLY lt 0 fprintf stderr Error opening dev rtf0 n exit 1 signal SIGINT do_end while end Y read fifo amp val sizeof val printf f t f n val t val u o return 0 In a terminal type fifo1 v In a second terminal type readfifo Two columns of data should start printing Interrupt the program by typing ctrl c In the second terminal now type readfifo gt fifo dat Interrupt the program after 3 to 10 seconds by typing ctrl c In Scicos menu Diagram gt Quit In Scicoslab s scilex window type n and then type at Scicoslab s gt command prompt to produce the plot in Fig 9p gt x read fifo dat 1 2 gt plot x 1 x 2 Semaphores Semaphores are used as a signalling method between tasks Design the diagram of figure 10 Open the SEM signal block and ensure that IP addr is 127 0 0 1 Open the SEM wait block and ensure that IP addr is 0 Open the left LED block and call it LED1 Frame a Superblock on the left side around blocks Sine SEM signal and LED Frame a Superblock on the right side around blocks SEM wait LED Sine and Scope Set each clock to a Period of 0 001 Simulate Eval 23 O P SEM si
40. hah Modeling and Simulation in Scil ab Scicos Springer Berlin Germany 2006 URL www scicos org Gene F Franklin J David Powell and Michael L Workman Digital control of dynamic systems Addison Wesley Longman Reading MA 1998 Bill Messner and Dawn Tilbury Control tutorials for MATLAB and Simulink 1998 URL www library cmu Ramine Nikoukhah and Serge Steer SCICOS A Dynamic System Builder and Simulator Users Guide 1998 URL Also as scilab soft inria fr doc scicos scicos pdf Giovanni Racciu and Paolo Mantegazza RTAI 3 3 User Manual 2006 URL www rtai org in Documenta tion Reference Documents G Sallet Ordinary differential equations with Scilab Universit de Saint Louis INRIA Lorraine Universit de Metz 2004 URL www math univ metz fr sallet ODE_Scilab pdf Pasi Sarolahti Real time application interface Technical report University of Helsinki Dept of Comp Sci 2001 URL www cs helsinki fi u sarolaht papers rtai pdf BibTex entry for this document Manual RTAILab 2006 title RTAI Lab tutorial Scicoslab Comedi and real time control author Roberto Bucher and Simone Mannori and Thomas Netter year 2006 url www rtai org RTAILAB 45 C About this document Bug reports This tutorial and associated source code can be downloaded in PDF and HTML from This tutorial should be considered work in progress and subject to frequent updates we therefore request
41. ign function menu Edit gt Align Click on the Sine block s data output port the black triangle to the right of the block and then on the Scope s data input port One of the blocks will then be shifted so that both blocks ports are aligned A faster way to align blocks using keyboard shortcuts is to place the mouse over a block s port input or output then use keyboard shortcut a then click on the port of the block to be aligned e Adjust mouse acceleration so that motion increments are more discretized type xset m 4 1 ina terminal shell window The drawback is that your mouse might move too fast for comfort Link blocks Menu Edit gt Link Click on Sine s output port Click on Scope s input port A link is drawn from Sine to Scope Click on the clock s event output port the red triangle below the clock Then draw an S shaped link to the Sine block by clicking below the clock s port once more above the Sine s event port and finally directly onto the Sine s event port A red link is drawn from the clock to the Sine Draw another event link by clicking onto the red line then click above the Scope and click again onto the Scope s event port Set block parameters Click on the clock You may adjust period and initialization times values are in seconds Click on Sine adjust parameters accordingly then click on OK You may also edit the Scope s name and notice that it may actually have more than one data input In any cas
42. inewave snaking smoothly in the scope Note that the Scope Manager lets you modify display properties such as the number of grid division Sec Div colors and filename You can save data points default 1000 to a file default filename SCOPE You may also pause the display Each trace s properties can also be adjusted via the Trace tab The trace can be hidden its offset shifted and its color changed You may also adjust the number of units per vertical division File View Help General M Show Hide Sec Diy 01 y Pause Run OneShot Run M Points Time N Points 1000 Time s 1 0 Grid Color Filename SCOPE By Color Save Help Close Y Grid on off Target Untitled Figure 7 xrtailab with scope manager window and a scope displaying a 1 Hz sinewave Most functions of the row of buttons are duplicated in the drop down menus Keyboard shortcuts are also available 3 4 4 Change parameters xrtailab lets you change on the fly the parameters that were defined in the Scicos block diagram For example the Sine block has 5 parameters amplitude Value 0 frequency Value 1 phase Value 2 bias Value 3 and delay Value 4 Click on the Parameters button The Parameters Manager window opens You might have to resize xrtailab s window and reposition the Parameters Manager window to obtain a convenient layout similar to that shown in figure 8 Change Value 0 to 3 and press the E
43. lab 3 4 1 Create block diagram Let s create the preliminary Sinewave diagram shown in figure B Select palettes Start Scicos Open the Sources palette click on menu Edit Palettes and select Sources at the top of the pop up window Open the RTAI Lib palette in a similar way figure i Keyboard shortcuts Note that by default Scicos has a few customizable keyboard shortcuts list them with menu Misc gt Shortcuts Select blocks From the Sources palette left click on the red clock Move your mouse to the main Scicos window You should see the block s contour being dragged as your mouse cursor enters the main Scicos window Left click again to place the clock in the main Scicos window somewhere towards the upper center of the window You may also right click to cancel block placement during the drag From the RTAI Lib palette left click on the Sine block and place it towards the lower left of the main Scicos window Place also a Scope block towards the lower right 16 Click to open block or make a link Diagran Edit Simulate Object Misc RTAIJ st Scope Sine SCOPE Figure 3 Preliminary RTAI Lib block diagram with real time sinewave generator and xrtailab scope blocks Align blocks Scicos does not currently feature a block placement grid so blocks are not perfectly aligned to make a nice diagram Two methods can help block alignment e Use Scicos s Al
44. lock gt ipar 1 if u 0 gt 0 val 0x01 lt lt block gt ipar 0 else val amp 0x01 lt lt block gt ipar 0 outb val block gt ipar 1 static void end scicos_block block outb 0x00 block gt ipar 1 void rt_pport_out scicos_block block int flag if flag 1 set output inout block else if flag 5 termination end block else if flag 4 initialisation init block 5 2 6 Compile the implementation files ppor COPYRIGHT C 2007 Roberto Bucher roberto bucher supsi ch This library is free software you can redistribute it and or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation either version 2 of the License or at your option any later version This library is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU Lesser General Public License for more details You should have received a copy of the GNU Lesser General Public License along with this library if not write to the Free Software Foundation Inc 59 Temple Place Suite 330 Boston MA 02111 1307 USA include lt machine h gt include lt scicos_block4 h gt include lt sys io h gt static void init scicos_block block static void inout scicos_block block iL double y
45. lt is Untitled 18 e Created files Path This is the directory where the generated C files are saved along with a Makefile This is also the directory where compilation occurs e Target This is the Makefile s basename It will be copied to the generated files directory and used for compilation The default value rtai corresponds to the file SCILAB macros RTAI RT_templates rtai mak e Sampling Time This corresponds to the Period value set in the Clock block parameters i e you can adjust the clock here Click on OK and the compilation starts Steps in the compilation can be monitored in the Scicoslab window Fig Br In case the compilation fails this can happen for example when you develop your own custom blocks see section B you can still start the compilation manually by typing make in the directory where C files were generated This provides more debugging output that what is printed in the Scicoslab window If you kept the default values you should find an executable file called Untitled in your current directory 3 4 3 Execute Open two terminal shells Real time executable In the first terminal type Untitled u This provides usage instructions as a list of command line options To start the real time executable with verbose output type Untitled v xrtailab Note that xrtailab only executes when an RTAI Linux kernel is running xrtailab will generate a segmentation fault if started over a standard Linux kernel In the seco
46. mber of inputs 1 the FIFO s number 0 and the FIFO s Dimension 50000 in bytes 4 Comedi hardware drivers e Comedi A D Comedi supported Analog Input You can select your acquisition card s analog input channel 0 the device if you have several acquisition cards comedi0 the range number as specified in your acquisition hardware s manual 0 warning the value to enter is not expressed in volts and the type of voltage reference 0 e g nonreferenced single ended referenced single ended and differential See also Comedi API comedi_data_read Comedi D A Comedi supported Analog Output The parameters are similar to Comedi A D See also Comedi API comedi_data_write Comedi DI Comedi supported Digital Input You can select the channel 0 and device comediO See also Comedi API comedi_dio_read Comedi DO Comedi supported Digital Output You can select the channel 0 device comediO and threshold 1 If the data input to the block is greater than the threshold value then a single bit will be output by your hardware See also Comedi API comedi dio write 5 Semaphores and more Semaphores can be used to synchronize real time tasks Similarly to mailboxes caution is needed with respect to blocking when exchanging a semaphore between a local and a remote host e SEM wait Decrement a semaphore s value and wait for a signal event The caller task is blocked and queued up as long as the semaphore s value is negative
47. model break end end case define then pinout 1 paddr 0x378 model scicos_model model sim list rt_pport_out 4 if exists inport then model in ones inport 1 else model in 1 end model out model evtin 1 model rpar model ipar pinout hex2dec strsubst paddr 0x model dstate model blocktype d dep_ut t 4f exprs sci2exp pinout paddr model rtai_pport_in sci function x y typ rtai_pport_in job argl arg2 x y typ select job case plot then exprs argl graphics exprs pinin exprs 1 paddr exprs 2 standard_draw arg1 case getinputs then x y typ standard_inputs arg1 case getoutputs then x y typ standard_outputs arg1 case getorigin then x y standard_origin arg1 case set then x argl model arg1 model graphics arg1 graphics exprs graphics exprs while t do ok pinin paddr exprs getvalue Set block parameters Parallel port Input 1 5 Parallel port Address list vec 1 str 1 exprs if ok then break end in if exists outport then out ones outport 1 else out 1 end model graphics ok check_io model graphics in out 1 if ok then graphics exprs exprs model rpar model ipar pinin hex2dec strsubst paddr 0x model dstate x graphics graphics x model model break end end case define then pinin 1 paddr gt 0x378 gt mo
48. n hardware section 2 of Comedi documentation www comedi org doc The Comedi manual and man comedi_config show how to associate a partic ular driver and hardware device to one of the dev comedi device files For example to configure a National Instruments 6024E PCMCIA card type comedi_config v dev comedi0 ni_mio_cs and the output is configuring driver ni_mio_cs 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 WARNING with the new udev platform there are some problems if the new inodes are not registered see Section A 3 2 9 RTAI 2nd pass 1 cd usr src rtai 2 make xconfig Or make menuconfig 3 Menu Add ons e Select COMEDI support over LXRT e Specify COMEDI installation directory usr local or usr The directory should contain lib libcomedi a include comedi h and include comedilib h 4 Menu RTAI Lab e Select RTAI Lab e Adjust EFLTK installation directory default is usr local 5 Exitxconfig menuconfig and save configuration 6 make and make install 2 10 ScicosLab The binary installation file for different Linux distributions can be downloaded at the project homepage www scicoslab org The Scicoslab add ons for thenew Scicoslab 4 4 version are provided in vulcano cvs 2 11 RTAI Lab add ons to Scicoslab 4 4 1 cd usr src vulcano rtai lab scicoslab macros 2 Adjust Scicoslab version and installation directory in Makefile e g SCILAB_VERSION 4 4b7 3 make install 2 12
49. n used for Hardware in the loop HIL tests see www scicos org This code may also call external C libraries The C code is segmented according to a flag s value thereby defining the job type such as et al 2006 Nikoukhah and Steer 1998 Initialization flag 4 Output update flag 1 State update flag 2 Integrator calls flag 0 Mode and zero crossing flag 9 Event scheduler flag 3 Ending flag 5 Source code for Scicos and RTAI Lab blocks may provide useful guidance and is available in the sci files in directories SCILAB_DIR macros scicos_blocks and SCILAB_DIR macros RTAI 34 5 2 Hardware example parallel port LED blinker This example uses the parallel port to output and input a bit that will blink an LED The example shows how to e Build the circuit e Program Scicos blocks e Produce C code to access the parallel port 5 2 1 Parallel port LED circuit AA Build a circuit with a e LED 4700 e a DB 25 male connector iaa solder side 2 DATAO e an LED CEA 0000000000090 e a 470 resistor 2 A GND 18 5 ERROR Check your BIOS settings for parallel port mode and address The safest choice is SPP Standard Par allel Port and base address 0x378 other valid addresses are 0x278 or 0x3BC This example outputs to pin 2 DATAO base address bit 0 and inputs from pin 15 ERROR base 1 Bit 3 Parallel port pinout addresses are detailed in
50. native to your standard Linux kernel In other words you should not use RTAI as the only kernel on you system You should use your computer s boot menu Lilo or Grub to select either your current Linux kernel RTAI Linux kernel or other operating system A 1 Kernel configuration As a first try you should configure a minimum RTAI kernel You may then add hardware drivers CD sound etc after some testing For help on configuring a kernel see e www linuxdocs org HOWTOs Kernel HOWTO html e www linuxheadquarters com howto tuning kernelcontfig shtml Note that a convenient starting point if you have already compiled a Linux kernel of a similar 2 x generation is to copy the config to the new linux 2 x xx rtai directory and type make oldconfig The following guidelines are for a 2 6 x kernel Now launch the configuration tool nake xconfig Or make menuconfig cd usr src linux 2 x xx rtai make xconfig Of make menuconfig General setup select Prompt for development General setup set Local version to rtai Enable loadable module support select Enable module support Module unloading and Auto matic module loading Deselect Module versioning support RTAI modules are not version depen dent Processor type and features Select your Subarchitecture Type PC Compatible and Processor family Select Preemption Model Preemptible kernel Low Latency Desktop You might need High Memory Supp
51. nd terminal type xrtailab h xrtailab Select menu File gt Connect keyboard shortcut alt c then Click on OK Fig 6 127 0 0 1 IP Address IFTASK Task Identifier Figure 6 xrtailab s connect dialog box RTS Scope Identifier IP Address is that of the host where the real time task is executing If RTL Log Identifier you are working local you can enter 0 as IP Address Cre Identifiers IFTASK RTS RTL RTE RTM and RTY are predefined in RTM Meter Identifier rtmain c in the directory that contains the generated source code If several real time tasks must run in parallel a real time task s identifiers RTY Synch Identifier may be set via the command line options execute the task with option u to list command line options and by adjusting values in the Connect to Target dialog Note that you may even edit rtmain c to change the real time task s predefined identifiers J Cancel xrtailab s row of buttons Fig 7 lets you start and stop the real time executable and open various displays such as scopes meters and LEDs At the time this tutorial is written not all buttons are fully functional Some may find it more convenient to use the View menu and associated keyboard shortcuts Open a scope manager window by either clicking on the Scope button or selecting it in the View menu shortcut alt s Then click on the Show Hide checkbox to display the scope You should see a 1 Hz s
52. ning the new blocks you need to inform the linker about your new library You need consequently a new template Makefile which substitute the provided rtai mak and a new target file which substitute rtai gen Your new target saved for example as pport gen file must be pport mak standalone cmd and the corresponding template Makefile looks like Makefile generate from template rtai mak all MODEL RTAIDIR shell rtai config prefix C_FLAGS shell rtai config lxrt cflags SCIDIR SCILAB_DIR RM rm f FILES_TO_CLEAN o MODEL CC gcc CC_OPTIONS 0 DNDEBUG Dlinux DNARROWPROTO D_GNU_SOURCE MODEL MODEL OBJSSTAN rtmain44 o common o MODEL o 0BI SCILIBS SCIDIR libs scicos a SCIDIR libs poly a SCIDIR libs calelm a 38 SCIDIR libs blas a SCIDIR libs lapack a SCIDIR libs os_specific a OTHERLIBS ULIBRARY RTAIDIR 1ib libsciblk a RTAIDIR 1ib liblxrt a RTAIDIR lib libmysci a CFLAGS CC_OPTIONS 02 I SCIDIR routines I SCIDIR routines scicos C_FLAGS DMODEL MODEL DMODELN MODEL c rtmain44 c RTAIDIR share rtai scicos rtmain44 c MODEL c cp lt MODEL COBJSSTAN CULIBRARY gcc static o 0 OBJSSTAN SCILIBS ULIBRARY lpthread lm Cecho Created executable MODEL clean RM FILES_TO_CLEAN where the only difference to the original rtai mak file is in the line with
53. nter key The sinewave s amplitude will increase accordingly Change Value 1 to 2 This will double the sinewave s frequency to 2 Hz and you will notice that the wave lost its smoothness This is an undersampling effect induced by the fact that the clock s period as defined in the Scicos block diagram is only of 0 1 s or 10 Hz Note that the Parameters Manager also lets you download block parameters from real time tasks running on remote hosts and upload them back after modification 3 4 5 Stop executable Click on the Stop hexagonal icon to disconnect xrtailab from the real time target and terminate it Note that it is possible to only disconnect xrtailab from a target alt d and leave it running You can re connect to it later Finally you may also interrupt the real time executable directly at the terminal where you launched its execution type ctrl c 20 RTAI Lab Graphical User Interface File View Help a asa aaa gt ABE a General V Show Hide Sec Div 01 xj Pause Run OneshotvRun M Points Time N Points 1000 Time s 1 0 Grid Color Filename SCOPE Bg Color Save Y Grid on off Parameters Manager Block Parameters IPARAM 1 al Value 0 3 Valuefl 2 Value 2 0 h Walue 3 0 v Batch Download Download Upload Help Close Al Target Untitled Figure 8 xrtailab with Parameters Manager window Parameters that have been changed are sinewave amplitude Value 0 from 1 to
54. nux kernel udev automatically creates device inodes in the dev directory upon device detection It later deletes those inodes as the devices are unused RTAI uses inodes in dev for FIFOs message passing between user and kernel space and to interact with data acquisition hardware It is therefore necessary to create persistent inodes You can for example launch the script below prior to loading RTAl and Comedi modules make it executable with chmod 777 rtai inode rtai inode RTAI inode creation for UDEV systems creates dev rtf n rm f dev comedi dev rtf dev rtai_shm for n in seq 0 9 do rm f dev rtf n mknod m 666 dev rtf n c 150 n done create shared memory inode mknod m 666 dev rtai_shm c 10 254 create Comedi inodes for i in seq 0 15 do rm f dev comedi i mknod m 666 dev comedi i c 98 i done Basically udev has an init script that reinstalls all devices in dev A user can create devices in lib udev devices and the init script will copy them into dev at boot time The above script can be modified to create devices under 1ib udev devices B Reference standard parallel port DB 25 Pin allocation Pin Name Func Register Hardware Inverted l 1 nStrobe In Out Control Yes 2 Data 0 Out Data I O BASE valid address 0x378 0x278 0x3BC 3 Data 1 Out Data DOSSI 4 Data 2 Out Data BASE 0 Data Re
55. of the block structure are listed below int block gt nevprt binary coding of activation inputs 1 if internally activated int block gt nz size of the discrete time state double block gt z vector of size nz discrete time state int block gt nx size of the continuous time state double block gt x vector of size nx continuous time double block gt xd vector of size nx derivative of continuous time state 39 double block gt res vector of size nx only used for internally implicit blocks int block gt nin number of inputs int block gt insz input sizes double block gt inptr table of pointers to inputs int block gt nout number of outputs int block gt outsz output sizes double block gt outptr table of pointers to outputs int block gt nevout number of activation output ports int block gt nrpar number of real parameters double block gt rpar real parameters of size nrpar int block gt nipar number of integer parameters int block gt ipar integer parameters of size nipar int block gt ng number of zero crossing surfaces double block gt g zero crossing surfaces int block gt jroot char block gt label 41 40 A Notes on Linux configuration and installation This appendix details how to configure a new RTAI kernel that you will boot as an alter
56. ort 4GB if you use a PCMCIA data acquisition card Deselect Use register arguments EXPERIMENTAL Possibly deselect Local APIC support on uniprocessors Power Management options Select ACPI Support and features relevant to your hardware Leave APM deselected Leave CPU Frequency scaling unselected Warning ACPI support may be a prob lem on laptops that use the screen closed button to put the computer into sleep or standby modes Bus options Leave the default Check the support for your hardware Laptops need PCCARD PCMCIA CardBus support and PC card bridges e g CardBus yenta compatible bridge support Device Drivers Generic driver options keep default Memory Technology Devices MTD not needed Parallel port support unselect Parallel port support The standard parallel port is a useful device for realtime debugging and experimenting You must leave it unselected so that Comedi s drivers can directly access the port Plug and Play support keep default Block devices select your devices Fedora Core lll needs Ram Disk Support and Initial RAM Disk initrd to boot ATA ATAPI MFM RLL Support select the main item ATA ATAPI MFM RLL support and all items relevant to your system SCSI device support select SCSI device support and keep the default selections according to your computer s SCSI devices Multi device support RAID and LVM only needed in special case
57. r realtime include 02 I usr src linux include Wall Wstrict prototypes pipe I usr realtime include scico s DMODEL Untitled c o Untitledc o Untitledc c gcc static o Untitled rtmain o Untitledc o usr local scilab 4 O libs scicos a usr local scilab 4 0 libs lapack a usr local scilab 4 0 libs poly a usr local scilab 4 0 libs calelm a usr local scila b 4 0 libs blas a usr local scilab 4 0 libs lapack a usr realtime 1 ib libsciblk a usr realtime lib liblxrt a lpthread lm 48 Created executable Untitled PLEASE GIVE US SOME INFORMATION New block s nane fees Created Files Pathe hone tnetter Untitled_rtai Target ftai Figure 5 Block diagram code generation and compilation a Scicos window after code generation b Dialog box to adjust generated filenames makefile and clock period c Text output after compilation Compile block diagram Menu RTAI gt RTAl CodeGen Then click on the Super Block At this point Scicoslab converts your block diagram into C code For each block inside the Super Block two lines are output in the Scicos window Fig 5B shared archive loaded Link done A dialog then opens Fig 5p shows the dialog with default values where you may modify e New block s name This will be the name of the final executable It will be saved in what Scicoslab thinks is your current directory The defau
58. s For Fedora Core III default installation you need this option enabled with LVM Device Mapper enabled too 41 Network device support keep defaults Explore the devices submenu until you find your net work interface The command 1spci may reveal the name of your ethernet controller Amateur Radio Irda Bluetooth ISDN subsystem and Telephony support Leave disabled You may enable these later Input device support Ensure that Mouse is selected Character devices Ensure dev agpart AGP Support and Direct Rendering Manager XFree 4 1 0 and higher DRI support are selected See coments below about video card selection 12C support keep unselected there are reports of difficulties when used with RTAI Multimedia devices keep unselected You may enable these later Graphics support keep unselected possibly enabling later With this option you can use the advanced features of your video card but sometimes this creates compatibility problems Sound preferably enable as module and select suitable drivers USB Support preferably enable as module e File Systems Second extended fs support select Ext3 journalling file system support select it and Ext3 extended attributes Reiserfs support the Suse distribution uses it maybe your Linux distribution doesn t need it CD ROM DVD Filesystems select ISO 9660 and sub items DOS FAT NT Filesystems s
59. sr local scilab 4 x x macros RTAI In any case the original blocks provided with the RTAI distribu tion are in usr src rtai rtai lab scilab macros RTAI Most of these blocks call up RTAI Lab functions written in C and compiled into the library usr realtime lib libsciblk a The source code of the C functions is in usr src rtai rtai lab scilab devices lf you look at the source code of the RTAI Lab functions you will see how RTAI API functions are called These RTAI API functions are documented in HTML and other formats in usr src rtai doc generated if you specified that documentation be gener ated during RTAI installation section 2 6 A detailed review of RTAI Lib blocks follows Default values are indicated in brackets 1 Inputs e Sine Real time sinewave generator The Sine block lets you adjust amplitude 1 frequency 1 Hz phase 0 bias 0 and delay 0 Furthermore you can adjust these parameters from xrtailab or an external program while the real time executable is running 14 Square Real time square waveform The Square block lets you adjust amplitude 1 pe riod 4 s pulse width 2 s bias 0 and delay 0 s You can also adjust parameters from xrtailab or other programs during real time execution Step Step function The Step block lets you adjust amplitude 1 and delay 0 s extdata Load data from a file The file test dat must contain a single column with ASCII values at each sampling time 10
60. tage input to motor position output dtf 2 9 454E 10 0 0010214z 0 0010389z 0 9424937z 1 9424937z z which after simplification and reordering corresponds to 0 001z 0 001 22 1 94252 0 9425 You can recover the transfer function s plot of Fig with td 0 T 0 2 u ones 1 size td 2 plot2d td C dsimul tf2ss dtf u 4 4 3 Digital control Build upon the superblock resulting from the block diagram of Fig 16p and generate the diagram of Fig 18p e Left clock Period 0 1 Init time 0 e Square wave generator Amplitude 1 e Discrete transfer function num z den z Numerator z 450 z 0 85 z 0 85 Denominator z z 0 98 z 0 7 30 Scope block Ymin 1 5 Ymax 1 5 Refresh period 0 2 e Menu Simulate Setup Final integration time 0 2 e Menu Simulate gt Eval e Menu Simulate gt Run produces the animated plot of Fig 18 a b 1 50 3 FTA a D r e 0 75 7 l T I ae wave y i J Mi generator El z k a oa a S H Ni 8 o S H pl fe l controller continuous plant ae Figure 18 a Closed loop system with digital controller b Step response 4 4 4 RTAI Lab controller In its current version RTAI Lab requires the block diagram to be simplified Fig 19 Mn a p DESEE a r Square num z num z see pe gt den z A S H den z gt SCOPE controller
61. that you do not make it available on other web sites This document is copyright 2005 2008 Roberto Bucher Simone Mannori Thomas Netter The first edition June 14 2006 of this document was written and tested with Linux 2 6 12 6 patched with RTAI 3 3 Scilab 4 0 Comedi CVS downloaded 2006 06 09 This 3rd edition Mar 14 May 23 2007 Feb 2008 was updated to RTAI 3 5 and partly tested with Linux 2 6 23 14 patched with RTAI 3 6 Scilab Scicos 4 1 2 Comedi CVS gcc 4 1 3 Mesa 7 0 2 efltk 2 0 7 C 1 About the authors Roberto Bucher lt roberto bucher at supsi ch gt is a lecturer and researcher in automatic control with the Pe i A at the University of Applied Sciences of Southern Switzerland SUPSI in Manno near Lugano He is the main developer of RTAI Lab Homepage ruw dt supsi ch bucher Simone Mannori lt smannori at f2n it gt is a research engineer with the METALAU project at the French National Institute for Research in Computer Science and Control INRIA in Rocquencourt near Paris He is currently developing Scicoslab s hardware in the loop soft real time functionalities Thomas Netter lt tnetter at ifi unizh ch gt is a researcher with the Artificial Intelligence Laboratory Uni versity of Zurich Switzerland His work focuses on real time control vision and unmanned air vehicles UAV Homepage www ifi unizh ch ailab people tnetter C 2 Bug reports suggestions RTAI Lab queries If you no
62. the ULIBRARY where we added the name of the new library libmysci a 5 2 9 Create a scicos block palette for the new files Create a new diagram with Diagram gt New Load new blocks into this diagram with Edit Add New Block You may also slide blocks from pre existing palettes into this new diagram Then save your diagram with Diagram gt Save as Palette for example as pport cosf The next step is the generation of the palette tree which can be performed using the following script unix ls 1 sci gt x x txt mgetl x x create_gif txt gif_icons mdelete x x The last step is to integrate the new palettes into the scicoslab environment Simply put the following lines in the scilab file scicos_pal 1 SUPSI Lib home bucher ScicosPP develop scicosdev pport cosf scicos_gif 1 home bucher develop ScicosPP scicosdev gif_icons 5 3 Scicos C block data structure When a block is linked to another in the Scicos GUI the link allows data to be passed from one block to its successor When a block diagram is converted to C code the block s data passing scheme along with some parameters are represented in C by the block data structure of type scicos_block see SCI routines scicos scicos_block h See usage examples in the c files in SCI routines scicos and in the RTAI Lab sci files in SCI macros RTAI gives more details on how to use this structure Members
63. tice software bugs have questions wish to suggest improvements to RTAI Lab such as submit new blocks for the RTAI Lib palette contact the main developer lt roberto bucher at supsi ch gt For bug reports please provide Linux kernel version RTAI version RTAI patch number CPU type data acqusition hardware type Scicoslab version gcc g cpp versions the block diagram that may cause the bug cos file outputs using verbose option v and possibly kernel logs resulting from tail f var log syslog RTAI Lab tutorial queries If you notice typos errors omissions or have contributions to make to this tutorial contact the author of this tutorial Thomas Netter lt tnetter at ifi unizh ch gt RTAI queries Check www rtai org and its associated mailing list Scicoslab queries Check www scicoslab org and the newsgroup C 3 Software licenses RTAI Lab RTAI and xrtailab are subject to the GNU Lesser General Public License Comedi is subject to the GNU General Public License Scicoslab and Scicos are subject to a specific license See scilabsoft inria fr legal license html C 4 Acknowledgements The authors wish to thank e Paolo Mantegazza RTAI project leader at the Department of Aerospace Engineering of the Politecnico di Milano for contributing so much to the development of RTAI Lab e Ramine Nikoukhah Scicos project leader with METALAU project at INRIA for helping adapt Sci coslab to generate RTAI code and supporting RTAI La
64. tlab Scicoslab Octave chainlink sf net 48
65. xt enter values for constants J 3 2284E 6 b 3 5077E 6 K 0 0274 R 4 L 2 75E 6 Menu Simulate gt Setup Final integration time 0 2 Step block Step time 0 Initial value 0 Final value 1 Clock block Period 0 001 Init time 0 Scope block Ymin 0 Ymax 8 Refresh period 0 2 Menu Simulate gt Eval Menu Simulate Run produces the plot of Fig 16p Digital model Menu Diagram gt Region to Super Block draw a frame around the computational blocks as shown in Fig 17p You then obtain a superblock Menu Diagram gt Save As save to dcmot model cos Menu Object gt Get Info then click on the superblock A window opens select Others Yes and click on OK Fig 17p A second window opens remember the superblock s object number here 43 Fig 17p and click on OK Menu Diagram gt Quit to exit Scicos then type n to get past the junk in the Scicoslab window In Scicoslab type replace the 43 in the 3rd line with your superblock s object number 29 Xscilab Figure 17 How to obtain information about a superblock prior to its discretization menu Object gt Get Info then a select Others Yes and b remember block s object number 43 load dcmot model cos J 3 2284e 6 b 3 5077e 6 k 0 0274 R 4 L 2 75e 6 scs_m scs_m objs 43 model rpar sys lincos scs_m dtf ss2tf dscr sys 0 001 You then obtain the discrete time transfer function from vol
66. y Matlab txt e The Mesa 3D graphical library e The EFLTK graphic widgets library e Anew Linux kernel that will be patched with RTAI code e The Comedilib data acquisition device interface library e The RTAI real time modules e The Comedi data acquisition device modules e The Scicoslab Computer Aided Control System Design CACSD software Note The next sections list commands where software minor versions are indicated with x x Make sure to replace the x with version numbers that correspond to your downloads 2 1 Requirements 2 1 1 Hardware requirements Most PCs can run a Linux kernel patched with RTAI Some hardware configurations deserve a specific comment Comedi support Before starting the installation first check that your data acquisition card or external hardware is supported by Comedi See this page may be out of date If you don t see your hardware listed then download Comedi anyway see section 2 5 and look grep into usr local src comedi comedi drivers PCMCIA Our PCMCIA card was not detected with some Linux kernels 2 6 13 xx 2 6 14 xx 2 6 19 see note in Sec 2 4 Laptops amp PCI sharing We have experienced incompatibilities with some Toshiba Satellite laptops If you use a data acquisition card that plugs into the PCMCIA CardBus slot of a Toshiba Satellite laptop you might see warning messages about PCI devices sharing the same IRQ when loading Comedi modules RTAl Comedi might not work but give
Download Pdf Manuals
Related Search
Related Contents
Cours de moniteurs pour jeunes tireurs CAT®ミニホイールローダ「900Cシリーズ」 ASSEMBLING AND OPERATING INSTRUCTIONS Véase - Diotronic Grandstream GXP16xx Administration Guide NK-142-162+P - Nor-k Infochip User Manual SERVICE MANUAL Operation Guide Camper Crosley 1950's User's Manual Copyright © All rights reserved.
Failed to retrieve file