0% found this document useful (0 votes)
67 views16 pages

Inverted Pendulum1 Motion Equation

This document describes an inverted pendulum robot controlled by a PIC microcomputer. It contains the following information: 1. It provides the objectives, model, principal of operation, and block diagram of the inverted pendulum system. The system uses a gyro sensor and motor to maintain the pendulum in an upright position through feedback control. 2. It derives the state equation matrix that describes the motion of the inverted pendulum using parameters like the motor torque constant, pendulum inertia, and friction. 3. It calculates the actual values of these parameters for the specific inverted pendulum system described in the document. The state equation matrix is needed to establish a state control model using linear quadratic control.

Uploaded by

Aung Thike
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views16 pages

Inverted Pendulum1 Motion Equation

This document describes an inverted pendulum robot controlled by a PIC microcomputer. It contains the following information: 1. It provides the objectives, model, principal of operation, and block diagram of the inverted pendulum system. The system uses a gyro sensor and motor to maintain the pendulum in an upright position through feedback control. 2. It derives the state equation matrix that describes the motion of the inverted pendulum using parameters like the motor torque constant, pendulum inertia, and friction. 3. It calculates the actual values of these parameters for the specific inverted pendulum system described in the document. The state equation matrix is needed to establish a state control model using linear quadratic control.

Uploaded by

Aung Thike
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

Department of Mechatronic Engineering TTU

Inverted Pendulum by
PIC Control
Self-Standing Robot

1. Motion Equation

May 2017
Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 1
Table of Contents

1. Object .................................................................................................................................... 3

2. Inverted Pendulum Model ...................................................................................................... 3

2.1 Principal of Self-Standing ....................................................................................................... 4

3. Block Diagram of Inverted Pendulum ..................................................................................... 5

4. Motion Equation ..................................................................................................................... 7

5. State Equation Matrix ........................................................................................................... 11

6. Actual Number of State Equation Matrix............................................................................... 13

6.1 Motor Torque Constant K T ................................................................................................... 13

6.2 Pendulum Inertia 𝐽𝐽𝜃𝜃 ............................................................................................................ 15


31T

6.3 Rotation Friction C B , C R ....................................................................................................... 15

6.4 Actual Number of Each Parameters ..................................................................................... 16

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 2
1. Object
The motor driven inverted pendulum is well known as good material to study about
computer programming, control algorithm and electronic circuit. Because the inverted
pendulum is very simple mechanism and it’s easy to build it by myself. In addition, it is
not so difficult to let the pendulum standing-up because it has few control parameters. So
that, this equipment is a good material to study and it’s used to curriculum at many
universities to study embedded system or control algorithm.
This document describes about its principal, construction, motion equations and state
matrix equations. And this document also provides the process how to create these
equations. These state matrix equations are necessary to establish the state control
model. After then, it is dealt with as the issue of LQ ( Linear-Quadratic ).

2. Inverted Pendulum Model


This document explains about the self-standing type of inverted pendulum. Two type
models are shown in following pictures. The both types use same method of DC motor
driving mechanism, but only controller board is different. The first one is named as
“Arduino Type” which uses the Arduino UNO board for controller. The second one is
named as “H8/3069F Type” which uses the Akizuki Denshi’s H8/3069F board for controller.
The DC motor and gear system are same which are made by TAMIYA MOKEI.
And then, let’s try to use the PIC18F series microcomputer. The PIC18F series has
almost same performance and peripherals as Arduino and H8/3069F.

Fig-2.1 Arduino Type Fig-2.2 H8/3069F Type

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 3
2.1 Principal of Self-Standing
The mechanism of motor driven inverted pendulum is very simple. The gyro sensor
detects the rotation speed of pendulum. The microcomputer inputs it through A/D
converter and calculates control output with using the appropriate control gain. The
control output is converted to motor power by D/A converter and amplifier. The motor is
connected with the wheel via gear box.
The rotating direction of wheel is same as the falling down direction of pendulum. When
the wheels rotate, the counterforce will be generated to opposite direction. If the
pendulum inertia and counter force are equal, the pendulum will be able to stand up by
itself. This is the feed-back control system by proportional-differential controller.

Gyro
θ Sensor

Counterforce

Inertia
Motor Wheel Speed
.
x

Fig-2.1 Self-Standing Mechanism

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 4
3. Block Diagram of Inverted Pendulum
The Fig-3.1 shows the block diagram of H8/3069F type. The signal flows are as follows.

I. The gyro sensor detects rotation speed 𝜽𝜽̇. The voltage of output is 0.67mV/deg/s.
II. The OP Amp amplitudes the output voltage from gyro sensor. The output voltage of
rotation speed is very small. It’s need to amplitude more than ten times.
III. The A/D converter of controller converts rotation speed to digital number. The
Arduino, H8/3069F and PIC have some 10 bit A/D converter channels.
IV. There are four control parameters, rotation speed 𝜽𝜽̇, rotation angle 𝜽𝜽, X-direction
speed 𝑿𝑿̇ and X-direction distance 𝑿𝑿. And there are four feedback gains relating
with these control parameters, rotation speed gain 𝑲𝑲𝜽𝜽̇, rotation angle gain 𝑲𝑲𝜽𝜽,
X-direction speed gain 𝑲𝑲𝑿𝑿̇ and X-direction distance gain 𝑲𝑲𝑿𝑿.
V. There is no sensor to detect 𝑿𝑿̇. But the 𝑿𝑿̇ been able to estimate from control
output, because the wheel rotating speed proportions to the motor power. The 𝑿𝑿 is
calculated from the 𝑿𝑿̇. Also the 𝜽𝜽 is calculated from time integrating the 𝜽𝜽̇.

