of 5


Published on February 2018 | Categories: Documents | Downloads: 7 | Comments: 0




2010 8th IEEE International Conference on Control and Automation

Xiamen, China, June 9-11, 2010

MATLAB and LabVIEW in Modeling, Analysis and Real Time Control of a Motion Control System Raziye Tekin








programs, MATLAB and LabVIEW, for designing a motion


control system designe r' s level. Firstly, mathematical m odeling


control system and

and provides a brief look on the issue from the








permanent magnet brush type direct current motor and gear head is given with MATLAB and then suitable hardware for

specific purposes is mentioned. A fterwards, real time control of the system is presented with LabVIEW FPGA and LabVIEW

RT (real time).


The mathematical model of the pennanent magnet DC motor can be found very often in the literature [4], [5], and [6]. Here, it will be explained briefly. The motor torque Tm is proportional to the magnetic flux, which is proportional to the annature current Tm = Kml



where Km is the motor torque constant.


There are many motion control applications for industrial, medical and military applications where time, precision and accuracy is very critical. Motion control system which is precise and part of a full automation system needs a challenging modeling and control effort to match the model as possible as the physical system. Also, hardware selection is a critical issue, too. System must be modular to accommodate new needs, and must be reliable. There are also many tools for analysis, modeling and real time control. The two important software programs in this area are MATLAB and LabVIEW. MATLAB is a powerful, flexible design and analysis tool for engineering applications. Another powerful and simulation tool is LabVIEW which is sometimes used instead of MATLAB or in addition to MATLAB. Both of them are used in motion control area with various purposes. Efficient usage of these two programs depends on firstly application properties and secondly of course designer's desire. There are a number of studies increasing in literature that uses both of them in a single application such as [I], [2], and [3]. In this study, usage of MATLAB and LabVIEW will be seen for different purposes. Modeling of the brush type dc motor and a gear head, controller design for this system and its perfonnance analysis will be conducted with MATLAB. Hardware design will be explained as a function system's needs. As a result of these, a real time application software will be programmed with LabVIEW, with special emphasis on LabVIEW FPGA.

Due to the motor shaft rotation, there is induced back electromotor force E in the rotor coils. Back electromotor force is proportional to the rotor angular velocity w : E Kew (2) =

where Ke is the motor electrical constant. The torque and motor electric constant are so close to each other in datasheets. They are equal to each other for an ideal motor. Voltage equation of the rotor circuitry is: dl U Rl +L-+E (3) dt where R is annature resistance, while L is annature inductance. Combining (I) and (3) yields !:..dTm +T.m Km m U -Kew (4) R Rdt ratio L/ R defines motor electrical time constant Te ' =


The moments of inertia of Jm and Jg are equivalent

moments of inertia of the rotating motor and gear head, respectively. The following differential equations describe the dynamics of the rotating motor: dw J -= T.m T./ (5) dt where: (6) J;;;;;Jm+Jg -

is the total moment of inertia and

Raziye Tekin is a system algorithms' developer engineer at Roketsan Missiles Inc., Ankara, Turkey, (e-mail: [email protected]).

978-1-4244-5196-8/10/$26.00 @2010 IEEE

I :


1i is the load torque.

FrD1.4 Let 8m be the angle of the motor shaft rotation, then the

B. Controller Design

following can be written:

a dc motor, as in many industrial control applications, will be a proportional­ derivative (PD) controller. Controller design process is briefly illustrated as controller design is not the main purpose of this paper. T he d esign of the PD controller is bas ed on the continuous transfer function of the system as [5]:




Position controller for




In this study, load is considered as a function of deflection angle 0 thus ,





w here

� = �max



Equation (I)-(9) are used to develop nonlinear simulation model of an electromechanical system including permanent magnet dc motor and gear box, as given in Fig. I.


v.. -alC


s(ls(Ls+ R)+ K2)

In this transfer function, load is considered as a disturbance and its effect will be compensated by the controller. Controller is designed by Root Locus method according to the design parameters below: Overshoot: < % 10, Settling T ime : < 0.5 sn Steady State Error: O. Syn thesis of PD controller u(t) = Kpe(t) +







....r1i.JI Lood R






has been done using MATLABI Simulink environment. Designed controller's performance can be seen under the defined load in Fig. 3.

I. Electrical and mechanical models of brush DC motor



MATLAB/Simulink model is seen at Fig. 2. Load model is im p lemented by a look up table but it still processes the

'5 '0

same form mentioned previously.




I "

I \\ jI \





/ \



Posillon Graph



,I I







