Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume...

18
Balancing Robot Control MEAM 510 Fall 2012 Bruce D. Kothmann

Transcript of Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume...

Page 1: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Balancing Robot Controlg

MEAM 510Fall 2012

Bruce D. Kothmann

Page 2: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Agenda• Bruce’s Controls Resume• Simple Mechanics (Statics & Dynamics) of the Balancing Robot• Basic Ideas About Feedback & Stability• Basic Ideas About Feedback & Stability

– Effects of Proportional Feedback– Two Key Observations About Integral Feedback – Derivative Feedback Used to StabilizeDerivative Feedback Used to Stabilize

• Why PID Feedback of Arm Angle Won’t “Work”– Effect of Sensor Alignment– Effect of Sloped TableEffect of Sloped Table– What Will Work

• Some Implementation Issues– Hall Effect Sensor for Wheel AngleHall Effect Sensor for Wheel Angle– Dealing with Accelerometer Noise & Rate Gyro Bias– 10-Bit A/D and Amplifiers– Sample Rate : Is Faster Always Better?

• Best Robots Invited to Demo in ESE 406 This Spring!

MEAM 510 : Balancing Robot Control Page 1BDK : 2012-10-26

Page 3: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Inverted Pendulum

BDK : 2012-10-26 Page 2MEAM 510 : Balancing Robot Control

Page 4: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Inverted Pendulum Description

M1 Microcontroller(PID Control)(PID Control)

Encoder From Lego Motor 43362EncoderGeek.com http://www.philohome.com/motors/motorcomp.htm

BDK : 2012-10-26 Page 3MEAM 510 : Balancing Robot Control

Page 5: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

“Ping Pong Poise”

BDK : 2012-10-26 Page 4MEAM 510 : Balancing Robot Control

Page 6: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Ping Pong Poise Description

This is a “Fixed-Point Regulator”

Servo Motor

M1 Digital Microcontroller(PD C t l)Optical Voltage Divider (PD Control)Optical Voltage Divider

BDK : 2012-10-26 Page 5MEAM 510 : Balancing Robot Control

Page 7: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

My Other Controls Design Experience

BDK : 2012-10-26 Page 6MEAM 510 : Balancing Robot Control

Page 8: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Simple Mechanics Part 1 : Static Equilibrium

Q=MotorWeight

2r

l

Pin

F= Friction

Q Motor Torque Pin

Shear Force

l

Q=Motor

Shear Force

Normal Force

Weight

FBD of Body

QTorque

Q rFSum Moments @ Center of Wheel

Sum Moments @ Pin in Body sinQ mgl mgl

Sum Forces Parallel to Slope on Both Objects(Pi Sh D O t) sinF Mg Mg

M rm l

BDK : 2012-10-26 Page 7MEAM 510 : Balancing Robot Control

(Pin Shear Drops Out) sinF Mg Mg m l

Page 9: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Simple Mechanics Part 2 : Dynamic Instability

Weight ll

Q=Motor

Technically WRONG 2d

Q=Motor Torque

Technically WRONG but Qualitatively Sort

of Close to Right Dynamics of the Body

2 sindI Q mgl Q mgldt

Main Problem : Gravity is Like a “Negative Spring”If Pendulum Starts Falling, Gravity Makes it Fall Faster

(Control Lawyers Call This a Dynamics Problem Not Disturbance Problem)

BDK : 2012-10-26 Page 8MEAM 510 : Balancing Robot Control

(Control Lawyers Call This a Dynamics Problem, Not Disturbance Problem)

Page 10: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Effects of Proportional Feedback

2

2P PdQ K I K mgldt

• Proportional Feedback Gain Has To Be Large Enough to Create Net Positive Spring (Overcome Open-Loop

dt

Negative Spring)• Beware of Destabilizing Effect of Delay (Due to

Processing Time or Other Dynamics) Processing Time or Other Dynamics)

( ) ( )PQ t T K t P iti @ t+TPosition @ t+T Position @ t

MEAM 510 : Balancing Robot Control Page 9BDK : 2012-10-26

Page 11: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Integral Feedback : A Simple ExampleSame Speed

Requires More Throttle

Example : Cruise Control Encountering a Hill

Proportional Feedback

Integral Feedback

Throttle Change (Solid Lines)No Feedback

Speed Change (Dashed Lines)

MEAM 510 : Balancing Robot Control Page 10BDK : 2012-10-26

Page 12: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Key Observations About Integral Feedback

• To Reach Steady State (Equilibrium), Input to Integral Feedback MUST Be Zero!– This Is Why Integral Feedback is so Powerful!This Is Why Integral Feedback is so Powerful!– This Is Why Integral Feedback is so Peril-ful!

• Integral Feedback is Very Often Destabilizing (Including in This Problem!)

• Integral Feedback Generally Implemented with “Anti-Windup” FeatureWindup Feature– What Happens to Integral Feedback if Car Encounters a Hill That is

Too Steep for the Engine Power to Allow Car to Maintain Constant Speed?p

– Details Can Get Complex & Matter a Lot for Good Performance

MEAM 510 : Balancing Robot Control Page 11BDK : 2012-10-26