𝑿𝑿 = � 𝑿𝑿̇𝒅𝒅𝒅𝒅

𝜽𝜽 = � 𝜽𝜽̇𝒅𝒅𝒅𝒅

VI. The microcomputer calculates control input in accordance with the control
variables and feed-back gain. The control input means the manipulated variables
for revolution speed of motor.

𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪𝑪 𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰𝑰(𝑽𝑽𝑽𝑽) = 𝑲𝑲𝜽𝜽̇ ∗ 𝜽𝜽̇ + 𝑲𝑲𝑲𝑲 ∗ 𝜽𝜽 + 𝑲𝑲𝑿𝑿̇ ∗ 𝑿𝑿̇ + 𝑲𝑲𝑲𝑲 ∗ 𝑿𝑿

VII. The microcomputer converts the control input to DC voltage output by using the
8-bits D/A converter. This 8-bit means 0 to 255, and this value is converted to
analog signal from 0 to 5VDC. The motor amplifier has CW/CCW direction port
individually. So that, the control value should be limited -255 to +255. This system
uses two D/A channels to realize right turn or left turn. The CW and CCW signals
are used for go ahead and go back.
VIII. The motor amplifier outputs motor power in accordance with the voltage of control
input Vs and CW/CCW signals from microcomputer. There are two motor
amplifiers for right motor and left motor. The battery for motor is separated for
microcomputer in order to supply large current to two motors.
IX. There are two gear boxes for right motor and left motor. The motor revolution is
gear downed to 1:114.7

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 5
Fig-3.1 Block Diagram of H8/3069 type

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 6
4. Motion Equation
The motion model of inverted pendulum is as follows. The “Arduino type” and the
“H8/3069F type” are same.

θ m
Pendulum m:pendulum mass (kg)
M: wheel mass (kg)
L: length between GC to rotation center (m)
y θ:rotation angle (rad)
Jθ:pendulum inertia (kgm2)
H: horizontal counterforce (N)
x GC Jθ V: vertical counterforce (N)
F: X-direction force (N)
CB: rotation friction factor of wheel
Motor CR: rotation friction factor of pendulum
Wheel mg g : gravity (=9.81m/s2)
L
. V
CRθ H <Motor & Wheel>
F
T :Rotation torque of wheel (kgm)
r KT:Torque constant of motor (kgm/A)
M IM:Current of motor coil (A)

CB x
.
Fig-3.1 Motion Model

At first, separate the pendulum and wheel for simplification. After then, make the
Newton's motion equation individually.
Considering the pendulum. Following equations are derived.

𝑱𝑱𝜽𝜽 𝜽𝜽̈ = 𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝑽𝜽𝜽 − 𝑯𝑯𝑯𝑯𝑯𝑯𝑯𝑯𝑯𝑯𝜽𝜽 − 𝑪𝑪𝑹𝑹 𝜽𝜽̇ (1) m


θ
𝐝𝐝𝟐𝟐 y
𝐇𝐇 = 𝐦𝐦 (𝐱𝐱 + 𝐋𝐋𝐋𝐋𝐋𝐋𝐋𝐋𝛉𝛉) (2)
𝐝𝐝𝐭𝐭 𝟐𝟐

x
𝐝𝐝𝟐𝟐
𝐕𝐕 = 𝐦𝐦𝐦𝐦 + 𝐦𝐦 (𝐋𝐋𝐋𝐋𝐋𝐋𝐋𝐋𝛉𝛉) (3) Jθ
𝐝𝐝𝐭𝐭 𝟐𝟐

mg
V L
. H
CRθ

Fig-3.2 Pendulum Model

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 7
Next is about the wheel. Following equations is derived.

Motor
𝐅𝐅 = 𝐌𝐌𝐱𝐱̈ + 𝐂𝐂𝐁𝐁 𝐱𝐱̇ + 𝐇𝐇 (4)
Wheel
M
H F
r
V
From (2) equation
𝑑𝑑2 𝑑𝑑2
𝐻𝐻 = 𝑚𝑚 𝑑𝑑𝑡𝑡 2 𝑥𝑥 + 𝑚𝑚 𝑑𝑑𝑡𝑡 2 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝜃𝜃 CB x
.
Fig-3.3 Wheel Model
𝑑𝑑 2 𝑑𝑑
𝑚𝑚 2 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝜃𝜃 = 𝑚𝑚𝑚𝑚 � 𝜃𝜃̇ 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃� = 𝑚𝑚𝑚𝑚(𝜃𝜃̈𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝜃𝜃̇ 2 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃)
𝑑𝑑𝑡𝑡 𝑑𝑑𝑑𝑑
Therefore (2) is as follows
𝑯𝑯 = 𝒎𝒎𝒙𝒙̈ + 𝒎𝒎𝒎𝒎(𝜽𝜽̈𝒄𝒄𝒄𝒄𝒄𝒄𝜽𝜽 − 𝜽𝜽̇𝟐𝟐 𝒔𝒔𝒔𝒔𝒔𝒔𝜽𝜽) (2.1)

