《Inverted pendulum倒立摆的matlab建模》由会员分享,可在线阅读,更多相关《Inverted pendulum倒立摆的matlab建模(14页珍藏版)》请在金锄头文库上搜索。
1、wordECE451 Controll Engineering Inverted pendulum09/29/2013Introduction:Inverted pendulum is a typical fast, multi-varaibles, nonlinear, unstable system, it has significant meaning. We choose the PID controller to fot the inverted pendulum. Assume the input is a step signal , the gravitational accel
2、eration g=9.8m/s2 and linearize the nonlinear model around the operating point.1.Mathematic ModlingMmass of the car0.5 kgmmass of the pendulum0.2 kgbcoefficient of friction for cart0.1 N/m/secllength to pendulum center of mass0.3 mImass moment of inertia of the pendulum 0.006 kg.m2Fforce applied to
3、the cartxcoordinate of cart positionpendulum 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 a
4、nd N, we get this equation:Merge these two equations, about to PAnd 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 th
5、e 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 tran
6、sfer 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 numthe numerator of the objectden the denominator of the objectnumPID the numerator of the PID controller transf
7、er functiondenPID the denominator of the PID controller transfer functionThe object transfer function is ,in which.PID Controller Transfer Function is Now, we add the cars position as another output, we get in which G1 is the transfer function of the pendulum, G2 is the transfer function of the car.
8、The output of the cars position is in which, num1,den1,num2,den2 are separately mean the controlled object 1 and object 2 and PID controllers numerators and denominators.From , we could get thatIn which, .We can easily simplified the equation as3. Matlab SimulationIn design, the carts position will
9、be ignored. Under these conditions, the design criteria are: 1) settling time is less than 5 seconds 2) pendulum should not move more than 0.05 radians away from the verticalWhen 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
10、0.0909 0 Then we tried many times to adjust the parameter to satisfy the requirements: Ts =5 s and overshoot M0.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, de
11、nc2=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*l2)/q-(m*l)2;num1=m*l/q 0 0;den1=1 b*(I+m*l2)/q-(M+m)*m*g*l/q-b*m*g*l/q 0;num2=-(I+m*l2)/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(co
12、nv(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*l2)/q-(m*l)2;num1=m*l/q 0 0;den1=1 b*(I+m*l2)/q-(M+m)*m*g*l/q-b*m*g*l/q 0;num2=-(I+m*l2)/q 0 m*g*l/q;den2=den1;kd=2
13、0;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
14、 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. /