Design Modeling and Fabrication of Twin Rotor Control System

  • Upload
    anampx

  • View
    16

  • Download
    2

Embed Size (px)

DESCRIPTION

Design Modeling and Fabrication of Twin Rotor Control System

Citation preview

Design, Modeling, and Fabrication of Twin Rotor Control System

v

ABSTRACT

This thesis presents the Design, Modeling, and Fabrication of Twin Rotor Control System. The twin rotor system has high non-linearity and signi_-cant cross coupling between its two axes. This project aims designing and developing a control scheme for the twin rotor control system.

The mechanical model of twin rotor system consists of two rotors, a main rotor and a tail rotor, mounted at each end on a lever bar. The primary task is to control the angular position of the twin rotor system. It has two degrees of freedom which are the azimuthal angle and the elevation angle. As a _rst step, mathematical modeling of the twin rotor system is done. As the system is highly non-linear, so nonlinear equations of azimuth and elevation angles are linearized. Then a State Space obesrver based controller is designed for the system. By implementing the controller in Simulink and testing it on the physical model it is found that controller is able to stabilize the system and track a reference signal.

A multifunction embedded control card is used for real time motion con-trol of the two rotors. Here a microcontroller is connected with two Digital to Analog Converter(DAC) and Analog to Digital Converter(ADC) channels through dierent latches. An external 32K memory is used for the addressing schemes of the DAC and ADC's. The codes for checking the functionality of the DAC's,ADC and observer design are written in C language using Keil software.

vi

Chapter 1

INTRODUCTION

The Twin Rotor Control System demonstrates the principle of a non-linear multi-input multi-output (MIMO) system. Systems having more than one control input and more than one output are multi-input-multi-output sys-tems. The twin rotor system is a nonlinear MIMO system with signi_cant cross coupling. Change in one input variable simultaneously aects all out-put variables in case of a MIMO system.

The twin rotor system resembles a helicopter model. Generally helicopter systems have a single main rotor, but the torque turns the rotor against its air drag causing the body of the helicopter to turn in the direction opposite to that of rotor. To balance this eect, some anti-torque is required. The tail rotor design is introduced to balance the torque eect by pushing or pulling against the tail rotor.

The state of the twin rotor control system is described by four process vari-ables: the horizontal and vertical angle of rotation of the two rotors and the two input voltages. The requirement of the project is to control the angu-lar position of the vertical and horizontal axis of twin rotor system. It has strong coupling between the two axis. The model needs to be linearized _rst and then controllers must be designed to control the positions of lever bar. The system consists of two dc motors which are used to drive the two rotors. The embedded motion control board is serially interfaced with a computer so that user sitting in front of computer can provide commands and can see current position of the two rotors.

1

Figure 1.1: Representation of MIMO system

1.1Analysis and Control of MIMO System

A control problem cannot be further reduced if the system has more than one control input and more than one manipulated variable. The interaction between them is that the model cannot be further reduced. The require-ment in case of a MIMO system is that system should allow for independent manipulation of its output variable. Any change of an input variable simul-taneously aects all output variables. It is said that there is a strong cross coupling between dynamic channels of the process. This coupling creates various di_culties to the process. So, a controller design for a MIMO sys-tem must include an attempt to eliminate the cross coupling between its input-output channels. Mathematically the transfer function obtained for the system which relates the output vector and reference signal is a diagonal matrix.

1.2Hardware Description

The system consists of vertical axis on which a lever arm is connected. At the two ends of the lever arm, two rotors are attached which are rotated at 90 degrees from each other allowing to generate horizontal and vertical thrusts. Two potentiometers are attached to snese the position.

1. At the junction between the vertical axis and the lever arm, a poten-tiometer is connected to feedback the position in the vertical plane.

2. Another potentiometer is connected on the vertical axis which is used to feedback the position in the horizontal plane.

2

Figure 1.2: Rotor System

_ The rotor generating vertical thrust is called the main rotor. This enables the model to pitch which produces elevation angle, which is rotation in the vertical plane around the horizontal X axis.

_ The rotor generating the horizontal thrust is called the tail rotor. This enables the model to yaw to produce azimuthal angle, which is rotation in the horizontal plane around the vertical Y axis.

Apart from mechanical unit, twin rotor system also has an electrical unit. It plays an important role in control of twin rotor system. The electrical unit is interconnected with a computer to send and receive control signals which are then send to the two motors to drive the twin rotor system. The mechanical and electrical units provide a complete control system set-up.

1.3Project Objectives

_ Understanding the mathematical model of twin rotor system

_ Programming the equations in MATLAB and Simulink

_ Linearization of the system

_ Stabilizing the system through controller design

3

_ Design of the hardware and control cards

_ Fabrication, assembling and testing of the system

1.4Thesis Layout

The thesis contains following chapters:

Chapter 1 is about introduction of MIMO systems and its importance in control engineering. Hardware description of twin rotor system is also given here. This chapter also contains project objectives and requirements. Chapter 2 is about mathematical modeling of twin rotor system which ex-plains its kinematics and energy expressions. Chapter also includes equations of motion that are derived and implemented in Simulink with the given pa-rameters.

Chapter 3 is about linearization of the system. It describe how to create a S-function _le and its implementation in Simulink. Linearized system is obtained by executing MATLAB commands.

Chapter 4 is about the controller design in state space. This chapter dis-cuss pole placement approach and design of a servo mechanism using pole placement. It also includes design of a full order state observer.

Chapter 5 is about the design of electrical unit of twin rotor system. It describes the hardware and software con_gurations of the real time motion control embedded card.

Chapter 6 is about conclusion of the thesis. It discusses future recommen-dations, targets and scope of the project.