From (3) equation


𝑑𝑑 2
𝑉𝑉 = 𝑚𝑚𝑚𝑚 + 𝑚𝑚 (𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝑙𝜃𝜃)
𝑑𝑑𝑡𝑡 2
𝑑𝑑 2 𝑑𝑑
𝑚𝑚 2
(𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝜃𝜃) = 𝑚𝑚𝑚𝑚 �− 𝜃𝜃̇ 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃� = −𝑚𝑚𝑚𝑚(𝜃𝜃̈𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃 + 𝜃𝜃̇ 2𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃)
𝑑𝑑𝑡𝑡 𝑑𝑑𝑑𝑑
Therefore (3) is as follows
𝑽𝑽 = 𝒎𝒎𝒎𝒎 − 𝒎𝒎𝒎𝒎(𝜽𝜽̈𝒔𝒔𝒔𝒔𝒔𝒔𝜽𝜽 + 𝜽𝜽̇𝟐𝟐 𝒄𝒄𝒄𝒄𝒄𝒄𝜽𝜽) (3.1)

Insert (2.1) and (3.1) to (1)


2 2
𝐽𝐽𝜃𝜃 𝜃𝜃̈ = �𝑚𝑚𝑚𝑚 − 𝑚𝑚𝑚𝑚 �𝜃𝜃̈ 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃 + 𝜃𝜃̇ 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃�� 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝜃𝜃 − �𝑚𝑚𝑥𝑥̈ + 𝑚𝑚𝑚𝑚 �𝜃𝜃̈ 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝜃𝜃̇ 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃�� 𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝐿𝜃𝜃 − 𝐶𝐶𝑅𝑅 𝜃𝜃̇

2 2
= 𝑚𝑚𝑚𝑚𝑚𝑚𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃 − 𝑚𝑚𝐿𝐿2 𝜃𝜃̈ 𝑠𝑠𝑠𝑠𝑠𝑠2𝜃𝜃 − 𝑚𝑚𝐿𝐿2 𝜃𝜃̇ 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃 − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝑥𝑥̈ − 𝑚𝑚𝐿𝐿2 𝜃𝜃̈ 𝑐𝑐𝑐𝑐𝑐𝑐2 𝜃𝜃 + 𝑚𝑚𝐿𝐿2𝜃𝜃̇ 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝐶𝐶𝑅𝑅 𝜃𝜃̇
= −𝑚𝑚𝐿𝐿2 𝜃𝜃̈ �𝑠𝑠𝑠𝑠𝑠𝑠2 𝜃𝜃 + 𝑐𝑐𝑐𝑐𝑐𝑐2 𝜃𝜃� − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝑥𝑥̈ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 − 𝐶𝐶𝑅𝑅 𝜃𝜃̇
= −𝑚𝑚𝐿𝐿2 𝜃𝜃̈ − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝑥𝑥̈ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 − 𝐶𝐶𝑅𝑅 𝜃𝜃̇
𝐽𝐽𝜃𝜃 𝜃𝜃̈ + 𝑚𝑚𝐿𝐿2𝜃𝜃̈ = −𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝑥𝑥̈ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 − 𝐶𝐶𝑅𝑅 𝜃𝜃̇
̇
−𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝜽𝜽𝒙𝒙̈ −𝑪𝑪𝑹𝑹 𝜽𝜽+𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝜽𝜽
𝜽𝜽̈ = 𝟐𝟐
(5)
𝑱𝑱𝜽𝜽 +𝒎𝒎𝑳𝑳

Inserts (2.1) to (4)


𝐹𝐹 = 𝑀𝑀𝑥𝑥̈ + 𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚𝑥𝑥̈ + 𝑚𝑚𝑚𝑚(𝜃𝜃̈𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝜃𝜃̇ 2 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃)
(𝑀𝑀 + 𝑚𝑚)𝑥𝑥̈ = −𝑚𝑚𝑚𝑚�𝜃𝜃̈𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝜃𝜃̇ 2 𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃� − 𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝐹𝐹
−𝑪𝑪𝑩𝑩 𝒙𝒙̇ −𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝜽𝜽𝜽𝜽̈+𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝒎𝜽𝜽𝜽𝜽̇𝟐𝟐 +𝑭𝑭
𝒙𝒙̈ = (6)
𝑴𝑴+𝒎𝒎

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 8
Inserts (5) to (6) equation

−𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝑥𝑥̈ − 𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃


−𝐶𝐶𝐵𝐵 𝑥𝑥̇ − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝜃𝜃̇ 2 + 𝐹𝐹
𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2
𝑥𝑥̈ =
𝑀𝑀 + 𝑚𝑚

