Ng Beng Kiat Taiwan2009 1
Introduction
Does not cover microcontroller
Demo
Body design Physics
Sensor & Alignment
PID control --
Speed Profile
DC Motor sizing
DC Motor driver
Battery
Search Algorithm???
Ng Beng Kiat Taiwan2009 2
Photo of top and bottom of Min5
Ng Beng Kiat Taiwan2009 3
Minimum mechanical design & construction PCB used as robot body () PCB is tough and strong Good soldering to withstand crash Sensors must be well supported (hot glue )
Ng Beng Kiat Taiwan2009 4
DEMO
Ng Beng Kiat Taiwan2009 5
1.0 Body Design Physics ()( )
Centre of gravity & weight transfer
Moment of inertia ()
Robot weight () heavier or lighter?
Robot wheel () bigger or smaller?
Ng Beng Kiat Taiwan2009 6
1.1 Centre of gravity & weight transfer (&)
When Robot is not accelerating/decelerating, all weight is on tires
If there is no weight on tires -> no grip
Acceleration () () High c.g.
x d
Weight on tire
= (robot weight)(d-x)/d
Reaction ()
Mouse weight
Resultant force
Fig 1: Weight transfer when accelerating
weight transferred here
Ng Beng Kiat Taiwan2009 7
Lighter or slimmer motors to lower c.g.
More weight on tires, hence more grip for acceleration
Resultant force acts through c.g.
acceleration() Lower c.g.
x d
Weight on tire
= (robot weight)(d-x)/d
reaction
Resultant force
Fig 2: Weight transfer when accelerating (low cg)
x is smaller
Ng Beng Kiat Taiwan2009 8
Stepper motor based micromouse has high c.g.
Has a higher tendency to roll over if cornering at high speed. ()
Always keep the robot c.g. as low as possible
Make robot as wide as possible () Make your robot like F1 car
Fig 3 : Weight transfer when cornering()
Centrifugal force = (vv)/(2r)
Resultant force
Ng Beng Kiat Taiwan2009 9
1.2 Moment of inertia ()
High moment of inertia
motor
r
I = mr2
m = motor weight
r
motor
Low moment of inertia
Ng Beng Kiat Taiwan2009 10
When moment of inertia is high, rotational acceleration () is
reduced for the same torque .
Torque = I (F = ma)
() = ()
Keep heavy parts like motors, battery etc as close to robot centre as possible
()()
If moment of inertia is high, stronger motor is required, -> bigger battery
too!
Ng Beng Kiat Taiwan2009 11
1.3 Robot weight ()
Question : Does a heavier mouse provides more acceleration (has more grip )? Question: ()?
Force (Newton) = mass(kg) acceleration(m/s2)
Ng Beng Kiat Taiwan2009 12
Force available to propel the robot forward depends on motor power
and friction force .
If motor is powerful enough, then friction is the limiting factor ()
Friction force = FN u u = coefficient of friction FN = mass g
g = 9.8 m/s2
tire
Ng Beng Kiat Taiwan2009 13
If motor exerts a force greater than friction force, tires will skid ().
To prevent skidding, driving force < friction force
o Friction = FN u = mass g u
o Therefore acceleration limit = gu
o If u=0.7, then acceleration limit is about 7m/s2.
u = 0.7 7m/s2
Acceleration is independent of mass. Limited by tires.
Keep robot weight low -> reduce motor size -> reduce battery capacity.
Ng Beng Kiat Taiwan2009 14
1.4 Robot wheel
Question : A bigger wheel or a smaller wheel?
Tire friction is reduced by dirt ()
Clean tires before run
A smaller wheel would need to rotate more times for the same distance o Pick up more dirt() o If maze if dirty, performance will be affected
Bigger wheels raise the c.g. ()
Ng Beng Kiat Taiwan2009 15
Weight of wheels and shaft affect the robots c.g. Keep wheels & shaft as light as possible
Use light and thin material if possible
Lower c.g. higher c.g.
Smaller wheel, lower c.g. Bigger wheel, lower c.g.
Ng Beng Kiat Taiwan2009 16
Big wheel will roll easily over steps or humps()
Hump or step Hump or step
Ng Beng Kiat Taiwan2009 17
Wider wheel will also be less affected by unevenness. ()
On a flat and clean surface, tire diameter and width has negligible impact on performance. ()
Too wide and its hard to turn
A bigger surface allows the wheel to
ride over unevenness
Ng Beng Kiat Taiwan2009 18
1.5 Four wheel drive ?
During acceleration, weight is transferred to back wheels (
)
During deceleration, weight is transferred to front wheels Good for straight acceleration/deceleration ()
Complex and hard to build ()
My dream mouse !!!
c.g.
x
More weight Less weight
acceleration
Ng Beng Kiat Taiwan2009 19
1.6 Skid Pads
Skid pad (Teflon)
Must be rocking
1mm
Wheels on floor
Wheels hanging in
the air
Ng Beng Kiat Taiwan2009 20
2.0 Sensors & Alignment
Side sensor
Front sensor
Diagonal sensor
Figure: Mouse sensors layout
receiver
transmitter
shield
Ng Beng Kiat Taiwan2009 21
2.1 Sensor circuit and operation
Left and right front sensors pulsed separately to avoid interference
Figure : Transmitter circuit diagram
IR LED
LeftFront
diagonal
side
rightFront
Ng Beng Kiat Taiwan2009 22
Figure : Receiver circuit diagram
Ng Beng Kiat Taiwan2009 23
Tx1
Rx1
Tx2
Rx2
From Tx2
Figure : Timing diagram of sensors signals()
Ng Beng Kiat Taiwan2009 24
IR LED
Pulsing allows higher current to swarm interference () LED on < 10% of time only -> can stand higher current
Pulsing minimize interference from neighbouring sensors
Receiver should be less sensitive -> allows high transmitter output ()
Improve signal noise ratio
Ng Beng Kiat Taiwan2009 25
2.2 Alignment
Direction offset
Centre of cell
Lateral offset
Longitudinal offset
Figure: Types of positional error
Ng Beng Kiat Taiwan2009 26
Figure: Correcting direction & lateral offset with diagonal sensor ( 45 )
if( (LALIGN_SEN_VALUE > laSenV3) && (RALIGN_SEN_VALUE < raSenV3)) {
//Too left, adjust right
alignSpeed= (LALIGN_SEN_VALUE - laSenV3)*maxAlignSpeed/laNearLeftRange ;
}
else if( (RALIGN_SEN_VALUE > raSenV3) && (LALIGN_SEN_VALUE < laSenV3) ) {
// Too right, adjust left
alignSpeed = -(RALIGN_SEN_VALUE - raSenV3)*maxAlignSpeed/raNearRightRange);
}
LALIGN_SEN_VALUE
RALIGN_SEN_VALUE
Ng Beng Kiat Taiwan2009 27
*Almost all turns are preceded by a pole to no-pole transisition
Threshold
eve
Readjust position
Figure: Correcting longitudinal offset with pole detection ()
Assumption :
Lateral and angular offset
is small.
Ng Beng Kiat Taiwan2009 28
Start of turn end of turn
Use front sensors to adjust
position before turn
Figure: Correcting longitudinal offset with front wall (exploration) ()
Calibrate sensor here
Ng Beng Kiat Taiwan2009 29
Collision avoidance
Detect pole to adjust
position()
Not use in diagonal run
Figure: Diagonal run. Collision avoidance and position adjustment
Ng Beng Kiat Taiwan2009 30
3.0 Speed Profile
Rotational speed(wSpeed)
Translational speed (xSpeed)
leftWheelSpeed = xSpeed wSpeed; rightWheelSpeed = xSpeed + wSpeed;
Figure : Speed components of a 2 wheels robot
Ng Beng Kiat Taiwan2009 31
3.1 Two basic speed profiles
Translational speed
Parameters
Top speed
Acceleration/deceleration
End speed (= curve turn speed)
Distance
Time(s)
Speed (m/s)
Top
speed Acceleration/
deceleration
end speed
Ng Beng Kiat Taiwan2009 32
Rotational speed ()
3.2 Basic movements
Diagonal & non-diagonal straight runs (wSpeed=0)
Pivot turns (xSpeed=0) ()
Curve turns 90, 180(U), 135(J), 45,V(xSpeed=constant, + wSpeed)
Time(s)
Speed (deg/s)
Top
speed Acceleration/
deceleration
Ng Beng Kiat Taiwan2009 33
45 degrees (x4)
90 degrees(x4)
180 degrees(x2) 135 degrees (x4)
Ng Beng Kiat Taiwan2009 34
V turn (x2)
Ng Beng Kiat Taiwan2009 35
Time(s)
Speed(m/s)
Outer wheel
Inner wheel
Figure : Curve turn speed profile
end
start
Ng Beng Kiat Taiwan2009 36
3.3 Profile generator and PD loop
No integral term
PD control & Profile generator is executed every msec PWM frequency is 10kHz PWM duty cycle = kp errorn + kd (errorn-errorn-1)
PD -
+ -
Profile
Generator
error speed
PWM
encoder signals
Figure : Profile generator and PD loop
Set topSpeed,
endSpeed,
acceleration, distance
motor
Ng Beng Kiat Taiwan2009 37
3.4 Straight speed profile C code
// At the beginning of profile, targetSpeed = topSpeed;
// Keep checking for deceleration condition
void SpeedProfile() {
decelerationRequired = (curSpeed2 endSpeed2)/(2distance);
if (decelerationRequired>deceleration) targetSpeed = endSpeed;
if (curSpeedtargetSpeed) curSpeed -= deceleration;
distance += curSpeed;
}
distance - ; curSpeed -; endSpeed - ; acceleration - ; deceleration -
Ng Beng Kiat Taiwan2009 38
Time(s)
Speed(m/s)
Figure : Speed profile
t2 t1
s2
s1
d
A
B
Calculating deceleration:
A+B = (S1t2)/2
B = S2(t2 - t1)/2
d = S1/t2 = S2/( t2 - t1)
o t2 = S1/d o (t2 - t1) = S2/d
A = (S1t2 )/2 -B = (S1t2)/2 - S2(t2 - t1)/2
= (S12- S2
2)/2d
d = (S12- S2
2)/2A
Ng Beng Kiat Taiwan2009 39
3.5 PD loop and gyroscope
PD + -
Straight
Profile gen
xError xSpeed left
Figure : rotational and translation control loop
PD + -
Curve turn
Profile gen
wError wSpeed right
(R-L)/2 or gyro
+ -
+ +
(R+L)/2
L
R
alignSpeed
leftSpeed = xSpeed wSpeed; rightSpeed = xSpeed + wSpeed;
xSpeed = (rightSpeed+leftSpeed)/2
wSpeed = (rightSpeed-leftSpeed)/2
Ng Beng Kiat Taiwan2009 40
Gyro is fast in response
Accurate for fast curve turn (not for very slow turn) / opposite of optical encoder
Need to calibrate before run due to DC drift ?
Not affected by tires size change
Ng Beng Kiat Taiwan2009 41
4.0 DC motor sizing
Step 1 : Calculate maximum power required
Force(N) = mass(kg) acceleration(m/s2) =
o Desired acceleration = 7 m/s2 // experience required
Time(s)
Speed (m/s)
7 m/s2
3
7 m/s2
Maximum power
Ng Beng Kiat Taiwan2009 42
Force = 0.12kg 7m/s2 = 0.84N
Power (W) = force(N) speed(m/s) ( = )
Maximum power is required when robot is accelerating at 7 m/s2 near top
speed = 3m/s.
Max power required = 0.84N3 m/s = 2.52 watt.
Since there are 2 motors, power required per motor = 1.26 W.
Step 2 : Select motor (Faulhaber 1717SR)
Choose a motor with maximum Power 1.5 times to 2 times 1.26W = 1.89W
to 2.52 W,
Which is less than the Pmax of 1.96 W (Faulhaber 1717SR).
Ng Beng Kiat Taiwan2009 43
Note that I also overdrive the motor. 2x Lithium Polymer = 8.4V. Average
around 7.8 volts
Maximum power out at 7.8 V = (7.8/6)2 1.96 = 3.3 watts
Step 3 : Select gear ratio
Calculate torque and speed
o Tires diameter is 24mm
o Torque required = Forceradius ( = )
Ng Beng Kiat Taiwan2009 44
= 0.84N 12mm = 10.08 mNm
o Torque required per motor = 5.04mNm.
o Wheel circumference = Pidiameter = 0.0754m
o At 3m/s, wheel revolution = speed/circumference
= 3/0.0754m = 39.8 rps = 2387 rpm
Therefore, near top speed, motor must be able to provide torque output of
5.04mNm at speed of 2387 rpm.
Ng Beng Kiat Taiwan2009 45
Speed rpm
Torque mNm 5 10 15
14000
Figure : DC motor speed-torque characteristic
Accelerating
5.04mNm
Top speed
2387 rpm
Max power 1.96W Speed (m/s)
7 m/s2 7 m/s2
Ng Beng Kiat Taiwan2009 46
Speed rpm
Torque mNm 5 10 15
14000
7000
4667
1:1
3:1
Figure : DC motor speed-torque characteristic
12
32
Gear ratio 2:1
Accelerating
5.04mNm
Top speed
2387 rpm
Max power 1.96W
Ng Beng Kiat Taiwan2009 47
There is a range of gear ratio to select from
The higher the gear ratio, the more energy efficient the motor is.
Allows spare power for alignment
Prefer long & slim motors to short and fat motor. Lower c.g.
Ng Beng Kiat Taiwan2009 48
4.1 DC motor driver
MOSFET driver motor driver
Pull up
Figure : Min5 motor driver circuit
-Choose low turn-On resistance MOSFET
-Pull up input to prevent conduction
Ng Beng Kiat Taiwan2009 49
User interface Need feedback to tell what the mouse is doing
LED lights
Sound
Menu driven (dotmatrix display & input switch)
Websites Visit my website at www.np.edu.sg/alpha/nbk
(A* Pathfinding ) http://www.policyalmanac.org/games/aStarTutorial.htm
(Nakashima website) http://homepage1.nifty.com/hfd01577/index.html
(Pete Harrison) http://micromouse.cannock.ac.uk
Good Luck!