f ,[ \\!I \ I /'

� ·5

·'O� ·20

DC m otor and gear head specifi cations are pr esented in Table I.


Ke=Km 1m 19 N


Omax L













270.10-6 1.63

pH ohm



I \ I \t ,I \ I


\�1� ' _I 2




, /


t '

' I



i \ ! "







�_ \:�

3 Time





\ I I I I I \

i !

I ! ! I j. ,

desired position



\ I





,. I

\, /I"


Fig 3. System response under load. .




1- I \' \


Fig. 2. Simulink block diagram of DC m otor and gear head.




ff\\ ·Yi\- aclual/POSiti� -----


Real time control is a very popular working area of control. There are many definitions of real time concept but the following definition is appropriate to be cited: A real time system is one in which the correctness of a result

not only depends on the logical correctness of the calculation but also upon the time at which the result is made available [7].

So the, real time control hardware configuration is one of control where high time precisi on and hig h p erfor mance is needed. There ar e different ways of hardware selecti on options with su pported software. Some programs such as MA TLAB xPC Target, LabVIEW RT and LabVIEW FPGA support some hardware the most important subjects of real time


FrD1.4 component. Hardware is supplied according to needs and purposes which mean selecting hardware and deciding the software for this hardware is a closed loop system. If motion control software is going to work synchronized with some other systems and if an operator is going to use the software in the end, indicating that the designed system becomes a part of a full automation system for factories or laboratories, LabVIEW is preferable with its more efficient virtuality, wide options for hardware selection and help for implementation of graphical user interface. MA TLAB may also be enough in design phase but in real time application phase such as a part of full automation system it is much more difficult work with because of some reasons like limited hardware options, less compactness, harness in graphical user interface programming and difficulty in having high sample times (e.g. 70 kHz), which of all means MA TLAB is less useful as an automation software. So that, LabVIEW and National Instruments have been preferred for real time application of motion control system design. As a real time controller, NI Real Time Embedded Controller and Chassis (NI cRIO) which includes, real time controller, chassis mounted signal conditioning modules (see Fig. 4) has been chosen. Compact RIO is a small rugged industrial control acquisition system powered by reconfigurable 1/0 FPGA technology for also reliable for stand alone applications.

Driver, amplifier and digital or analog input for feedback sensor are also other hardware components of motion control. The possible hardware modules are NI 94 11 (6 channel, ± 5, 24V digital input module), NI 9205 (32 channel, ± 200mV to ± 10V, analog input module) and NI 940 I (8 channel, 5V TTL, high speed, bidirectional digital input/output). Additionally, an amplifier is needed that supplies the desired current limit. These modules can work with both LabVIEW RT and LabVIEW FPGA. However, instead of using distributed hardware for encoder decoding, Pulse Width Modulation (PWM) and amplifier, there is practical module that does all supplies all those things. This module is NI 9505. NI 9505 is for Compact RIO and it is a full H-bridge servo motor drive for direct connectivity to motors, actuators (up to 300 W at 40 degree) [9]. This module also includes a built in encoder interface for single ended or differential inputs for position feedback from a quadrature encoder. The Fig. 6 shows the total hardware architecture of the system with NI 9505.

O_ed.Time ... PWM



Input Real TIme Controller

Reconfigurable Chasls

Encoder NI950S

DC Motor

Fig. 6. Architecture of the system with NI 9505.

Fig. 4. Compact RIO. As seen in Fig. 5, FPGA is an intermediate processor between the RT and 110 modules, ethernet interface and shared variable engine. The important point of this Compact RIO is the FPGA unit which can run multiple, simultaneous process. The FPGA unit has a maximum clock frequency of 40 MHz and one important point of is that; it is programmed with LabVIEW not VHDL [8].

If a brief look from the software side is given, desired software loops for this hardware configuration can be programmed with two options. One is Soft Motion, a tool of LabVIEW for motion control; the other is programming all of the parts such as PWM, Encoder, Controller, Signal Generator and Data Transfer loops etc. The preferred direction in this study is the second one, namely one by one implementation of all the program parts. As seen from Fig. 6, LabVIEW FPGA has to be used for NI 9505, so a description of programs is needed. The dataflow of the LabVIEW control software is depicted in Fig. 7. The software consists of three independently running parts. The first part is the Host-VI (Virtual Instrument), which provides a user interface on a PC or laptop for an operator. It communicates with the RT-VI on the real time controller, which regulates the position of the motor, calculates the next position in dependence of the desired position, and evaluates the motor feedback signals from the FPGA-VI. The FPGA-VI generates the motor pulse-width modulation (PWM) and pulse generator signals, evaluates the switch, status, encoder, limit data.

Fig. 5. Compact RIO architecture.


FrD1.4 counterclockwise rotation. When an Index (Phase Z) is detected, the index position is recorded, but Index is not a must parameter to be used in calculating the position of the motor.

User Interface

I � (----------------------------------���-����;;;�-�--------------------------------'.




cooeol motor po� stalUS, etc

motor PWM ratio, rotation,

R.alllme(Rn motor control

dlrecUon. pOIIUon

--�t> <J---


control & pwm loop.

data processing

motor position. limit switch S1atus


Fig. 7.LabVIEW control software architecture. Fig. 8. shows status of NI 9505 like drive fault, drive status, supply voltage existence, cause of drive fault and enable/disable option for the drive. These characteristics can be seen and changed from Host-VI if needed.


N19505 Dnve Fait Drrve StabJs ENbIe E-5too VsupPr6ent Ove" Terroeraue


ftrnlDnve Fait --I'r....,1Drtve Status

!'IDIVli;£Pr...., tl


(D :OverT�abseFMAtl


Fig. 10. Encoder decoding program with LabVIEW FPGA. These routines (Fig. 9 and Fig. 10) are parts of the FPGA program. Real time program done with LabVIEW RT calls FPGA program, transfers the desired signal, PO parameters found in modeling phase, data transfer loop rates, etc to the FPGA program. The third program is for operator and operator only sees the desired signal, actual response. Operator only selects motion profile and pushes the trigger button to start the motion which is seen as a trigger signal. After motion is over, real time program saves the response and desired command in date-time order in jpeg and text format in a specified folder. Fig. II shows the response of the system to I Hz, 20 degree position command. As seen, PO controller's performance under load is good as expected from MATLAB/Simulink model analysis.

Fig. 8. LabVIEW FPGA program for NI 9505 properties.

_ ......

Fig. 9. shows the loop to create a PWM frequency of 20 kHz. The duty cycle input control is used to create the appropriate pulse width; in general, the duty cycle input is decided by control algorithm.


IpWM Generationl

Fig. II. Real time response graph under load. I!El



Fig. 9. PWM generation program with LabVIEW FPGA. Fig. 10 shows decoding position data from quadrature encoder signals on NI 9505. It decodes the Encoder Phase A and Encoder Phase B signals for position and counts up for clockwise rotation and counts down for


This paper presented a design process of a motion control system, starting from modeling and control to hardware selection and finally real time control. Two kinds of software programs are used depending on the desired application. Modeling, controller design and analysis phase of the study is presented with MATLAB. MATLAB is


FrD1.4 preferred because of the reasons mentioned for modeling and analyzing the system. Furthermore. LabVIEW FPGA and RT are used for the real time application. LabVlEW has wide hardware alternatives and some advantages duri ng real time programming and user interface design. Additionally to the application, National Instruments embedded controller for real time applications is introduced and some alternative modules for the system is given. PWM generation encoder decoding and Nl 9505 properties is shown with LabVIEW FPGA. A result is shared which shows the control effectiveness of the system under load. ,


[I) (2)



Y. Xiong, B. Qin, M. Wu, J. Yang, M. Fan, "LabVIEW and MATLAB- Based Virtual Control System for Virtual Prototyping of Cyclotron", Proceedings ofPA COl, Albuquerque, USA, 2007. F. Coito, P. Almeida, L. B. Palma, "A LabVIEW/MATLAB Based Tool for Remote Monitoring and Control", Emerging Technologies and Factory Automation 1 Uh IEEE Conference, vol.2, Catania, 2005. B. Gross, M. Kozek, H. Jorgl, "Identification and Inversion of Magnetic Hysteresis Using LabVIEW and MATLAB", REV2004, Villach; 10-2004. B. MacCleery, Z. M. Kassas, "New Mechatronics Development Techniques for FPGA Based Control and Simulation of Electromechanical Systems , Proceedings of J 7'h World Congress IFAC, July, 2008. G, Buja, R.Menis M. I. Valla, "Disturbance torque estimation in a sensorless dc drive", IEEE Transactions on Industrial Electronics, vol. 42, no. 4, August 1995. J. Roubal, P. Augusta, V. Havlena, "A brief introduction to control design demonstrated on laboratory model servo DR300-AMIRA", Acta Electrotechnica et Informatica, vol. 5, no.4, 2005. A. Gambier, "Real Time Control Systems: A tutorial , the Sh Asian Control Conference, July 2004. S. Cohen, S. Babel, J. D. Gilpatrick, J. D. Sedillo, D. A. Bonal, M. M. Ravindran, "Closed loop wire scanner actuator control for lansce accelerator beam profile measurements", Beam Instrumentation Workshop. May 4-8, California 2008. National Instrument, "Creating Custom Motion Control and Drive Electronics with an FPGA-Based COTS System", Available: www.ni.com. "


(6) (7) [8]




Sponsor Documents


No recommend documents

Or use your account on DocShare.tips


Forgot your password?

Or register your new account on DocShare.tips


Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in