(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )(𝑀𝑀 + 𝑚𝑚)𝑥𝑥̈ = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃(𝑚𝑚𝑚𝑚𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃𝑥𝑥̈ + 𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃)
+(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝜃𝜃̇ 2 + (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐹𝐹
(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )(𝑀𝑀 + 𝑚𝑚)𝑥𝑥̈ = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐 2 𝜃𝜃𝑥𝑥̈ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝑚𝑚2 𝐿𝐿2𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃
+(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝜃𝜃̇ 2 + (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐹𝐹
((𝑀𝑀 + 𝑚𝑚)𝐽𝐽𝜃𝜃 + 𝑀𝑀𝑀𝑀𝐿𝐿2 + 𝑚𝑚2 𝐿𝐿2 − 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐 2 𝜃𝜃)𝑥𝑥̈ = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝑚𝑚2 𝐿𝐿2 𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃
+(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝜃𝜃̇ 2 + (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐹𝐹
((𝑀𝑀 + 𝑚𝑚)𝐽𝐽𝜃𝜃 + 𝑀𝑀𝑀𝑀𝐿𝐿2 + 𝑚𝑚2 𝐿𝐿2 𝑠𝑠𝑠𝑠𝑠𝑠2 𝜃𝜃)𝑥𝑥̈ = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝑚𝑚2 𝐿𝐿2 𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝑔𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃
+(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝜃𝜃̇ 2 + (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐹𝐹

̇ 2
Around θ ≒ 0 then, sinθ = θ, sin2 θ = 0, cosθ = 1 and θ = 0

((𝑀𝑀 + 𝑚𝑚)𝐽𝐽𝜃𝜃 + 𝑀𝑀𝑀𝑀𝐿𝐿2 )𝑥𝑥̈ = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃̇ − 𝑚𝑚2 𝐿𝐿2 𝑔𝑔𝜃𝜃 + (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐹𝐹

−�𝑱𝑱𝜽𝜽 +𝒎𝒎𝑳𝑳𝟐𝟐 �𝑪𝑪𝑩𝑩 𝒙𝒙̇ +𝒎𝒎𝒎𝒎𝑪𝑪𝑹𝑹 𝜽𝜽̇−𝒎𝒎𝟐𝟐 𝑳𝑳𝟐𝟐 𝒈𝒈𝜽𝜽+�𝑱𝑱𝜽𝜽 +𝒎𝒎𝑳𝑳𝟐𝟐 �𝑭𝑭
𝒙𝒙̈ = (𝑴𝑴+𝒎𝒎)𝑱𝑱𝜽𝜽 +𝑴𝑴𝑴𝑴𝑳𝑳𝟐𝟐
(7)

Inserts (6) to (5)

−𝑚𝑚𝑚𝑚�𝜃𝜃̈𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝜃𝜃̇ 2𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃� − 𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝐹𝐹


−𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 − 𝐶𝐶𝑅𝑅 𝜃𝜃̇ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃
𝜃𝜃̈ = 𝑀𝑀 + 𝑚𝑚
𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2

(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )(𝑀𝑀 + 𝑚𝑚)𝜃𝜃̈


= (−𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃�−𝑚𝑚𝑚𝑚�𝜃𝜃̈𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃 − 𝜃𝜃̇ 2𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃� − 𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝐹𝐹� + (𝑀𝑀 + 𝑚𝑚)(−𝐶𝐶𝑅𝑅 𝜃𝜃̇ + 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃)
(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )(𝑀𝑀 + 𝑚𝑚)𝜃𝜃̈ = 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝐵𝐵 𝑥𝑥̇ + 𝑚𝑚2𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐 2 𝜃𝜃𝜃𝜃̈ − 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃𝜃𝜃̇ 2 − (𝑀𝑀 + 𝑚𝑚)𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝐹𝐹𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃
+(𝑀𝑀 + 𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃
((𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿 2 )(𝑀𝑀
+ 𝑚𝑚) − 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐 2 𝜃𝜃)𝜃𝜃̈ = 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝐵𝐵 𝑥𝑥̇ − 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃𝜃𝜃̇ 2 − (𝑀𝑀 + 𝑚𝑚)𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝐹𝐹𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃
+(𝑀𝑀 + 𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃
((𝑀𝑀 + 𝑚𝑚)𝐽𝐽𝜃𝜃 + 𝑀𝑀𝑀𝑀𝐿𝐿 + 𝑚𝑚2 𝐿𝐿2 − 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐 2 𝜃𝜃)𝜃𝜃̈ = 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝐵𝐵 𝑥𝑥̇ − 𝑚𝑚2 𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃𝜃𝜃̇ 2 − (𝑀𝑀 + 𝑚𝑚)𝐶𝐶𝑅𝑅 𝜃𝜃̇
2

−𝐹𝐹𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 + (𝑀𝑀 + 𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃


((𝑀𝑀 + 𝑚𝑚)𝐽𝐽𝜃𝜃 + 𝑀𝑀𝑀𝑀𝐿𝐿 + 𝑚𝑚2 𝐿𝐿2 𝑠𝑠𝑠𝑠𝑠𝑠2 𝜃𝜃)𝜃𝜃̈ = 𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃𝐶𝐶𝐵𝐵 𝑥𝑥̇ − 𝑚𝑚2𝐿𝐿2 𝑐𝑐𝑐𝑐𝑐𝑐𝜃𝜃𝑠𝑠𝑠𝑠𝑠𝑠𝜃𝜃𝜃𝜃̇ 2 − (𝑀𝑀 + 𝑚𝑚)𝐶𝐶𝑅𝑅 𝜃𝜃̇ − 𝐹𝐹𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃
2

+(𝑀𝑀 + 𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃

̇ 2
Around θ ≒ 0 then, sinθ = θ, sin2 θ = 0, cosθ = 1 and θ = 0

((𝑀𝑀 + 𝑚𝑚)𝐽𝐽𝜃𝜃 + 𝑀𝑀𝑀𝑀𝐿𝐿2 )𝜃𝜃̈ = 𝑚𝑚𝑚𝑚𝐶𝐶𝐵𝐵 𝑥𝑥̇ − (𝑀𝑀 + 𝑚𝑚)𝐶𝐶𝑅𝑅 𝜃𝜃̇ + (𝑀𝑀 + 𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚𝜃𝜃 − 𝐹𝐹𝐹𝐹𝐹𝐹

̇
𝒎𝒎𝒎𝒎𝑪𝑪𝑩𝑩 𝒙𝒙̇ −(𝑴𝑴+𝒎𝒎)𝑪𝑪𝑹𝑹 𝜽𝜽+(𝑴𝑴+𝒎𝒎)𝒎𝒎𝒎𝒎𝒎𝒎𝜽𝜽−𝑭𝑭𝑭𝑭𝑭𝑭
𝜽𝜽̈ = (𝑴𝑴+𝒎𝒎)𝑱𝑱 𝟐𝟐
(8)
𝜽𝜽 +𝑴𝑴𝑴𝑴𝑳𝑳

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 9
The X-direction force F consists of motor torque T and wheel radius r. Refer the equation
(9). And the motor torque T is made by motor torque constant K T and motor current I M .
Refer the equation (10).

Motor
𝑇𝑇 Wheel T
F= (9)
𝑟𝑟
T = 𝐾𝐾𝑇𝑇 𝐼𝐼𝑀𝑀 (10) KT
IM F
r
Therefor from (9) and (10)
𝑲𝑲𝑻𝑻
𝐅𝐅 = 𝑰𝑰𝑴𝑴 (11)
𝒓𝒓
Fig-3.4 Motor Model

Therefor (7) and (8) are as follows

−�𝑱𝑱𝜽𝜽 +𝒎𝒎𝑳𝑳𝟐𝟐 �𝑪𝑪𝑩𝑩 𝒙𝒙̇ +𝒎𝒎𝒎𝒎𝑪𝑪𝑹𝑹 𝜽𝜽̇−𝒎𝒎𝟐𝟐 𝑳𝑳𝟐𝟐 𝒈𝒈𝜽𝜽 �𝑱𝑱 +𝒎𝒎𝑳𝑳𝟐𝟐 �
𝜽𝜽 𝑲𝑲𝑻𝑻
𝒙𝒙̈ = (𝑴𝑴+𝒎𝒎)𝑱𝑱𝜽𝜽 +𝑴𝑴𝑴𝑴𝑳𝑳𝟐𝟐
+ (𝑴𝑴+𝒎𝒎)𝑱𝑱 ∗ 𝑰𝑰𝑴𝑴 (12)
𝜽𝜽 +𝑴𝑴𝑴𝑴𝑳𝑳𝟐𝟐 𝒓𝒓

̇
𝒎𝒎𝒎𝒎𝑪𝑪𝑩𝑩 𝒙𝒙̇ −(𝑴𝑴+𝒎𝒎)𝑪𝑪𝑹𝑹 𝜽𝜽+(𝑴𝑴+𝒎𝒎)𝒎𝒎𝒎𝒎𝒎𝒎𝜽𝜽 𝒎𝒎𝒎𝒎 𝑲𝑲𝑻𝑻
𝜽𝜽̈ = 𝟐𝟐
− ∗ 𝑰𝑰𝑴𝑴 (13)
(𝑴𝑴+𝒎𝒎)𝑱𝑱 𝜽𝜽 +𝑴𝑴𝑴𝑴𝑳𝑳 (𝑴𝑴+𝒎𝒎)𝑱𝑱 𝜽𝜽 +𝑴𝑴𝑴𝑴𝑳𝑳𝟐𝟐 𝒓𝒓

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 10
5. State Equation Matrix
Next is to make the state equation matrix from (12) and (13) equations. Following figure
shows standard state equation. The character “S” means Laplace operator.

.
X 1 X
U B + C + Y
S

Fig-4.1 Standard State Equation

𝑿𝑿̇ = 𝐀𝐀𝐀𝐀 + 𝐁𝐁𝐁𝐁 𝑿𝑿𝑻𝑻 = [𝒙𝒙̇ 𝒙𝒙 𝜽𝜽̇ 𝜽𝜽] X: State Variables Vector (14)
𝐘𝐘 = 𝐂𝐂𝐂𝐂 + 𝐃𝐃𝐃𝐃 Y: Output Vector
𝐔𝐔 = 𝑰𝑰𝑴𝑴 U: Input Vector
A: State Matrix
B: Input Matrix
C: Output Matrix
D: Feedforward Matrix

Therefor
(𝐽𝐽𝜃𝜃 +𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑚𝑚𝑚𝑚𝐶𝐶𝑅𝑅 −𝑚𝑚2 𝐿𝐿2 𝑔𝑔
⎡ − 𝑎𝑎0
0 𝑎𝑎0 ⎤
𝑎𝑎0
⎢ ⎥
⎢ 1 0 0 0 ⎥
A=⎢ ⎥
𝑚𝑚𝑚𝑚𝐶𝐶𝐵𝐵 (𝑀𝑀+𝑚𝑚)𝐶𝐶𝑅𝑅 (𝑀𝑀+𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚
⎢ 0 − ⎥
𝑎𝑎0 𝑎𝑎0 𝑎𝑎0
⎢ ⎥
⎣ 0 0 1 0 ⎦
𝑎𝑎0 = 𝐽𝐽𝜃𝜃 (𝑀𝑀 + 𝑚𝑚) + 𝑀𝑀𝑀𝑀𝐿𝐿2

𝜃𝜃 𝐽𝐽 +𝑚𝑚𝐿𝐿2
𝑇𝑇 𝐾𝐾 1 0 0 0 0
⎡ 𝑎𝑎0 ∗ 𝑟𝑟 ⎤ ⎡ ⎤ ⎡ ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ 0 ⎥ ⎢0 1 0 0⎥ ⎢0⎥
B=⎢ ⎥ 𝐶𝐶 = ⎢ ⎥ D=⎢ ⎥
𝑚𝑚𝑚𝑚 𝐾𝐾
⎢ − ∗ 𝑇𝑇 ⎥ ⎢0 0 1 0⎥ ⎢0⎥
𝑎𝑎0 𝑟𝑟 ⎢ ⎥ ⎢ ⎥
⎢ ⎥
⎣ 0 ⎦ ⎣0 0 0 1⎦ ⎣0⎦

The output vector Y is same the state variables vector X.

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 11
Therefor

(𝐽𝐽𝜃𝜃 +𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑚𝑚𝑚𝑚𝐶𝐶𝑅𝑅 −𝑚𝑚2 𝐿𝐿2 𝑔𝑔 𝐽𝐽 +𝑚𝑚𝐿𝐿2 𝐾𝐾


𝑥𝑥̈ − 0 𝑥𝑥̇ 𝜃𝜃 𝑇𝑇
⎡ ⎤ ⎡ 𝑎𝑎0 𝑎𝑎0 𝑎𝑎0 ⎤ ⎡ ⎤ ⎡ 𝑎𝑎0 ∗ 𝑟𝑟 ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ 𝑥𝑥̇ ⎥ ⎢ 1 0 0 0 ⎥ ⎢ 𝑥𝑥 ⎥ ⎢ 0 ⎥
⎢ ⎥ = ⎢ ⎥ ⎢ ⎥+⎢ ⎥ 𝐼𝐼𝑀𝑀 (15)
⎢ 𝜃𝜃̈ ⎥ ⎢
𝑚𝑚𝑚𝑚𝐶𝐶𝐵𝐵
0 −
(𝑀𝑀+𝑚𝑚)𝐶𝐶𝑅𝑅 (𝑀𝑀+𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚
⎥ ⎢ 𝜃𝜃̇ ⎥ ⎢ − 𝑚𝑚𝑚𝑚 ∗ 𝐾𝐾𝑇𝑇 ⎥
⎢ ⎥ 𝑎𝑎0 𝑎𝑎0 𝑎𝑎0 ⎢ ⎥ ⎢ 𝑎𝑎0 𝑟𝑟
⎢ ⎥ ⎥
⎣ 𝜃𝜃̇ ⎦ ⎣ 0 0 1 0 ⎦ ⎣ 𝜃𝜃 ⎦ ⎣ 0 ⎦
𝑎𝑎0 = 𝐽𝐽𝜃𝜃 (𝑀𝑀 + 𝑚𝑚) + 𝑀𝑀𝑀𝑀𝐿𝐿2

1 0 0 0 𝑥𝑥̇ 0
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢0 1 0 0⎥ ⎢ 𝑥𝑥 ⎥ ⎢0⎥
Y= ⎢ ⎥ ⎢ ⎥+ ⎢ ⎥ 𝐼𝐼𝑀𝑀 (16)
⎢0 0 1 0⎥ ⎢ 𝜃𝜃̇ ⎥ ⎢0⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣0 0 0 1⎦ ⎣ 𝜃𝜃 ⎦ ⎣0⎦

The (15) equation is replaced as follows.

𝑥𝑥̈ 𝑎𝑎11 0 𝑎𝑎13 𝑎𝑎14 𝑥𝑥̇ b1


⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ 𝑥𝑥̇ ⎥ ⎢ 1 0 0 0 ⎥ ⎢ 𝑥𝑥 ⎥ ⎢ 0 ⎥
⎢ ⎥ = ⎢ ⎥ ⎢ ⎥+⎢ ⎥ 𝐼𝐼𝑀𝑀 (17)
⎢ 𝜃𝜃̈ ⎥ ⎢ 𝑎𝑎31 0 𝑎𝑎33 𝑎𝑎34 ⎥ ⎢ 𝜃𝜃̇ ⎥ ⎢ b3 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣ 𝜃𝜃̇ ⎦ ⎣ 0 0 1 0 ⎦ ⎣ 𝜃𝜃 ⎦ ⎣ 0 ⎦

𝑎𝑎0 = 𝐽𝐽𝜃𝜃 (𝑀𝑀 + 𝑚𝑚) + 𝑀𝑀𝑀𝑀𝐿𝐿2


𝑎𝑎11 = −(𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 /𝑎𝑎0
𝑎𝑎13 = 𝑚𝑚𝐿𝐿/𝑎𝑎0
𝑎𝑎14 = −𝑚𝑚2𝐿𝐿2 𝑔𝑔/𝑎𝑎0
𝑎𝑎31 = 𝑚𝑚𝑚𝑚𝐶𝐶𝐵𝐵 /𝑎𝑎0
𝑎𝑎33 = −(M + 𝑚𝑚)𝐶𝐶𝑅𝑅 /𝑎𝑎0
𝑎𝑎34 = (M + 𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚/𝑎𝑎0
b1 = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿2 )𝐾𝐾𝑇𝑇 /(a0 ∗ 𝑟𝑟)
𝑏𝑏3 = −𝑚𝑚𝑚𝑚𝐾𝐾𝑇𝑇 /(a0 ∗ 𝑟𝑟)

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 12
6. Actual Number of State Equation Matrix
6.1 Motor Torque Constant KT
The motor torque T is a proportional value of motor current I M . The actual number of
K T is able to calculate by measuring the torque T and current I M .
From (9), (10) equation
𝑻𝑻 𝑭𝑭𝑭𝑭
𝑲𝑲𝑻𝑻 = = (18)
𝑰𝑰𝑴𝑴 𝑰𝑰𝑴𝑴

The following figure shows one method to measure the force F. The r is radius of wheel.
The easy way is to use the inverted pendulum body. Because which already implements
the PIC, motor and gear.

Motor
Wheel
T F

IM
r
Wire

Load
F=M*g=weight M
T=F*r

M*g
Fig-8.1 Measuring Motor Torque

The following figures are actual measured value with using the self-standing robot.
The Fig-5.1 shows the relation between Vs and I M . The Vs means the set value to A/D
converter of PIC. The PIC A/D consists of 8 bit converter, so the set value should be in
range from 0 to 255. Also the Fig-5.2 shows the relation between Vs and torque constant
K T. Therefore, it’s easy to get the I M and K T with using the following figures.

Fig-5.2 Relation of Vs–I M Fig-5.3 Relation of Vs-K T

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 13
But when measuring the torque and motor current, the force F is already measured. So
that, it’s not necessary to calculate the I M and K T . The relation between A/D set value
Vs and force F is shown in the Fig-5.4. This figure shows only one motor. The total force
must be twice of this number.

F = K F Vs*2 K F =0.00248 (19)

Fig-5.4 Relation of Vs-F

Therefor (15), (16) and (17) are

(𝐽𝐽𝜃𝜃 +𝑚𝑚𝐿𝐿2 )𝐶𝐶𝐵𝐵 𝑚𝑚𝑚𝑚𝐶𝐶𝑅𝑅 −𝑚𝑚2 𝐿𝐿2 𝑔𝑔 𝐽𝐽 +𝑚𝑚𝐿𝐿2


𝑥𝑥̈ − 0 𝑥𝑥̇ 𝜃𝜃
⎡ ⎤ ⎡ 𝑎𝑎0 𝑎𝑎0 𝑎𝑎0 ⎤ ⎡ ⎤ ⎡ 𝑎𝑎0 ∗ 2𝐾𝐾𝐹𝐹 ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ 𝑥𝑥̇ ⎥ ⎢ 1 0 0 0 ⎥ ⎢ 𝑥𝑥 ⎥ ⎢ 0 ⎥
⎢ ⎥ = ⎢ ⎥ ⎢ ⎥+⎢ ⎥ 𝑉𝑉𝑆𝑆 (20)
⎢ 𝜃𝜃̈ ⎥ ⎢
𝑚𝑚𝑚𝑚𝐶𝐶𝐵𝐵
0 −
(𝑀𝑀+𝑚𝑚)𝐶𝐶𝑅𝑅 (𝑀𝑀+𝑚𝑚)𝑚𝑚𝑚𝑚𝑚𝑚
⎥ ⎢ 𝜃𝜃̇ ⎥ ⎢ − 𝑚𝑚𝑚𝑚 ∗ 2𝐾𝐾𝐹𝐹 ⎥
⎢ ⎥ 𝑎𝑎0 𝑎𝑎0 𝑎𝑎0 ⎢ ⎥ ⎢ 𝑎𝑎0
⎢ ⎥ ⎥
⎣ 𝜃𝜃̇ ⎦ ⎣ 0 0 1 0 ⎦ ⎣ 𝜃𝜃 ⎦ ⎣ 0 ⎦

1 0 0 0 𝑥𝑥̇ 0
⎡ ⎤ ⎡ ⎤ ⎡ ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢0 1 0 0⎥ ⎢ 𝑥𝑥 ⎥ ⎢ 0 ⎥
Y= ⎢ ⎥ ⎢ ⎥ + ⎢ ⎥ 𝑉𝑉𝑆𝑆 (21)
⎢0 0 1 0⎥ ⎢ 𝜃𝜃̇ ⎥ ⎢ 0 ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣0 0 0 1⎦ ⎣ 𝜃𝜃 ⎦ ⎣ 0 ⎦

𝑥𝑥̈ 𝑎𝑎11 0 𝑎𝑎13 𝑎𝑎14 𝑥𝑥̇ b1


⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ 𝑥𝑥̇ ⎥ ⎢ 1 0 0 0 ⎥ ⎢ 𝑥𝑥 ⎥ ⎢ 0 ⎥
⎢ ⎥ = ⎢ ⎥ ⎢ ⎥+⎢ ⎥ 𝑉𝑉𝑆𝑆 (22)
⎢ 𝜃𝜃̈ ⎥ ⎢ 𝑎𝑎31 0 𝑎𝑎33 𝑎𝑎34 ⎥ 𝜃𝜃 ̇
⎢ ⎥ ⎢ 3 ⎥b
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎣ 𝜃𝜃̇ ⎦ ⎣ 0 0 1 0 ⎦ ⎣ 𝜃𝜃 ⎦ ⎣ 0 ⎦
2
b1 = (𝐽𝐽𝜃𝜃 + 𝑚𝑚𝐿𝐿 )2𝐾𝐾𝐹𝐹 /a0
𝑏𝑏3 = −𝑚𝑚𝑚𝑚2𝐾𝐾𝐹𝐹 /a0

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 14
6.2 Pendulum Inertia 𝑱𝑱𝜽𝜽
The following figure shows simplified model to calculate inertia moment of pendulum.
The exact number of pendulum length and weight are different between the Arduino
type and H8/3069F type. The weight includes the motors, gear box and batteries, of
course. The unit of dimension is “mm” and weight is “kg”.

<Ar dui no> <H8/ 3069F>


a=150 a=160

b=60 b=75

c=60 m=0.490 c=68 m=0.460

x=39 24 x=53 27

Jθ=(m(a2+b2))/12+mx2 Jθ=(m(a2+b2))/12+mx2
=1.81x10-3 =2.49x10-3

Fig-8.5 Outline of Pendulum Body

6.3 Rotation Friction C B , C R


The rotation friction of wheel C B and rotation friction of pendulum C R are well known
and defined as common data. The exact number of C B and C R are selected from common
data.
The C B is a rotation friction factor between wheel and surface. In generally, rotation
friction factor of bicycle wheel is known as 0.002 to 0.005. The wheel of this inverted
pendulum is made by gum and it’s a same as bicycle wheel. So, in this lecture, the exact
number of 0.005 is selected for C B.
The C R is a slip friction factor between pendulum shaft and hub. In generally, the slip
friction factor of is known as 0.01 to 0.02. In this lecture, the exact number of 0.002 is
selected for C R.

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 15
6.4 Actual Number of Each Parameters
The Table-8.1 shows exact number of parameters of each type. The C B and C R are used
from common data.

Table-8.1 Exact number of each type


Arduino Type H8/3069F Type PIC18F Type
𝐽𝐽𝜃𝜃 (kgm2)
R
1.81x10 -3 2.49x10 -3
M (kg) 2x2.25x10 -2 2x2.95x10 -2
m (kg) 4.90x10 -1 4.60x10 -1
L (m) 3.90x10 -2 5.30x10 -2
𝐶𝐶𝐵𝐵 5x10 -3 5x10 -3
𝐶𝐶𝑅𝑅 2x10 -2 2x10 -2
KF 2.48x10 -3 2.48x10 -3

The exact numbers of state equation matrix are as follows.

Table-8.2 Exact number of state equation matrix


Arduino Type H8/3069F Type PIC18F Type
𝑎𝑎0 1.00x10 -3 1.37x10 -3
𝑎𝑎11 -1.28x10 -2 -1.38x10 -2
𝑎𝑎13 3.81x10 -1 3.56x10 -1
𝑎𝑎14 -3.57 -4.26
𝑎𝑎31 9.53x10 -2 8.91x10 -2
𝑎𝑎33 -10.7 -7.59
𝑎𝑎34 100 90.7
b1 1.26x10 -2 1.37x10 -2
b3 -9.46x10 -2 -8.84x10 -2

Title No Revision
Inverted Pendulum by PIC Control 0
1. Motion Equation Page 16

You might also like