Professional Documents
Culture Documents
Inverted Pendulum MicroChip PDF
Inverted Pendulum MicroChip PDF
PENDULUM
The pendulum is attached to the base platform by a
360 free rotating potentiometer. The pendulums base
is attached to the potentiometer in such a fashion that
when the pendulum is balanced (completely vertical),
the potentiometer center tap is biased to VREF/2. For
the rest of this application note will be used to denote
the displacement angle of the pendulum with respect to
the vertical axis.
CONTROLLER BOARD
Feedback EQUATION 4:
C(n) = KPE(n) + KITs E(n) + KD[E(n)- E(n-1)]/Ts
N
R(t) = Reference of desired set point
0
Y(t) = Measured response
E(t) = Error OR
N
Reset of
Reset TMR0
PIC16F684
Yes No
Calculate
Integral Term Error to Yes Clear PID
small? Loop Flag
Set PWM DC
& direction
Shift errors
clear PID flag
DS00964A-page 8
100 nF RA4/OSC2 RA1/AN1 ICSPCLK
AN964
4 11
APPENDIX A:
PIC16F684/P
+15V +15V
C1 C8
SCHEMATICS
100 nF 100 nF
+15V +15V
C3 C4
8 7 Q1:A 10 pF 10 pF Q2:A 7 8
IRF7389 IRF7389 U2:B
4 5 2 1 2 4
P1B 2 5 P1D
U1:B
R2 TC4428A TC4428A R4
1 J1 1
100 k 100 k
Note 1: Unless otherwise specified, resistance values are in . Resistors are 5% tolerance. Capacitance values are in F.
2: Device names and numbers shown here are for reference only and may differ from the actual number.
3: Items labeled with A are unpopulated, B are socketed but not populated, and C are socketed and populated.
R32
FIGURE 8:
+5V 10 k
R16 S1
1 4
9.1 k MCLR
C11 C13 2 3
0.1 F
6.8 nF
+5V +5_SWITCHED
8
J2 2 U4:A TP3
4
3 MCP602SN C12 TP5 TP6
C10 MCP602SN
+5V 1 F
BUTTON
0.1 F
R17
150 k
CW
3
Offset R9 2
10 k In-Circuit Serial
+5V
1
CCW C14 Programming Header
CW
3
1 F J3
R29 1 No Connect
R27 2 R18
P-POT
10 k 100 150 k 2
ICSPCLK
1
CCW C24 3
ICSPDATA
4
0.1 F
5
+5_SWITCHED
6
+5V MCLR
CW BFMP
3
R30
R26 2
I-POT U8
10 k 100
1
CCW C23 LM2940S
TP1 +15V
0.1 F R8
1 Input Output 3 +5_SWITCHED
TP2 2
+5V C19 C18 C17 C21
Gnd
Gnd
CW
2
4
470 F 1 F 22 F 4.7 F
3
R31
R28 2 +5V
D-POT R23
10 k 100
1
CCW C22 2 C20
0.1 F
4.7 F
DS00964A-page 9
AN964
AN964
APPENDIX B: DERIVATION OF Using 2 unit vectors, i and j to represent the horizontal
and vertical vectors respectively, yields the following
EQUATION 5
equations for the pendulum.
The pendulums motion is described in this appendix
with one assumption. The assumption is that the EQUATION B-1:
pendulum is modeled as a point mass at the end of a
massless rod. Position = Rsini +Rcosj
Where R is the length of the pendulum
FIGURE 9: PENDULUM FREE BODY
DIAGRAM
The pendulums angular velocity is the derivative of the
j position with respect to .
EQUATION B-2:
i Velocity = Rcosi Rsinj
mg
The pendulums angular acceleration is the derivative
T of the angular velocity w.r.t. .
EQUATION B-3:
Acceleration = (Rcosi R2sini) (Rsinj + R2cosj)
= R(cosi sinj 2sini 2cosj)
EQUATION B-4:
EQUATION B-5:
EQUATION B-6:
EQUATION B-9:
EQUATION B-10:
EQUATION B-11:
EQUATION B-12:
EQUATION B-13:
EQUATION B-15:
= (g/R)sin
EQUATION B-16:
= (g/R)
Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the
intended manner and under normal conditions.
There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our
knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data
Sheets. Most likely, the person doing so is engaged in theft of intellectual property.
Microchip is willing to work with the customer who is concerned about the integrity of their code.
Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not
mean that we are guaranteeing the product as unbreakable.
Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our
products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts
allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.
10/20/04