Hardware Access in Real-Time for scilab/scicos
sudo suDownload the newest debian package linux-image-3.8.0-42-generic_3.8.0-42.62~precise1_i386.deb (linux-lts-raring - 3.8.0-42.62~precise1) from https://launchpad.net/ubuntu/precise/i386/linux-image-3.8.0-42-generic/3.8.0-42.62~precise1 and save it to /usr/src
cd /usr/src/
cvs -d:pserver:anonymous@cvs.gna.org:/cvs/rtai co vulcano
ln -s vulcano rtai
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
cd linux-stable
git branch linux-3.8-rtai origin/linux-3.8.y
git checkout linux-3.8-rtai
git apply ../vulcano/base/arch/x86/patches/hal-linux-3.8.13-x86-4.patch
git commit -a -m 'applied the rtai patch hal-linux-3.8.13-x86-4.patch'
exit
sudo suImportant: It is needed to deselect "Module versioning support" under "Enable loadable module support".
cd /usr/src
dpkg-deb -x linux-image-3.8.0-35-generic_3.8.0-42.62~precise1_i386.deb linux-image
cp linux-image/boot/config-* linux-stable/.config
cd linux-stable
make menuconfig
make -j `getconf _NPROCESSORS_ONLN` deb-pkg LOCALVERSION=-rtaiNow install linux-image package and the linux-header package with dpkg
exit
cd /usr/srcThe number {x} depends on how many linux-image-3.8.13-rtai and linux-headers-3.8.13-rtai deb packages are in /usr/src.
sudo dpkg -i linux-image-3.8.13-rtai_3.8.13-rtai-{x}_i386.deb
sudo dpkg -i linux-headers-3.8.13-rtai_3.8.13-rtai-{x}_i386.deb
uname -rThe output of uname -r should now contain rtai.
cd /usr/src/rtaiEnsure directories are correct:
sudo make menuconfig
sudo makenow run export PATH=/usr/realtime/bin:$PATH for each open shell or do logout and login
sudo make install
sudo sed -i 's/\(PATH=\"\)/\1\/usr\/realtime\/bin:/' /etc/environment
sudo su
cd /usr/local/src/
git clone git://comedi.org/git/comedi/comedi.git
git clone git://comedi.org/git/comedi/comedilib.git
sudo su
cd /usr/local/src/comedilib
sh autogen.sh
./configure
makev make install
mkdir /usr/local/include/linux
exit
sudo su
cd /usr/local/src/comedi
sh autogen.sh
./configure --with-linuxdir=/usr/src/linux-headers-3.8.13-rtai --with-rtaidir=/usr/realtime
make
make install
make dev
ldconfig
exit
sudo cp /usr/local/src/comedi/include/linux/comedi.h /usr/local/include/Under “Add-Ons”, select “Real Time COMEDI support in user space”
sudo cp /usr/local/src/comedi/include/linux/comedilib.h /usr/local/include/
sudo ln -s /usr/local/include/comedi.h /usr/local/include/linux/comedi.h
sudo ln -s /usr/local/include/comedilib.h /usr/local/include/linux/comedilib.h
cd /usr/src/rtai
sudo make menuconfig/usr/src/rtai/addons/comedi/Makefile Must be edited as followed:
EXTRA_CFLAGS += -I$(rtai_srctree)/base/include \
-I$(rtai_srcdir) \
-I/usr/include \
-I/usr/local/src/comedi/include \
-I$(src)/../../base/include \
-I$(src)/../.. \
$(rtai_extradef) \
-D__IN_RTAI__
obj-m += rtai_comedi.o
rtai_comedi-objs := $(rtai_objs)
make
make install
exit
/sbin/insmod /usr/realtime/modules/rtai_smi.koCopy the lines to /usr/local/bin/start_rtai
/sbin/insmod /usr/realtime/modules/rtai_hal.ko
/sbin/insmod /usr/realtime/modules/rtai_lxrt.ko
/sbin/insmod /usr/realtime/modules/rtai_fifos.ko
/sbin/insmod /usr/realtime/modules/rtai_sem.ko
/sbin/insmod /usr/realtime/modules/rtai_mbx.ko
/sbin/insmod /usr/realtime/modules/rtai_msg.ko
/sbin/insmod /usr/realtime/modules/rtai_netrpc.ko
/sbin/insmod /usr/realtime/modules/rtai_shm.ko
#!/bin/bashReplace your_comedi_card with the name of your comedi card (e.g.: s626, jr3_pci, ....)
cd /usr/local/src/comedi
make dev
ldconfig
cd ~
insmod /lib/modules/3.8.13-rtai/comedi/comedi.ko
insmod /lib/modules/3.8.13-rtai/comedi/kcomedilib/kcomedilib.ko
insmod /usr/realtime/modules/rtai_comedi.ko
insmod /lib/modules/3.8.13-rtai/comedi/drivers/comedi_fc.ko
comedi_config /dev/comedi0 your_comedi_card
chmod o+rw /dev/comedi*
chmod go+rw /dev/input/event*
sudo apt-get install scilab
cd /usr/local/srcEdit qrtailab.config and replace '/usr/include/qwt/' with '/usr/include/qwt-qt4/' and '-lqwt' with '-lqwt-qt4'
sudo svn checkout http://svn.code.sf.net/p/qrtailab/code/trunk qrtailab
cd qrtailab
sudo qmake-qt4
sudo make
sudo make install
svn checkout http://svn.code.sf.net/p/hart/code/trunk hart-codeGo in your hart-directory.
make
cd /...../scilab-xxx/contrib
sudo ln -s {link to hart-toolbox} .
It is important to add -o to your rtai executable in order get a good realtime! The default setting uses the periodic mode. The hard timer will run in oneshot mode when using the "-o" options, which works better for same systems and slow sampling rates (<10kHz).
Gratulation you are finished!