ECE451 Controll EngineeringInverted pendulum09/29/2013Introduction:Inverted pendulum is a typical fast, multi-varaibles, nonlinear, unstable system, ithas significant meaning. We choose the PID controller to fot the inverted pendulum. Assume the input is a step signal , the gravitational acceleration g=9.8m/s^2 and linearize the nonlinear model around the operating point.1.Mathematic ModlingM mass of the car 0.5 kgm mass of the pendulum 0.2 kgb coefficient of friction for cart 0.1 N/m/secl length to pendulum center of mass 0.3 mI mass moment of inertia of the pendulum 0.006 kg.m^2F force applied to the cartx coordinate of cart positionθpendulum angle from vertical (down)N and F are the force from horizontal and vertical direction.)Force analysisConsider the horizontal direction cart force, we get the equation:Consider the horizontal direction pendulum force, we get the equation:To get rid of P and N, we get this equation:Merge these two equations, about to P And N, to obtain a second motion equation:u to represent the controlled object with the input force F, linearized two motion equationsApply Laplace transform to the equation aboveThe transfer function of angle and positionLet v =put the equation above into the second equationWe get the transfer functionState space equation:Solve the algebraic equation, obtain solution as follows:Finally we get the system state space equations.2. PID Controller DesignWe now design a PID controller for the inverted pendulum system.KD(s) is the transfer function of the controller.G(s) is the transfer function of the controlled car.Considering that the input r(s) =0, the block diagram can be transformed as: The output of the system is()()()()()()()()()()()()()()()()sFnumnumPIDdendenPIDdenPIDnumsFdendenPIDnumnumPIDdennumsFsGskDsGsy+=+=+=11num —the numerator of the objectden —the denominator of the objectnumPID – the numerator of the PID controller transfer functiondenPID – the denominator of the PID controller transfer functionThe object transfer function is()()()()dennumsqbmglsqmglMmsqmlIbssqmlsUs=-+-++=Φ23242,in which[()()()]22mlmlIMmq-++=.PID Controller Transfer Function is()22sKsKsKsKKsKsKD IpDIPD++=++=Now, we add the car’s position as another output, we getin which G1 is the transfer function of the pendulum, G2 is the transfer function of the car.The output of the car’s position is()()()()()()()()()()sFdendenPIDnumnumPIDdennumsFsGsKDsGsX11221211+=+=in which, num1,den1,num2,den2 are separately mean the controlled object 1 and object 2 and PID controller‘s numerators and denominators.From ()()()s s g ml ml I s X Φ⎥⎦⎤⎢⎣⎡-+=22, we could get thatIn which,[()()()]22ml ml I M m q -++=.We can easily simplified the equation as()()()()()()()()s F num numPID k den denPID denPID num s X 12+=3. Matlab SimulationIn design, the cart's position will be ignored. Under these conditions, the design criteria are:1) settling time is less than 5 seconds2) pendulum should not move more than 0.05 radians away from the vertical When kd=1,k=1,ki=1:numc1=4.5455 0 0 0, denc1=1 4.7273 -26.6364 0.0909 0 0, num2= -1.8182 0 44.5455 0, denc2=1 4.7273 -26.6364 0.0909 0()()()()()()s qbmgl s q mgl M m s q ml I b s s qbmgls q ml I s U s X s G -+-++-+==2324222Then we tried many times to adjust the parameter to satisfy the requirements: Ts <=5 s and overshoot M<0.05.We find the optimal parameters of kd,k,ki which is the second situation.2. When kd=20,k=300,ki=1:Numc1= 4.5455 0 0 0, denc1=0.001 0.09111.3325 0.0001 0 0, numc2= -1.8182 0 44.5455 0, denc2=0.001 0.09111.3325 0.0001 0 0The results:Matlab codesM=0.5;m=0.2;b=0.1;I=0.006;g=9.8;l=0.3;q=(M+m)*(I+m*l^2)/q-(m*l)^2;num1=[m*l/q 0 0];den1=[1 b*(I+m*l^2)/q-(M+m)*m*g*l/q-b*m*g*l/q 0];num2=[-(I+m*l^2)/q 0 m*g*l/q];den2=den1;kd=1;k=1;ki=1;numPID=[kd k ki];denPID=[1 0];numci=conv (num1 denPID);denc1=polyadd(conv(denPID,den1),conv(numPID,num1)); t=0:0.1:20;figure(1)impulse(numc1,denc1,t)title(‘Angle’)figure(2)impulse(numc2,denc2,t)title(‘Position’)M=0.5;m=0.2;b=0.1;I=0.006;g=9.8;l=0.3;q=(M+m)*(I+m*l^2)/q-(m*l)^2;num1=[m*l/q 0 0];den1=[1 b*(I+m*l^2)/q-(M+m)*m*g*l/q-b*m*g*l/q 0]; num2=[-(I+m*l^2)/q 0 m*g*l/q];den2=den1;kd=20;k=300;ki=1;numPID=[kd k ki];denPID=[1 0];numci=conv (num1 denPID);denc1=polyadd(conv(denPID,den1),conv(numPID,num1)); t=0:0.1:20;figure(1)impulse(numc1,denc1,t)title(‘Angle’)figure(2)impulse(numc2,denc2,t)title(‘Position’)Simulation:We will build a closed-loop model with reference input of pendulum position and a disturbance force applied to the cart.We now begin to simulate the closed-loop system. The physical parameters are set as follows.M=0.5, m=0.2, b=0.1, I=0.006, g=9.8, l=0.3After 20s simulation, we see the response as followThe response is very much like what have been done in Matlab codes.。