Modification of the equation of motion
The equation of motion is defined in the block named `Pendulum'
.
After single-clicking on Pendulum block,
select Edit -> Look Under Mask to open the following window:
Contents of Pendulum block
In the above figure, the input U is force applied to the cart.
The cart position is outputted to the output port `Cart'.
The pendulum angle is outputted to the output port `Pendulum'
The equation of motions are described in two blocks named `f(u)'.
Double click to open the contents.
The upper block of f(u) has input signals of force, angular
velocity, and angle, and has output signals of acceleration
velocity of cart..
The lower block of f(u) has output signal of acceleration
velocity in angle.
In those blocks, force, angular velocity, and angle are shown
as u(1), u(2), and u(3), respectively.
Exercise:
Now, check if the following equations of motion are
described in two f(u) blocks:
For derivation procedure of the equation of motion,
see this document (sorry now in
Japanese) where
the derivation procedure of equation of motion for 2-link
inverted pendulum is shown. The case of 1-link can be derived
by setting the mass of the second link to be zero.
The equation of motion in demo file above is derived
by neglecting the moment of inertia of pendulum around its
center of gravity.
By letting the moment of inertia to be J, the following
equation of motion is derived.
Exercise:
Check if the equation of motion (3) is
equivalent to (1) and (2) when J = 0.
The moment of inertia becomes as follow:
Exercise:
Modify the equation of motion described in two f(u) blocks
so that the moment of inertia is considered.
Use variable J for moment of inertia.
Answer:
Fcn1 (acceleration of cart)
((m*l*l+J)*(u[1]+m*l*power(u[2],2)*sin(u[3]))-m*m*l*l*g*sin(u[3])*cos(u[3]))/((M+m)*(m*l*l+J)- power(m*l*cos(u[3]),2))
Fcn2 (angular acceleration of pendulum)
((M+m)*m*g*l*sin(u[3])-(u[1]+m*l*power(u[2],2)*sin(u[3]))*m*l*cos(u[3]))/((M+m)*(m*l*l+J)-power(m*l*cos(u[3]),2))
Note:
変数 J を定義は,つぎのように行う:
pendulum ブロックを選択(左クリック)してから
Edit タグ → Edit Mask → Initialization → Add と選択し,
Variable: フィールドに J を入力する.
Exercise
Compare the responses of two cases when J is given as
equation (4) and when J is set to 0.
Example of execution:
(Double click the Reference block and specify the reference position
of cart as 5.)
(Then, run simulation with J = 0)
>>y0 = y;
(run simulation with J = 0.21*(0.61/2)^2/3)
>> plot(t, y0(:,2), 'b--', t, y(:,2), 'b', t, y0(:,3), 'r--', t, y(:,3), 'r')
>> xlabel('Time [sec]');
>> ylabel('Displacement of cart and angle of pendulum');
Blue: cart position
Red: pendulum angle
Broken line: J = 0
Line: J is given as equation (4)
Exercise:
Change the mass of cart and/or pendulum, and the length of
pendulum, to compare the resultant responses before and
after the changes.