Page 13: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Effect of Sensor Alignment• Attitude Sensor Won’t Be Perfectly

Aligned with Line Between Hinge & CG

MCG• Static Equilibrim (See Below)

Cannot Achieve =0! • Even Integral Feedback (Which

Acts Like KPInfinity) Fails!Effect

Exaggerated for Clarity

• Cart ALWAYS Slowly Drifts Away!

Q K K mgl

for Clarity

M P M PQ K K mgl

P PK mgl K

MEAM 510 : Balancing Robot Control Page 12BDK : 2012-10-26

Page 14: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Effect of Slope

• Static Equilibrium (Overall CG Must Be Above Wheel Contact Point) Don’t Want =0!

Point) Don t Want =0!

• Integral Feedback of Cannot Work on a Slope!p

• Could Achieve Static Equilibrium with Exactly Right V l f P ti l G i

Value of Proportional Gain Only, But This Would Not Be Enough for Stability!

M rm l

m l

PQ Mgr mgl K Torque Due to Feedback Must Equal Torque Required to Stay Upright

MEAM 510 : Balancing Robot Control Page 13BDK : 2012-10-26

Page 15: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

What Might Work?

• Human Operator!– Use Wireless To Allow Operator to Command “Lean Angle”– On Level Ground, Operator Cancels Installation MisalignmentOn Level Ground, Operator Cancels Installation Misalignment– On Tilt, Operator Commands Lean Into the Hill– Sufficient to Use PD Only?– System Not Stable Without Operator But Instability Slow Enough to System Not Stable Without Operator, But Instability Slow Enough to

Be Easily Compensated (Many Airplanes & Bicycles Are Like This)

• Use Wheel-Angle Feedback!P b bl W t “D i ti f Wh l A l ” T f St bilit

P WQ K K – Probably Want “Derivative of Wheel Angle” Too for Stability– Arbitrary Steady Torque Can Be Achieved by Small Position Drift

(Wheel Angle Change From Power-On Condition)This Fixes Both Installation Misalignment & Slope Effects!– This Fixes Both Installation Misalignment & Slope Effects!

– If Gains Make System Stable (You Need Equations to Know for Sure), Required Position Drift Happens Automagically!

– Hall Effect Sensor Can Measure Something Like (); Maybe Okay Hall Effect Sensor Can Measure Something Like ( ); Maybe Okay to Use PD Feedback on This?

MEAM 510 : Balancing Robot Control Page 14BDK : 2012-10-26

Page 16: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Measuring Body Angle• Accelerometer Sees Gravity as Negative

Acceleration (General Relativity)• But Accelerometer Also Sees Local Linear

But Accelerometer Also Sees Local Linear Acceleration (Due to Wheel Movement & Angular Acceleration Times Moment Arm) Accelerometer Has “Noise”, Especially at High Frequency

a

2

2 sinwheelda a r gdt

• Body Angle Can Also Be Estimated by Integrating Angular Velocity, But This Will Drift (Because Angular Velocity Won’t

dt

Drift (Because Angular Velocity Won t Read Exactly 0 at Rest) (0) ( )

t

d MEAM 510 : Balancing Robot Control Page 15BDK : 2012-10-26

0

Page 17: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Complementary Filter : Combine a &

• Basic Idea– Use Integral of angular velocity at high frequency (where a is noisy)– Use (-a/g) at low frequency (where drift of angular velocity is bad)Use ( a/g) at low frequency (where drift of angular velocity is bad)

Theta =High Pass Filter

Of +Low Pass Filter

Of

• Need Digital Implementation of Integral & Filters

Theta OfIntegral of

Of(-a/g)

g p g

ˆ ˆ 1i i i t

ˆˆ Integrate

Hi h P

Combine

1 1i i i i

1ˆ ˆ 1 /i i ia g

i i i High-Pass

Low-Pass

MEAM 510 : Balancing Robot Control Page 16BDK : 2012-10-26

1i i i g

Page 18: Balancing Robot Controlmedesign/wiki/... · Bruce D. Kothmann. Agenda • Bruce’s Controls Resume • Simple Mechanics (Statics & Dynamics) of the Balancing Robot ... M1 Digital

Miscellaneous Implementation Issues• Scaling of accelerometer voltage into A/D: you really only care

about +/- ~5 deg, so make sure that range is 0 to 5 volts so you make good use of your 10-bit A/D (1024 Values)

build a simple op-amp circuit?

• Very high processor speeds may cause problems, because digital Very high processor speeds may cause problems, because digital filters may require very high precision. Also, digital filters are easiest to design with a fixed frame rate. MATLAB has a very convenient “C2D” function for converting analog filters to digital. g g g

Do you need to go faster than ~1000 Hz?

• I told a couple of lies earlier—motor friction might allow • I told a couple of lies earlier—motor friction might allow proportional feedback to work on level ground & carpet might allow equilibrium on small slopes! But these effects are very unreliable (low robustness) Control designer wouldn’t

MEAM 510 : Balancing Robot Control BDK : 26-Oct-2009 : Page 17

unreliable (low robustness) Control designer wouldn t generally accept a design that exploited these effects

BDK : 2012-10-26