4

Chapter 2

MATHEMATICAL MODELING

In this chapter, basic understanding of the mathematical modeling of twin rotor control system is developed. The dynamics of the system is derived by using the Euler Lagrangian approach. The system has two degrees of freedom which are.

1. Rotation _ in horizontal plane, about the vertical axis.

2. Rotation _ in the vertical plane, about the horizontal axis.

Lagrangian approach is mathematically equal to Newton's approach of apply forces to things and see how they move. Instead of force here we deal with kinetic and potential energies of the system. The core of Lagrangian approach is a quantity called Lagrangian (L).

2.1Kinematics

Assuming that the mass distribution on the lever arm of twin rotor is re-stricted to a line between the two rotors, which is at distance h from the pivot point. The origin on this line is denoted by 0'. Let [rx(R),ry(R),rz(R)] denotes an arbitrary point P on the lever arm which is at distance R from O'. Then

rx(R) = Rcos_cos_ hsin_cos_(2.1)

ry(R) = Rcos_sin_ hsin_sin_(2.2)

5

Figure 2.1: Representation of system in Cartesian coordinate

rz(R) = Rsin_ + hcos_(2.3)

By dierentiating equation 2.1, 2.2 and 2.3 with repeat to time corresponding velocities are obtained.[1]

2.2Energy Expressions

The Lagrangian approach deals with kinetic and potential energies of the system. We know that kinetic energy T of a body depends on velocity v of the object and the potential energy V depends on the position z of the object as shown in equation 2.4 and 2.5.

1

K:E = T = 2mv2(2.4)

P:E = V = mgz(2.5)

The parameters position ,mass and velocity are a function of the distance R. So the derived equations are

1

Z

T = 2v2(R)dm)R)(2.6)

6

= _

= _

Z

V = gz(R)(R)dm(R)(2.7)

Here g is the acceleration due to gravity.

2.3Equations of Motion

The Lagrangian states that:

L = T V(2.8)

Lagrange's contains partial derivatives of the Lagrangian with respect to the

position and velocity of the object. So the equations of motion are:

d _@L_@L

_

dt@_@__

d _@L_@L

_

dt@_@__

(2.9)

(2.10)

Consider l is the total length of the lever arm,m is the mass of the lever arm,lc is the center of gravity of the lever arm, JA is the inertia of the center axle and JL is the inertia of the lever arm. The two equations of motion are solved for _ and _.

d

_

@_

@L

dt _@L_ @_ = JL + mh2__ [ (cos_sin_)JL

_

+ mlchcos2 _ mlchsin2 _ + h2 sin_cos_]_2 + mglc cos_ + mghsin_ = __

d

_

@_

@L

___

_ _

dt _@L_ @_ = [ 2JL sin_cos__ + 2mlchcos2 __ 2mlchsin2 __ + 2mh2 sin_cos___] + [JL cos2 _ + 2mlchsin_cos_ + mh2 sin2 _ + JA]_ = __

These equations can be expressed in the matrix form as:

_ _

__

___ __

_

D(_;_) _ + C(_;_;_;_) _ + g(_;_) = _(2.11)

7

Here the term with coe_cient D is representing inertia matrix, the term with C represents centripetal force matrix and g represents gravity matrix. Where

dd

_

_

D = _d11d12_ 21 22

C =

c11c12

0

_c21c22_

g = mglc cos_ + mgsin_

2.4Equations of Rotors

The motor dynamics for the two rotors can be expressed as:

d1

1

R1 : dt!1 = T1 !1 + k1T1 u1(2.12)

d

11

R2 : dt!2 = T2 !2 + k2T2 u2(2.13)

Here T1, T2 are the time constants of the motors, k1 and k2 are the motor constants of the motors and !1, !2 are the angular velocities of the main rotor and the tail rotor respectively.

2.5Simulation Model

The simulation model of the twin rotor system can be described by consid-ering the equations of rotors and equations of motion.

_

d1

_ _

_ _

_

dt _ = D[d22__ ( 2JL sin_cos_ + 2mhlc(cos2 _sin2 _) + 2mh2 sin_cos_)__]

d12__ [JL sin_cos_ mhlc(cos2 _sin2 _)]_2 (mglc cos_ + mghsin_)

d1

__ _

_ _

_

dt _ = D[d21__ ( 2JL sin_cos_ + 2mhlc(cos2 _sin2 _) + 2mh2 sin_cos_)__]

d11__ [JL sin_cos_ mhlc(cos2 _sin2 _)]_2 (mglc cos_ + mghsin_)

The total mass m is

m = m1 + m2 + ml + mw(2.14)

8

Here m1 is the mass of main rotor, m2 is the mass of tail rotor and mw is the mass of motors and _ns. ml is the mass of lever arm bar. The sum of the moment of inertia for the point masses of the rotors and weight and solid lever bar is the moment of inertia of the lever arm.

222

l

m+

33

12

JL = m1l1 + m2l2 + mwlw + 3ll1+ ll2(2.15)

The center of mass for the system is:

2

m

lc = m1l1 m2l2 mwlw + ml(l1 l2)(2.16)

The verticle axle has a negligible moment of inertia. JA = 0

2.6Parameters

l1=.174; %Arm length to main rotor

l2=.1751; %Arm length to tail rotor

