An Easy-to-use and Economic Experimental Apparatus for Motion Control Education

Motion control education in engineering requires hands-on experiments to catch the concept of feedback control, but experimental apparatus for motion control experiments is expensive, complex in mechanism and is hard to use it in general. In this paper, we develop an easy-to-use and economic experimental apparatus for motion control education using an open-source free operation system LINUX and a free real-time kernel RTAI. The developed apparatus is reliable in mechanical structure, and fast enough to realize 100 microsecond sampling time for real-time control purpose, and so it can test conventional PID control logics, various input shaping control logics and advanced motion control logics with cheap prices. The validity of the developed motion control apparatus is demonstrated by testing P, PD control logics and ZV input shapers experimentally.


Introduction
In recent years, open-source LINUX operating systems which are significantly developed for graphics user interface such as UBUNTU, FEDORA etc are available in public for LINUX users.These LINUX operating systems are convenient for programming since they include the open source libraries which have various control modules that are useful for control engineers.Even if LINUX is multi-tasking operating systems, it is not true real-time operating system.For real-time control purpose, we can import free real-time kernel such as RTAI into LINUX operating system.The usual way in industry for real-time control is to use the real-time operating system (RTOS), but this is very expensive in general due to high cost of RTOS.There are many research works that use RTAI and LINUX for the development of a laboratory model (Anju, 2008), an electromechanical system (Matej & Martin, 2008), and a real-time control system (Michele et al., 2005), and a motion control system (Kwak & Kang, 2010).Motion control education in engineering requires hands-on experiments to catch the concept of feedback control, but experimental apparatus for motion control experiments is expensive, complex in mechanism and is hard to use it in general.In this paper, we develop an easy-to-use and economic experimental apparatus for motion control education using an open-source free operation system LINUX and a free real-time kernel RTAI.We use open-source operating system UBUNTU 11.04LTS, RTAI version 3.8, COMEDI library and NI PCI 6221 card to make a real-time apparatus.The controlled object is an AC servo motor connected with ball screw.The developed apparatus is reliable in mechanical structure, and fast enough to realize 100 microsecond sampling time for real-time control purpose, and so it can test conventional PID control logics, various input shaping control logics and advanced motion control logics with cheap prices.The validity of the developed motion control apparatus is demonstrated by testing P, PD control logics and ZV input shapers experimentally.

RTAI and COMEDI software
After UBUNTU 11.04LTS operating system has been installed, we can choose appropriate module RTAI to install.The setup file and detail instruction can be found in website www.rtai.org.Before installing COMEDI library, we have to confirm that RTAI is successfully installed.We can use the command below to test RTAI.cd /usr/realtime/testsuite/kernel/latency ./runWhen the UBUNTU LINUX and RTAI kernel are correctly installed, we see the window as shown in Figure 1  To get more details about setup procedure, we can use the RTAI installation guide (Joan, 2008).After finishing installations of RTAI and COMEDI, we have to connect them to hardware NI PCI 6221 card.The instructions below show that how we can connect them together.
insmod /usr/realtime/modules/rtai_hal.koinsmod /usr/realtime/modules/rtai_lxrt.komodprobe ni_pcimion comedi_config /dev/comedi0 ni_pcimio Experimental apparatus: For hands-on experiences for motion control experiments, we developed an easy-to-use and economic experimental apparatus with one degree-of-motion.The developed experimental system is easy to use since it is simple in mechanical structure and it is using a standard operating system, and is economic since it uses free softwares such as UBUNTU LINUX, RTAI and COMEDI.The developed system includes a servomotor and driver, a ball-screw, an NI card, an encoder circuit, two laser sensors, a desktop PC with Core2duo processor, UBUNTU 11.04LTS operating system, RTAI 3.8 module and COMEDI softwares as shown in Figure 2. servo motor is processed with quadrature signal by encoder circuit before transferring to NI card.To detect motion and vibration of the moving parts of the system, two laser sensors are used to measure the displacements of the moving parts.

Experimental Demonstrations
To verify the validity of the developed motion control apparatus, we inserts program codes of our control logics into the program file.We only need to change the control logic part of the whole program, and thus you don't need to understand the whole program codes.Our experimental codes are written in C language using RTAI functions and COMEDI functions.To use RTAI and COMEDI functions, we have to add some header files at the top of the codes.

