You are on page 1of 20

a 

        


 

p 

 2010/7/28
R 
Π  
  
    


 R 
   

   R   R
        
  



 2010/7/28
[
  
- ‰ 
1. 3-point platform
2.2wheels ( one of which is geared and attached to a DC motor)
3.audio jack

a. it is used as the axis of rotation for the base platform
b. it is to bring commutated power to the controller board

r 2010/7/28
  
The pendulum is attached to the base platform by a 360o free
rotating potentiometer.
The pendulum·s base is attached to the potentiometer in such
a fashion that when the pendulum is balance (completely
vertical), the potentiometer center tap is biased to VERF/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.

 2010/7/28
   
- Ë 
1. ù 
The motor is controlled by an H-bridge which is driven
by the PIC16F684 Enhanced Capture/ Compare/PWM
Module (ECCP). The output of the ECCP are connected
to FET drivers that produce the proper drive voltage and
reduce the transition time for the FETs in the H-bridge.
2. 
- ö ´ 1. KPKIKD
2.

3.

´ 2010/7/28
R

 2010/7/28
- Proportional TermKPE(t)
Ë —® 
- Integral TermKIœE(t)dt

Ë —f 


- Derivative TermKDdE(t)/dt

Ë 5 

G 2010/7/28
The frequency of the PID control loop is also going to be
selected to simplify the math routines. The Integral term, in
Equation 3, shows that each error term needs to be
multiplied by the sample.
By choosing a sampling frequency in power of 2·s, a very fast
divide routine can be done by using the right shift command,
where each right shift is a divide by 2. Knowing this, choose
2´6Hz as the sampling frequency.

 2010/7/28

  
- Converting over to a digital system,Y(t) is measured by an
A/D converter. In order to implement the PID controller,
the PICmicro® microcontroller will have to do some
approximations of integral and derivative terms.

¿ 2010/7/28
  
- The input filter is a low-pass Bessel
1. cut-off frequency of 60Hz
The cut-off frequency was chosen to be at least twice the
expected frequency of the pendulum.
2. voltage gain of 6
The gain of the filter was chosen to increase the resolution
of the A/D converter.
With the 360Ü potentiometer and 10-bit A/D converter,
with no gain, one LSb equals 0.3´Ü.
With the gain set to 6, the displacement angle is limited to
I30Ü which gives a resolution of 0.0´ Ü per.

 2010/7/28
ƒ      
- In order to proper implement the control algorithm the user
needs to look at how the mechanical and electrical system are
going to interface together.
- Dynamic modeling the inverted pendulum is not a simple task.
- Select a motor (with proper torque, rpm·s and gear ration to the
drive wheel)
- The angular acceleration of the pendulum with respect to the
displacement angle is  wŽ (g/R) ¼
- ¼MAX is controlled by both hardware and software.
Π 

  Ir 



I r
 
The boundary of software I20Ü or I0.34 radians

 2010/7/28
- EPU
-  4.6~7.2V
- t 2 inch
- Ð 8.6:1


- decrease ¼MAX in the software
- increase the length of the pendulum
- Increase the coefficient of friction between the drive wheel
and the base

 2010/7/28
a    
Z 
1.The interrupt service routine is set to run off the Timer0
interrupt.
2.Timer0 is an 8-bit timer that will increment the TMR0 register
every instruction clock.
3.When the TMR0 register overflow, the Timer0 interrupt flag is
set.
4.The speed at which the interrupt should occur is every
3. millisecond.

r 2010/7/28
PID ö 
The derivative term is crucial in order to bring the inherently
unstable system into stability. In any PID control the derivative
terms acts as an anticipator. By checking the current error against
the previous error, the controller can tell if the error term is
getting large or small.
1. If the error term is getting large , the derivative term adds to
the output of the controller much like that of the proportional
and integral, but to a lesser effect.
2. If the error term is getting smaller, this term will subtract from
the output of the control in anticipation of an over-shoot
condition.

 2010/7/28
! 
- //calculate the differential term
- Derivative_term ec0 ² en3;
- If(derivative_term > 120){
- derivative_term 120;
- }
- If(derivative_term < -120){
- derivative_term -120;
- }
- derivative_term derivative_term * Kd;
- derivative_term derivative_term >>´;
- // divide by 32
- if(derivative_term >120){
- derivative_term 120;
- }
- if(derivative_term> -120){
- derivative_term -120;
- }

´ 2010/7/28
- @ Z

- 
—

 2010/7/28
- Why use E(n)-E(n-3) instead of E(n)-E(n-1)?

The main reason for doing this is to limit the variation in the
error angle measurement. There will always be an amount of
uncertainty associated with the error measurement, some of
which can be attributed to A/D error, Bessel filter
throughput, mechanical vibration.

G 2010/7/28
# 
—Q
1.hKpKiKd
 
2.512V( 3)  Z
3.h  0



    Ë
 PID
 
4. Kp 3 
  
´.# Ki— KpKi— —
!—"Ki # 
$ 
%&—"'(

 2010/7/28
6. Kd—KpKi '(

7.  )*PIDö #

¿ 2010/7/28
!  
gPIC16F684
ZECCPA/D! +*
PID ö ,-
",-Z
."#$ 
  ,-/"%
0$12  34 PID ö
  2@ / &'#

 2010/7/28