Control Theory Introduction
Control Theory Introduction
informal
overview of
control theory
And how to control a FIRST robot
Anatomy of a
Robot
Electromechanical parts of Interest
Stepper Motor
Input: Power
(Voltage)
Encoders – usually automatically
attached to Servos
• Two types
• Absolute
• Not used often, especially within FRC
• Relative
• Most common in FRC, What is
installed in our ‘23 robot
• You use “magnetic encoders”—Less
good than optical
• Measures distance by counting
“Pulses” can identify directions
• FIRST calls this “Odometry”
• “Route measuring”
What do encoders look like for our purposes
• Top- Cancoder
• CTRE
• Communicates using CAN bus
• Bottom Right- SRX Mag Encoder
• CTRE
• Communicates via pulse width
modulation PWM
• Bottom Left –Through bore Encoder
• Rev Robotics
• PWM
Controller–
Robo RIO
• The “Big Brain” of the robot
• Handles all input and output via
• Digital inputs/outputs
• Pulse width modulated inputs/outputs
• Analog inputs
• Relays
Encoder
Spark Max Motor
Robo RIO
Controller
Servo motor
Battery
“But the Kraken/Falcon/Sparks/etc. don’t
have Encoders/Controllers”
What is control
theory?
Introduction to classical control
principles
Control Theory
• The field of controlling dynamic
systems
• Identify a goal, and use electrical,
mechanical, and computer systems
to reach said goal
• Examples
• Cruise Control
• Thermometer
• Heat seeking missiles
• Segways ( invented by the founder
of FRC)
Terms to know
What is a system? Its whatever. We don’t care
• Anything that takes a signal in,
modifies it, and produces a
measurable output
• Examples include
• Cars
• Stoves
• Doors System/Plant
output
Open Loop Control: No feedback
• Example case: Wind up car
1x rotation
• Input: wind up torque
• System/plant: car
• Output: distance
• We can calculate the
relationship between input-
1.25 feet
torque and output- distance
• E.g. 1 turn = 1.25 feet
Open Loop control limitations
• Wind up the car 3
times, how far will it
go? 3x rotation
Wanted Position
Error Pressed Gas Pedal
(brainwaves)
- (wanted position-actual position)
Driver Real car
Distance
Brain waves
Eyes
Additional benefits of a controller
• They make unstable things
stable.
• Responsive to environments
• Increase performance.
• How do you make my ‘89 ford
Tempo function like a
Maserati?
• Essentially like replacing the
little old lady driver with a
racecar driver
PID controller
How do I make a controller?
What is a PID
Controller
WPILIB, CTRE, Rev
robotics already did
the math
What is proportional control, intuitively*
• Imagine our goal is to move
blocks from point A to Point B
• The size of the block is
representative of the error of
the system
• If block is big, we send big guy
• If block is small, we send small
guy
• *this is obviously a simplification
What is Integral control, intuitively
• Sometimes P won’t work (the
block gets stuck on a rock for
example)
• By measuring the history of the
blocks movement
measures all of the missed goal
posts and sends Integral terms
to help
• Because it’s the summation of all
past actions, the small Integral
gains “I” can add up fast
Integral Windup, What is it?
• If the controller can’t reach its
goal, the error will add up and
the integral term will get bigger
• Something has to give, the
obstruction, or the system
• If it’s the obstruction, the system
will leap forward
• If it’s the system the system
(motor, frame, gear) will break
What is a Derivative Control, Intuitively?
( )
• looks forward to where he
thinks the system will be
• He predicts the systems movement
by how fast the system accelerates Slow Down!
We are
• He sends the derivative terms to almost there
address future changes
• Can change size very rapidly
• Can be very big or very small
• Derivatives are “noisy” too much D
will cause “Chatter”
How to choose the PID constants
1. Set I and D to zero
2. Start out with a small P value
3. Give the system a reference point
4. Double the P value until the system
starts to oscillate/go unstable
5. Halve the P value and slowly creep
up until you oscillate stably
6. Slowly bring up the I value until the
oscillations disappear
7. Increase D to make the response
faster
Feed
Forward
control and
Disturbances
But Mr. Luke, I need it to go
faster/better/more accurate
Mechanism models (According to WPILIB)
• Motor
• kS
• kV
• Voltage needed to break friction/operate at all Motor
• Voltage needed to maintain speed
• kA
• Voltage needed to change speed
• Elevator/Arm Elevator
• kG
• Voltage needed to overcome Gravity
• Other Terms
• d,𝑑̇ ,𝑑̈
• V
• distance/velocity/acceleration based on number of dots
Arm
• Output voltage
• Sgn
• Sign of the equation (positive or negative
• Θ
• angle
What tools do we have
• WPILIB has a SYSID library
• It doesn’t work great
• 2928 has a walkthrough which
may work better?
• CTRE’s Phoenix Tuner?
• Research more options
• Or build our own!
• https://2928-frc-programmer-
• Last years solution training.readthedocs.io/en/lates
• Guess and check! t/Romi/Control/romiSystemId/