ml=.007432; %Mass of main rotor(fins+motor+(base+fasteners)

mw=.1026; %Mass of weight

lw=.0518; %Distance from pivot to weight

m1=.4147; %Mass of lever arm bar

M1=.3767; %Mass of tail rotor(fins+motor+(base+fasteners)

g=9.8; %acc. due to gravity

T1=5; %Time constant for main rotor

T2=2.5; %Time constant for tail rotor

k1=0.055; %Motor constant for main rotor

k2=0.044; %Motor constant for tail rotor

k_phi=0.002; %Coefficient of friction of vertical axle bearing

k_theeta=0.002; %Coefficient of friction of horizontal axle bearing

Mv=4.6292*10^-5; %Aerodynamic lift coefficient for Main Rotor

Mh=2.7999*10^-5; %Aerodynamic drag coefficient for Main Rotor

Tv=1.2572*10^-5; %Aerodynamic drag coefficient for Tail Rotor

9

Th=7.0793*10^-5; %Aerodynamic lift coefficient for Tail Rotor

m=ml+m1+m2+mw; %total mass

JA=0; %moment of inertia for vertical axle

JL=(m1*(l1*l1))+(m2*(l2*l2))+(mw*(lw*lw))+((ml/3)*(((l1*l1*l1)+

(l2*l2*l2))/(l1+l2))); %moment of inertia for horizontal axle

lc=((ml*(l1-l2)/2)+(m1*l1)-(m2*l2)-(mw*lw))/m; % center of gravity

d22=JL+(m*h2*h2);

10

Chapter 3

LINEARIZATION OF THE SYSTEM

3.1Nonlinear Systems

For a nonlinear system the principle of superposition is not applicable. In case of a nonlinear two input system the response cannot be treated by considering single input at a time and adding the results. In general there are very few systems in control that are actually linear.

3.1.1Linearization of Nonlinear Systems

In control engineering the response of the system can be treated around an equilibrium point. A nonlinear system may be treated as a linear system if its operation is considered within some limits or around equilibrium points. The twin rotor system has two degrees of freedom: the elevation and az-imuthal angles. The cross coupling between these two angles is the reason for the non-linearity in twin rotor system. The mathematical model developed for the twin rotor control system is also a non-linear model. Linearization of this non-linear system is required in order to implement control function. In this project Sfunction approach is used to obtain a linear model.

11

3.2S-Function

S-functions (system-functions) provide a powerful mechanism for extending the capabilities of the Simulink environment. An S-function is a computer language description of a Simulink block written in MATLAB, C, C++, or Fortran. C, C++, and Fortran S-functions are compiled as MEX _les using the mex utility. As with other MEX _les, S-functions are dynamically linked subroutines that the MATLAB interpreter can automatically load and execute.

S-functions use a special calling syntax that enables you to interact with the Simulink engine. S-functions follow a general form and can accommodate continuous and discrete systems. By following a set of simple rules, you can implement an algorithm in an S-function and use the S-Function block to add it to a Simulink model. After you write your S-function and place its name in an S-Function block (available in the User-De_ned Functions block library), you can customize the user interface using S-Function block to add it to a Simulink model.

3.2.1Write an S-function _le

As the nonlinear model becomes more complex, the dierential equations associated with it can be written in an M-_le. These M-_les will be called by SimulinkthroughtheS-functionblock.

Input Arguments

_ t - the time variable

_ x - the state variable vector

_ u - the input vector (It will be called in Simulink block)

_

ag - an integer value that indicates which task is to be performed at a particular time. There are six types of

ag requests that Simulink performs, with

ag values 0,1,2,3,4 and 9.

Output Arguments

_ sys - This is the vector that shows the results of the request sent by Simulink.

12

Flag value

0

1

2

3

4

9

Table 3.1: S-Function

ags Description

De_nes S-Function block characteristics, sample time, initial

conditions and sizes.

Calculates the derivatives of the continuous state variables.

Updates discrete states, sample times, and major time step

Requirements.

Calculates the outputs of the S-function.

Calculates the time of the next hit in absolute time for discrete

domain.

Performs any necessary end of simulation tasks.

All other output arguments will be evaluated by Simulink only when

ag = 0, otherwise they are ignored:

_ x0 - initial condition vector.

_ str - This is set to a null matrix.

_ ts - This represents the sampling time interval. In case of continuous time systems it is set to zero.

The description of the S-function M-_le developed for this project is given in Appendix A.

3.2.2Using S-function blocks in Simulink

In the Simulink Library browser, go to the User-De_ne Functions subdirec-tory. Then drag-drop the level2 MATLAB S-Function block. Double click the S-function block and change the name as 'sfunction'. Also _ll in the parameters. Here 'sfunction' is the name of the M-_le created.

An advantage of using S-functions is that you can build a general-purpose block that you can be used in dierent problems. An M-_le of an S-Function block must provide information about the model characteristics. Simulink needs this information during simulation. As the simulation precedes, Simulink, the ODE solver, and the M-_le interact to perform speci_c tasks. These tasks

13

Figure 3.1: S-function block in Simulink

include de_ning initial conditions and block characteristics, and computing derivatives, discrete states, and the system outputs.

3.3Linearization Using MATLAB

After the development of S-function block in Simulink,the system is linearized using linmod command in MATLAB. linmod obtains linear models from sys-tems of ordinary di. equations (ODEs). [A,B,C,D]=linmod(`sfunblock',x0,u0) obtains the state-space linear model of the system of ordinary dierential equations described in the block diagram \sfunblock". Here \sfunblock" is the name of our S-function _le.

The state vector x, and input u can be speci_ed by using trim command in MATLAB. A linear model will then be obtained at this operating point. The M-_le created for these commands is shown in Appendix B. These _les are executed to obtain state-space linear system.

The operating points and the state-space matrices are shown here:

x0 =

67

67

67

2 1:0000 3 6 0:00007 6 0:5559 7 6 0:000 7 450:00005

33:6410

u0 =

_0:5000_ 0:4676

14

6

6

6

0

7

7

7

6

6

6

0

7

7

7

1

6

6

6

0

7

7

7

20 60

6

A = 60 40

0

1:000000

0:11520:00000

001:0000 0 17:1170 0:0774 00 0

000

0 0 3 0:0274 0:04087 0 0 7

0:03570:0057 7

0:909105

0 3:0303

20 60

6

B = 60 490:9091

03 07 07 07 05

0218:0074

_

C = 0

0 0 0 0 0_ 0 1 0 0 0

20 60

6

D = 60 40

0

03 07 07 07 05

0

15

Figure 3.2: Plot of Linearized System

The plots for the six state variables speci_ed in the S-function M-_le are obtained after linearization of the system.

16

Chapter 4

CONTROL SYSTEM DESIGN IN STATE SPACE

4.1Introduction

This chapter discusses State-space design method for designing and analyzing feedback control system for the twin rotor system as the plots obtained during linearization of the system shows that system is highly unstable. State-space controller design is the modern approach and preferred over frequency domain methods of design because frequency domain analysis do not allow us to specify all closed loop poles in systems of order higher than 2 as they do not allow us to get information about su_cient number of unknown parameters to place all the closed loop poles of the system uniquely. State-space method solve this problem of pole placement as:

1. It introduces other adjustable parameters.

2. It de_nes various techniques for _nding unknown parameter values to place the closed loop poles of the system.

Firstly, pole placement approach for regulator system is applied and state feedback gain matrix is obtained using MATLAB commands. Then design of a servo system using the pole placement approach is discussed. A full order observer is implemented and transfer functions of observer controllers for azimuthal and elevation angles are derived. Finally, quadratic optimal control method is discussed.

17

Figure 4.1: State space representation of a Plant

4.2Pole Placement

We assume that all state variables are measurable and are available for feed-back. If the system response is completely state controllable, then poles of the closed-loop system can be placed at any desired locations through state feed-back by introducing an appropriate state feedback gain matrix. We decided that the desired closed-loop poles are to be at J= [-1+1i*sqrt(3) -1-1i*sqrt(3) -1 -2 -3 -4], where J is the matrix consisting of the locations of the desired closed loop poles. By choosing an appropriate state feedback gain matrix for the system, it is possible to force the system to have closed-loop poles at the desired locations, provided that the original system is completely state controllable.

Consider the plant is represented in state space as:

x_ = Ax + Bu(4.1)

y = Cx(4.2)

Where A = 6x6 constant matrix B = 6x2 constant matrix C = 2x6 constant matrix x = state vector (6x1) Y = output signal (2x1) u = control signal (2x1) The block diagram representation of these equations is If all the state variables are feedback to the control, through a gain K, then there will be n gains, Kn that could be adjusted to yield the required closed-loop pole values. The feedback through the gain K is shown in Figure 4.2 by the feedback vector -K. The state equations for the closed-loop system now will be

x_ = Ax + Bu = Ax + B( Kx) = (A BK)x(4.3)

y = Cx(4.4)

This implies that the control signal u can be determined by an instantaneous

18

Figure 4.2: Plant with state variable feedback

state. Such a scheme is called state feedback. This closed-loop system has no input. Its objective is to maintain the zero output. As the disturbances are present in any system, the output will deviate from zero. The nonzero output will return to the zero reference signal because of the state feedback controller of the system. The controllers can be divided into 2 categories. One is the regulatory systems in which the reference signal is a constant quantity (including zero). The other control scheme is the one in which reference is a time varying quantity. In our project we implemented the regulator system.

4.2.1Solving Pole Placement Problem With MATLAB

Pole-placement problems can be solved easily with MATLAB. MATLAB has two commands acker and place for the computation of feedback gain matrix K. K = place(A,B,J) computes a state-feedback matrix K such that the eigenvalues of A-BK are those speci_ed in the vector J. Eigen values must not have a multiplicity factor greater the input vector. For single input system, the commands acker and place gives the same K. In case of multi-input multi-output systems, the command place should be used instead of acker.

To use the command acker or place, we should have known the matrices A, B and J

A matrix. B matrix, J matrix

where J= [-1+1i*sqrt(3) -1-1i*sqrt(3) -1 -2 -3 -4]

For our system as the matrix A is 6x6, so we choose length of the matrix J to be 1x6. Feedback gain matrix K is calculated using place command.

19

K =

Figure 4.3: Response of Elevation and Azimuthal angle to step input

_ 0:2801

0:1730

0:4405 57:1146

0:24722:9529

13:3382 0:7088

0:0818 0:0016_

0:00540:0014

4.2.2Choosing the Locations of Desired Closed-Loop

Poles

There is a necessary condition for placing the closed loop poles at desired locations that the system must be state controllable. The stability of this system can be determined by evaluating the eigenvalues of matrix A-BK.The approached used here is to choose poles using frequency domain analysis, by placing a dominant pair of closed-loop poles and then choose the other poles such that they are far to the left of the dominant closed-loop poles. If the dominant closed-loop poles are placed far from the j! axis, the system response will become very fast, and the signals in the system will become very large, which results that the system may become nonlinear.This approach must be avoided. eig (A-BK) =

20

-1.0000 + 1.7321i -1.0000 - 1.7321i -4.0000 -1.0000 -3.0000 -2.0000

The eigen values of matrix A-BK shows that the closed loop poles are stable.

4.3State Observers

Controller design is based upon measurable state variables for feedback through adjustable gain matrices. However in practical, some of the state variables are not available to feedback, send them to the controller or it is too costly to measure them . If the state variables are not measurable directly because of system limitations or cost, it is possible to estimate the states. Estimated states are then fed to the controller. An observer, sometimes called an es-timator, is used to calculate state variables that are not measurable from the plant directly. In this project the derivatives of elevation and azimuthal angles are not available to measure so an observer is designed to estimate their values. Here the observer is a model of the plant.

The plant with an observed state will have

^

x_ = Ax^ + Bu + Ke(y Cy^)(4.5)

y^ = Cx^(4.6)

Where hat of x is the estimated state and C hat of x is the estimated output. The inputs to the observer are the output y and the control input u. Matrix Ke which is called the observer gain matrix, is a weighting matrix to the correction term involving the dierence between the measured output y and the estimated output. The design of the observer is separate from the design of the controller. Similar to the design of the controller vector, K, the design of the observer consists of evaluating the constant vector, Ke, so that the transient response of the observer is faster than the response of the controlled loop in order to yield a rapidly updated estimate of the state vector.

21

Ke =

6

6

6

7

7

7

Figure 4.4: Block diagram of observered state feedback control

4.3.1Observer Gain Matrix Ke, with MATLAB

Because of the duality of pole-placement and observer design, the same algo-rithm can be applied to both the pole-placement problem and the observer-design problem. Thus, the commands acker and place can be used to de-termine the observer gain matrix Ke. Ke = place(A,B,L) computes a state-feedback matrix Ke such that the eigenvalues of A-BKe are those speci_ed in the vector L. As a general rule, the closed loop poles in L must be 2 to _ve times of the closed loop poles chosen for matrix J.

20:0200 60:1019 60:0037 60:0288 43:9436

0:6155

0:0048 3 0:0564 7 0:0217 7 0:1360 7

1:85535

1:5139

4.4Design of regulator systems with observers

Following procedure is followed for designing regulator system based con-troller:

22

Figure 4.5: Response of Angle Phi and Theta to Initial conditions

1. Derive a state-space model of the plant.

2. Choose the desired closed-loop poles for pole placement. Choose the desired observer poles.

3. Determine the state feedback gain matrix K and the observer gain matrix Ke .

4. Using the gain matrices K and Ke obtained in step 3, derive the transfer function of the observer controller. If it is a stable controller, check the response to the given initial condition. If the response is not acceptable, adjust the closed-loop pole location and/or observer pole location until an acceptable response is obtained.

We shall now consider the optimal regulator problem that, given the system equation. In MATLAB the command lqr(A,B,C,D) solves the continuous time linear, quadratic regulator problem and the associate Ricatti equation. This command calculates the feedback gain matrix K. After calculating the feedback gain matrix K, response of the system to the initial condition was accomplished.

23

Chapter 5

DESIGN OF ELECTRICAL UNIT

5.1Introduction

The electrical unit of twin rotor system plays an important role in position control of the two rotors of twin rotor system. The electrical unit is intercon-nected with a computer. Its purpose is to send and receive control signals which are then send to the two motors to drive the twin rotor system. Pulse Width Modulation technique is generally used to control speed and direction of dc motors. One method is to generate analog or variable voltage from a microcontroller, by using a digital to analog converter (DAC). It produces an output voltage proportional to the numerical input. Digital to Analog convertors are fast and accurate and simple to program. A numeric value is written to the address of the DAC and a voltage proportional to the this value appears at the DAC output pin.

5.2Embedded Control Card

Embedded technology plays a major role in integrating various tasks of a system. This needs to tie up various functions in a closed loop system. In this project a multifunction micro controller based embedded card is used for real time motion control application. The board gives combined features of position control,stable operation and increases the processing speed (upto

24

Figure 5.1: Outlook of Embedded Control Card

24MHz clock) and gives the

exibility to reprogram the microcontroller ac-cording to the motion control need. Further, this board gives the facility to implement the advanced control techniques for motion control applications.

The board consists of a microcontroller connected to four Digital to Ana-log channels,two of which are used in our project for the position control of tail rotor and the main rotor. A 12 channel Analog to Digital converter is also interfaced to facilitate the microcontroller to communicate between analog and digital world. The microcontroller is not only responsible for communicating between PC,itself but also sends the necessary commands to each DAC and ADC for con_guration and proper operation. The board can be utilized in any application requiring multidimensional control with high speed,and good precision. The motion control is designed in this project to implement position control mode. The codes for checking the functionality of the two DAC channels and ADC are written in C using Keil software. The motivation to use this multifunction board is:

_ To combine the best features of all the available motion control tech-niques.

_ To make the system response fast as the board operates at 24.576MHz crystal frequency.

5.3Hardware Section

_ The card consists of following major components:

25

_ The card consists of following major components:

_ AT89C52 series microcontroller

_ 0800 Digital to Analog Converter (8 bits)

_ AD574 Analog to Digital Converter (12 bits)

_ 32K External Random Access Memory

_ MAX232 (for serial communication)

_ 74LS373 (for multiplexing and address latching)

_ Voltage regulator IC

_ LM741 Operational Ampli_er

There are four loops in the system out of which we used two in our project. Each loop interconnects PC, microcontroller, and DAC in feedforward path and ADC, microcontroller and PC in feedback path, along with some ad-ditional circuitries. The microcontroller is connected with the PC through serial port using a RS-232 standard conversion IC MAX-232 with full in-terrupt based con_guration to make the board reliable for real time control scheme.

The serial communication is chosen for the following advantages over the parallel communication: [?]

1. Serial cables can be longer than parallel cables. This is because of the standard voltage levels representing the logic levels (-3 to -25 for logic 1 and +3 to +25 for logic level 0), which are much higher than standards for the parallel communication (+5V for logic 1 and 0V for logic 0).

2. The control card uses AT89C55WD microcontroller which has built in serial interface and can provide and receive serial data with only two pins for transmission and reception as compared to parallel connections that require eight pins for data transmission.

5.4Digital to Analog Conversion

The motor drives has a feed forward path and a feedback path. Feed forward path consists of DAC0800, operational ampli_ed LM741 and current ampli_er LM12 to convert the digital command input of the motor into corresponding

26

Figure 5.2: Connections of DAC1 with microcontroller

analog voltages to be applied on the input of the motor to be controlled. Feedback path consists of a 12 channel Analog to digital Converter which provides current position of the two rotors through a potentiometer.

Digital to Analog Convertor is used to convert a binary word to a proportion current or voltage. The 8-bit DAC0800 has been used for this purpose in the embedded card. A negative power supply of -12V is attached for proper operation of DAC0800. This -12V supply is attached with VEE. VREF-pin of DAC0800 is attached with ground through a resistor as speci_ed in DAC0800 datasheet. VREF pin is attached with +10V supply through a resistor. This means that output of digital to analog convertor can increase from 0V to 10V only. The reference voltage can be changed if required. The C language code for the DAC operation is given in Appendix A.3.

5.5Current Ampli_cation

As the output of LM741 Operational Ampli_er reaches a value of 9.5V then due to the oset it will saturate at this value. This implies even if you in-crease the input voltage at the DAC, output of op-amp will not increase anymore. So, the circuit can be safely used to vary output voltage from 0v to 9.5V for reference voltage = +10V.

The current driving capability of LM741 op-amp is 500mA. The motors at-tached to the two rotors draws nearly 1.5A current so an additional power

27

Figure 5.3: Connections of LM12 power op-amp

ampli_er is connected to amplify the output current of the LM741.

5.6Control Algorithms

28

Figure 5.4: Flow Chart of Control Algorithm

29

Figure 5.5: Flow Chart of Timer Interrupt Algorithm

30

Chapter 6

CONCLUSION

Twin rotor control system is highly nonlinear system and quite often used in control system lab to demonstrate the yaw and pitch motion of a helicopter. The work scope in this project covers modeling, linearization of the system, design of state space controller, fabrication of the hardware and design of control cards.

6.1Testing of the System

_ It involves testing the embedded control card to check if all the modules are functional using the codes developed.

_ The card was tested for serial communication, Digital to Analog Con-version (DAC), and Analog to Digital Conversion (ADC).

_ A simple test code for toggling was used to check the ports of the microcontroller.

_ Initially, the modules were simulated on PROTEUS using the codes which ensured the viability of the code and the design.

_ LM12 operational ampli_er is tested by making its connections with the two motors.

31

6.2Controller Designing in C-language

Full order state observer was designed for the system in C language.

The algorithm was implemented on the real system. It was able to track the pitch or yaw reference input speci_ed in the code but the system response was not satisfactory for a changed reference input sent by PC through serial port.

32

Appendix A

A.1Appendix 1

\% S function M-file

function [sys,x0,str,ts] = sfunction(t,x,u,flag)

NoOfStates=6;

switch flag,

%%%%%%%%%%%%%%%%%%

% Initialization %

%%%%%%%%%%%%%%%%%%

case 0,

[sys,x0,str,ts]=mdlInitializeSizes(NoOfStates);

%%%%%%%%%%%%%%%

% Derivatives %

%%%%%%%%%%%%%%%

case 1,

sys=mdlDerivatives(t,x,u);

%%%%%%%%%%

% Update %

%%%%%%%%%%

case 2,

sys=mdlUpdate(t,x,u);

%%%%%%%%%%%

% Outputs %

%%%%%%%%%%%

case 3,

sys=mdlOutputs(t,x,u);

%%%%%%%%%%%%%%%%%%%%%%%

% GetTimeOfNextVarHit %

%%%%%%%%%%%%%%%%%%%%%%%

case 4,

sys=mdlGetTimeOfNextVarHit(t,x,u);

33

%%%%%%%%%%%%%

% Terminate %

%%%%%%%%%%%%%

case 9,

sys=mdlTerminate(t,x,u);

%%%%%%%%%%%%%%%%%%%%

% Unexpected flags %

%%%%%%%%%%%%%%%%%%%%

otherwise

error(['Unhandled flag = ',num2str(flag)]);

end

% end sfun_sub

function [sys,x0,str,ts]=mdlInitializeSizes(NoOfStates)

sizes = simsizes;

sizes.NumContStates = 6;

sizes.NumDiscStates = 0;

sizes.NumOutputs = 6;

sizes.NumInputs = 2;

sizes.DirFeedthrough = 0;

sizes.NumSampleTimes = 1; % at least one sample time is needed

sys = simsizes(sizes);

% initialize the initial conditions

%

u10=1;u20=1;

g=9.8;

m1=0.3792;

m2=0.1739; %mass of Tail rotor

%((fins+motor+(base+fasteners))

mw=0.158;

ml=0.280;%Mass of lever arm

% All masses are in grams

%L=171.75+179.7;

lw=0.090; %distance from pivot to weight

l1=0.1995;%distance from pivot to axle of

%main rotor

l2=0.1743; %distance from pivot to axle of Tail

%motor

%h1=72.67/1000; %horizontal distance from vertical axle to lever bar

h=0.0298; %vertical distance from horizontal axle to lever bar

m=m1+m2+mw+ml; %total mass of lever bar assembly

%lw=(ml*(l1-l2)/2+m1*l1-m2*l2)/mw;

lc=(ml*(l1-l2)+(m1*l1)-(m2*l2)-(mw*lw))/m; %center of mass of lever bar

JL=(ml/3)*((l1^3+l2^3)/(l1+l2))+m1*l1^2+m2*l2^2+mw*lw^2;

JA=0;

34

T0=atan(lc/h); %Equilibrium point of the lever bar

Td0=0;

F0=1;

Fd0=0;

u=[1 1];

T1=1.1;T2=0.33;

k1=0.01;k2=0.0139;

w10=u10/k1;

w20=u20/k2;

x0=[F0 Fd0 T0 Td0 w10 w20]';

str = []; %str is always an empty matrix

ts = [0 0]; %initialize the array of sample times

% end mdlInitializeSizes

%Description: Calculation of the model's CT state derivatives.

function sys=mdlDerivatives(t,x,u)

g=9.8;

m1=0.3792;

m2=0.1739; %mass of Tail rotor

%((fins+motor+(base+fasteners))

mw=0.158;

ml=0.280;%Mass of lever arm

% All masses are in grams

%L=171.75+179.7;

lw=0.090; %distance from pivot to weight

l1=0.1995;%distance from pivot to axle of

%main rotor

l2=0.1743; %distance from pivot to axle of Tail

%motor

%h1=72.67/1000; %horizontal distance from vertical axle to lever bar

h=0.0298; %vertical distance from horizontal axle to lever bar

m=m1+m2+mw+ml; %total mass of lever bar assembly

%lw=(ml*(l1-l2)/2+m1*l1-m2*l2)/mw;

lc=(ml*(l1-l2)+(m1*l1)-(m2*l2)-(mw*lw))/m; %center of mass of lever bar

JL=(ml/3)*((l1^3+l2^3)/(l1+l2))+m1*l1^2+m2*l2^2+mw*lw^2;

JA=0;

T1=1.1;T2=0.33;

k1=0.01;k2=0.0139;

F=x(1); %states

Fd=x(2);

T=x(3);

Td=x(4);

w1=x(5);

w2=x(6);

35

sc=sin(T)*cos(T);

c2s2=(cos(T))^2-(sin(T))^2;

D=[JL*cos(T)^2+m*h^2*sin(T)^2-2*m*h*lc*sc+JA, 0

0, (JL+m*h^2)];

G=[ 0

m*g*(lc*cos(T)-h*sin(T))];

Fd2Td2=[-(JL*sc+m*h*lc*c2s2-m*h^2*sc)*(Td),-(JL*sc+m*h*lc*c2s2-m*h^2*sc)*(Fd)

(JL*sc+m*h*lc*c2s2-m*h^2*sc)*(Fd),0];

MV=4.6292*10^-5;

MH=2.7999*10^-5;

TV=1.2572*10^-5;

TH=7.0793*10^-5;

Tau=[MH*l1*w1^2*cos(T)-TH*l2*w2^2*cos(T)

-MV*l1*w1^2+TV*l2*w2^2 ];

Fric=[-0.002*Fd;-0.002*Td]; %friction of potentiometer

FddTdd=inv(D)*(Tau+Fric-Fd2Td2*[Fd Td]'-G);

Fdd=FddTdd(1,:);

Tdd=FddTdd(2,:);

w1d=-w1/T1+u(1)/(k1*T1);

w2d=-w2/T2+u(2)/(k2*T2);

sys=[Fd

Fdd

Td

Tdd

w1d

w2d];

% end mdlDerivatives

function sys=mdlUpdate(t,x,u)

sys = [];

% end mdlUpdate

function sys=mdlOutputs(t,x,u)

sys = [x(1);x(2);x(3);x(4);x(5);x(6)];

\%end mdlOutputs

\% Description:Calculate the time of the next sample

\% time. For systems with non-uniform sampling

function sys=mdlGetTimeOfNextVarHit(t,x,u)

sys = [];

\% end mdlGetTimeOfNextVarHit

function sys=mdlTerminate(t,x,u)

sys = [];

\% end mdlTerminate

36

A.2Appendix 2

\% To find the linear model of the system

[x0,u0,y0,dx0]=trim('sfuncblock')

[A,B,C,D]=linmod('sfuncblock',x0,u0)

37

A.3Appenidx 3

\% C language program for the two DAC's

#include

#include

unsigned char DACdata1;

unsigned char DACdata2;

unsigned char temp;

char xdata *DAC1=0x0001;

char xdata *DAC2=0x0002;

void serial_ISR(void) interrupt 4

{

if(RI==1)

{

RI=0;

temp=SBUF;

SBUF=temp;

if (temp=='D')

{

DACdata1+=50;

*DAC1=DACdata1;

DACdata2+=50;

*DAC2=DACdata2;

P1=DACdata1;

P2=DACdata2;

}

}

else

{

TI=0;

}

}

void main(void)

{

DACdata1=0;

DACdata2=0;

*DAC1=DACdata1;

*DAC2=DACdata2;

38

P1=0X55;

TMOD = 0x20;

ACC=PCON|0x80;

PCON=ACC;

TH1=-13;

SCON=0x50;

IE=0x90;

TR1=1;

TH0=0x80;

TL0=0;

TR0=1;

SBUF='S';

while(1)

{

}

}

A.4Appendix 4

\%C_LANGUAGE PROGRAM FOR OBSERVER DESIGN

#include

#include

#include

#include

void Initialize(void);

void Find_Load_Ts(void);

char Read(char *);

void Write(char*,char);

void Read_ADC(void);

char DAC_CE(float);

char data Ts_4 _at_ 0x30; // Programeable Sample Time (Ts) in days //

char data Ts_3 _at_ 0x31;

char data Ts_2 _at_ 0x32;

char data Ts_1 _at_ 0x33;

float data Ts _at_ 0x30;

char data ADC_H_Val _at_ 0x46; // ADC value

char data ADC_L_Val _at_ 0x47;

int data ADC_Val _at_0x46;

char xdata *DAC0=0x0001;

char xdata *DAC1=0x0002;

39

char xdata *ADC_C=0x0005;

char xdata *ADC_L=0x0006;

char xdata *ADC_H=0x0007;

char xdata *RAM_32K=0x8000;

char xdata *ptr_r;

unsigned int Samples=0; // No of samples to save and then send

float a_DAC;

float b_DAC;

float a_ADC;

float b_ADC;

char ADC_C_B;

// Programeable filter parameters //

float A[6][6]={{ 1.0,0.055,0.0002,0.0,0.0,0.0},

{0.0,0.9803,0.0063,0.0008,0.0009,-0.0014},

{0.0,0.0,0.9937,0.0548,0.0,0.0},

{0.0,0.0006,-0.2271,0.9723,-0.0017,0.0003},

{0.0,0.0,0.0,0.0,0.989,0.0},{0.0,0.0,0.0,0.0,0.0,0.9780}};

float b[6][2]={{0.0000018,-0.0000066},{0.001,-0.0004},

{-0.0000034, 0.0000015},{-0.0002,0.0001},

{0.2123,0.0},{0.0,0.4990}};

float C[2][6]={{1.0,0.0,0.0,0.0,0.0,0.0},{0.0,0.0,1.0,0.0,0.0,0.0}};

float xdata Xdot_hat[6]={0.0,0.0,0.0,0.0,0.0,0.0} ;

float xdata X_hat[6]={0.0,0.0,0.0,0.0,0.0,0.0};

float xdata K[2][6]= {{0.5309,1.3692,0.0357,0.0020,0.9553,-0.0038},

{-0.8475,-2.1770,-0.0037,-0.0524,-0.0091,0.9630}};

float xdata K_e[6][2]={{1.8,-0.1},{15.8,-0.6},{0.0,1.9},

{0.2,18.6},{-272.6,-1225.7},{-781.1,-415.8}};

float xdata K_eC[6][6];

float xdata A_new[6][6];

float xdata A_nn[6]; /*used for (A-K_e*C)*X_hat */

float xdata bu[6]; /* B*(signal to the plant) matrix */

float xdata K_eY[6]; /*(observer gain matrix * output) matrix*/

float xdata Y[2]={0.0,0.0}; /*Two output of the plant */

float xdata actuate[2]; /* Used for, Reference minus output (Y) */

float xdata SetPoint[2]={0.0,0.0}; /* Set point for phi and theta */

float xdata actuate2[2]={0.0,0.0}; /* Signal to the plant */

float xdata u[2]={0.0,0.0}; /* used for K*X_hat */

float xdata SP0,SP1; /* For conversion of angle to volts */

float xdata g1,g2;

float xdata pi=3.14159;

40

float xdata K_Fi,K_Theta;

char bdata flags=0;

sbit ADC_send_flag = flags^0;

sbit save_flag = flags^1;

sbit Samples_send_flag = flags^2;

sbit Go_flag = flags^3;

sbit ADC_DAC_Cali = flags^6;

char bdata PCON_set;// To double the BR

sbit SMOD_0 = PCON_set^7;

char Temp,Temp1;

unsigned int n=0;

unsigned char i,j,a,c,z;

char xdata *ptr;

unsigned char DAC_Val1,DAC_Val2;

// --------------//

// Main FUNCTION //

// --------------//

void main(void){

Ts = 0.01;

SP = 0x7F; // To start the stack memmory from 80H (in idata)

Initialize();

ADC_C_B = 0x80; // Using ADC Channel # 0

//// For step response lets take the calibration equation as

//////////////

while(1){

if(ADC_DAC_Cali){

for(n=2000;n>0;n--); // 1ms delay so that the DAC value stabilized on ADC i/p (Important)

ADC_DAC_Cali = 0;

Read_ADC();

SBUF = ADC_L_Val; /// For float transfer

ADC_send_flag = 1; /// For float transfer

}

}

}

// -----------------------------------//

41

// Timer 0 Interrupt (To generate Ts) //

// -----------------------------------//

void Timer_0 (void) interrupt 1

{

TR0 = 0; // Reload sample timer

TH0 = 0xAF;

TL0 = 0xFF;

TR0 = 1;

T0 = !T0; // Show Half the Frequency of the sample timer

Read_ADC(); //// Read Data from ADC. /////////////

if(Go_flag){

// Callibration Eqn. of ADC

// Y = 0.0049 * ADC_Val - 9.9096;

Y[0] = a_ADC * ADC_Val + b_ADC;

Y[1] = a_ADC * ADC_Val + b_ADC;

SP0=K_Fi*(SetPoint[0]-pi)+1.9; /* Convert Horizontal Set point from

radians to volts */

K_Fi=(1.9+1.2)/(2.0*pi);

K_Theta=-10.0/pi;

SP1=K_Theta * (SetPoint[1]-pi/2.0)-5.0; /* Convert Vertical Set point from

radians to volts *

actuate[0]=(SP0-Y[0]); /* Reference phi minus output */

actuate[1]=(SP1-Y[1]); /* Reference theta minus output */

g1=actuate[0]*K[0][0]+actuate[1]*K[0][2]; /* gain matrix in the forward

path, used for tracking */

g2=actuate[0]*K[1][0]+actuate[1]*K[1][2];

for(i=0;i