#include <rtai.h> #include <rtai_sched.h> #include <rtai_lxrt.h> #include <rtai_msg.h> #include <comedilib.h>
The following code is for generating 0.1 ms sampling time using RTAI for real-time motion control purpose.mlockall(MCL_CURRENT|MCL_FUTURE); rt_set_periodic_mode(); rt_make_hard_real_time(); start_rt_timer(nano2count( 100000)); rt_task_make_periodic( g_stask1, rt_get_time(), nano2count( 100000)); The first demonstration is P control (proportional control) of the developed motion control apparatus as shown in Figure 3.The plant dynamics is approximately a second-order system with a small damping, but the closed-loop system with a small proportional gain p K becomes an overdamped system as shown in Figure 4.If we increase the proportional gain p K further, then it becomes a critically damped system and then underdamped system, which are consistent with our intuitions.The P controller is given by ( ) ( ), ( ) ( ) ( ) p u t K e t e t r t y t    (1) where () et is an error signal, () rt is a position command, and () yt is an actual displacement of the moving part of the up-down motion system.Figure 4 shows step responses for 1 sec when the position command is 5 cm and the proportional gains are 0.5, 2 and 10.The actual code in the program for the P controller (1) is as follows double Kp = 2; . . .err = ref -yout; u = Kp*err;  The final demonstration is residual vibration control using a ZV (Zero Vibration) input shaper.When we attach a flexible beam on top of the moving part of the up-down system as shown in Figure 7, residual vibration will occur when we move the moving part in a step fashion.Figure 8 shows the block diagram of the input shaping control system, and Figure 9 shows the experimental results measured by a laser sensor at the end of the flexible beam.The laser sensor is put on the table and measures the distance between the end of the beam and the table.By adding a ZV input shaper, we see the residual vibration has been removed in Figure 9.The ZV input shaper is given by  From three experimental demonstrations, we have shown that the developed motion control apparatus is easy-to-use and economic in cost for motion control educations.With this experimental apparatus, users can easily change appropriate values for controller parameters by directly changing a part of the codes and recompiling.Furthermore, users can test various kinds of their control logics by modifying a part of the control logic codes.The developed apparatus has been used for teaching feedback control and input shaping control to undergraduate and graduate students at Konkuk University in Seoul, Korea for last two semesters, and it was very effective to teach motion control concept using the developed apparatus.The students were interested in doing experiments using the apparatus.

Conclusion
The open-source operating system LINUX combined with RTAI module and COMEDI library is very useful when we want to design a cheap real-time control system.This paper has shown how to build real-time experimental apparatus using RTAI and LINUX operating system.In this paper, we develop an easy-to-use and economic experimental apparatus for motion control education using an open-source free operation system LINUX and a free real-time kernel RTAI.The developed apparatus is reliable in mechanical structure, and fast enough to realize 100 microsecond sampling time for real-time control purpose.Furthermore we have shown this apparatus can be used successfully for motion control experiments in real-time.The validity of the developed motion control apparatus is demonstrated by testing P, PD control logics and ZV input shapers experimentally.

Figure 1 :
Figure 1: RTAI testing display when UBUNTU LINUX and RTAI kernel are correctly installed

Figure 2 :
Figure 2: Developed experimental apparatus for motion control education

Figure 3 :
Figure 3: Block diagram of the closed-loop control system with a P controller

Figure 4 :Figure 5 :Figure 6 :
Figure 4: Experimental step responses during 1 sec for P control when the position command is 5 cm and the proportional gains are 0.5, 2 and 10 input-shaped reference signal, () t  is Dirac delta function, 1 A and 2 A are impulse magnitudes, 2 t is the time location of the second impulse, n is the natural frequency of the flexible beam, and  is the damping ratio of the flexible beam.In the present case, the program for the ZV input shaper is as follows.doublezeta = 0.012; double wn = 5.04; double pi = 3.1416; double K = exp(-zeta*pi/sqrt(1-zeta^2)); double A1 = 1/(1 + K)); double A2 = K/(1 + K); double t2 = pi/wn; -yout; de = (err -pre_err)/Ts; pre_err = err; u = Kp*err +Kd*de;

Figure 7 :FigureFigure 9 :
Figure 7: Experimental apparatus with a flexible beam on top of the moving part of the system which displays RTAI testing results.To communicate with and control hardwares in real-time applications, COMEDI library provides drivers of hardwares and call feature functions of hardwares.The setup files can be downloaded by using commands below.git clone git://comedi.org/git/comedi/comedi.git git clone git://comedi.org/git/comedilib.gitgit clone git://comedi.org/git/comedi_calibrate.git git clone git://comedi.org/git/comedi-nonfree-firmware.git