A DC- Motor Micromouse

Download Report

Transcript A DC- Motor Micromouse

A DC-Motor Micromouse
Dr. Tony Wilcox
Technology Innovation Centre
Birmingham City University
Micromouse at TIC
Micromouse at TIC evolved as a mechanism to enthuse and engage
students more fully in the practical aspects of designing real-time
embedded systems.
Traditionally, Embedded Systems has been taught using static target
boards – flashing LEDs, reading sensors, “traffic-light” controllers etc., and
little else.
Mobile robots bring in motor drives, positional encoders, real-time systems,
closed-loop control theory, and most importantly of all, real-world problems.
Mobile Robots becomes “Electronics on Wheels”
Key mouse components
There are many elements that must come together in a mouse build.
•
Mechanics: chassis, drive system, motors, wheels
•
Power supply: batteries, regulators, charger
•
Power electronics: H-bridge for DC or Stepper motor drive
•
Sensors and signal conditioning electronics for sensing walls
•
Encoders for position, speed, acceleration measurement and control
•
Comms interface for programming and/or debugging
•
A controller: microprocessor, microcontroller, or custom logic
Software
For real-time software applications look no further ....
•
Speed and Position measurement: multi-source interrupts
•
Motor Speed and Positional control : P, PD or PID
•
Mouse Position/Velocity/Acceleration profiling
•
Rotational/Traction Control :additional sensors - accelerometers,
gyros
•
Orthogonal tracking: in-place turns (rotation), smooth turns – 90,180
degrees
•
Diagonal tracking: 45, 90,135,180 degree in-place and smooth turns
•
Maze Mapping: multi-sensor data acquisition and analysis
•
Maze Solving: Flooding algorithms
HEREtic:
A low cost DC mouse
The aim of HEREtic was to develop a low-cost, DC motor driven,
autonomous mobile robot that would be a versatile educational tool, as
well as a competitive maze solver.
The key objectives were that it would:
•
have sufficient capability to be a micromouse wall-follower and mazesolver
•
be able to function in other non-micromouse environments (long-range
sensors, rf links)
•
provide a reference design for a new influx of mouse-builders.
Mechanics
The mechanical design and build is usually the stumbling block ...
•
Compact chassis 75mm wide by 130mm long (diagonals?)
•
PCB used as structural element i.e. the chassis (cost)
•
‘Wheelchair’ drive – 2 motors, 2 wheels independently driven
•
Spur and Pinion gearing for higher torque, lower speed, ‘controllability’
•
Low cost DC motors (VCR)
•
Sensors at 30, 60, 120, 150, 210, 240, 300, 330 degrees
•
43mm wheels with ‘O’ ring tyres
•
Laser-printed encoder disk direct mounted on motor shaft
•
Front and rear skids to minimise rocking
Design and Build
•
Designed using a 3D CAD package
– forces an assessment of all mechanical aspects
– reduces conflicts/errors in component placement
– can produce a 2D drawing for import as a mechanical layer on
PCB, reducing electronic/mechanical component conflicts.
– simplifies positioning of fixing holes, cutouts, pillars etc.
•
Machining kept to a minimum
– used COTS aluminium angle for motor mounts
– used COTS gears, nylon washers
– Laser-printed acetate encoder disks
– Stub axle machined from mild steel rod, but can be made from
COTS tube plus bolts.
Base Assembly
HEREtic model
Electronics
Plenty of room to show your elegance here – or not ......
•
8 IR phototransistors , 8 matching IR emitters
•
2 additional IR emitters at 0,180 degrees for ranging with
forward/reverse facing sensors
•
2 - I2C sensor ports at 0,180 degrees for long-distance ranging
using ultrasonic sensors or triangulation IR sensors.
•
All IR phototransistors multiplexed through one signal conditioning
circuit – giving good channel matching, ambient cancellation and
sample-and-hold.
•
Low cost L293 dual H-Bridge motor driver.
•
PLD used to enable either locked-antiphase or sign-magnitude
pwm.
•
RF and wired RS232 comms.
•
ICD connection for debugging.
Base-board schematic
Top-board schematic
Base PCB with overlay
Top PCB with overlay
HEREtic prototype
Development Tools
A selection of development tools used for HEREtic.
•
Protel and Orcad for PCB design and circuit simulation
•
Solidworks for 3D/2D CAD
•
Coreldraw for the encoder disks
•
Quartus II and WARP to simulate and synthesise VHDL for the PLD
•
MPLAB IDE with MCC18 compiler
•
MPSIM source-level code simulation
•
ICD2 and wired-RS232 for debug on the bench
•
RF link for ‘run-time’ RS232 debug
OK, so we’ve got hardware...
Embedded microprocessor systems need software to function some key software elements are:
•
•
•
•
•
•
Real-time measurements: wheel speed and position, wall sensors,
battery voltage etc.
Real-time motor control using appropriate sensor feedback
Navigation algorithms
Mapping algorithms
Solving algorithms
User interface (RS232 radio link, on-board LCD, LEDs)
DC motor control
A typical micromouse motor-wheel arrangement is the ‘wheelchair’ drive.
DC motors need a geartrain to reduce speed
and improve torque
SENSOR
DRIVER
MOTOR
CONTROLLER
DRIVER
SENSOR
MOTOR
The wheels are
independently driven,
though most often the
motors share the same
controller.
Skids or castors on the
front and rear limit rocking.
The control loop
A block diagram can be used to represent the control loop implemented
by the controller.
SENSOR
MEASURED
SET
SET
+
e = error
R=drive
MOTOR
GAIN
e = error
+
R=drive
GAIN
MOTOR
MEASURED
SENSOR
OUTPUT
The error between desired
and actual is calculated,
and the value of the error
determines the drive
applied to the motor.
OUTPUT
Duplicate the control
loop for the other motor.
Straight line?
One would think that the system discussed would follow a perfect
straight line.
DRIVER
MOTOR
DRIVER
MOTOR
CONTROLLER
It doesn’t !
This is due to slight difference between the drive-trains, and to an
imperfect control system limited by what is termed the ‘steady state error’.
Proportional Control
If the GAIN is a constant, K, then we have:
R = drive
R(t) = K * e(t)
e = error
The drive is linearly proportional to the error, and so this is termed
proportional control.
R(t) = Kp * e(t)
where Kp is the proportional gain of the controller
Steady State Error
SET
k=0.8
Steady state error
k=0.6
k=0.4
k=0.2
Time
We will always have a steady state error with a proportional controller
R(t) = Kp * e(t)
or the discrete form
Rn = Rn-1 + Kp * (en - en-1)
If the error reduces to zero, there is no drive to the motor, therefore
the error can never be zero.
‘Three-Term’ PID control
Simple proportional control has significant limitations –
We can overcome these by the use of three gain terms:
proportional, integral, derivative  PID
P
SET
+
e
-
+
+
+
I
R=drive
OUTPUT
MOTOR
D
MEASURED
SENSOR
With these three terms we can ‘tune’ the response of the system,
reducing rise time, overshoot, and steady-state error
The Derivative Term
SET
Kd
Kp
Time
The derivative is the rate of change – adding this term increases the
speed of the response, but with the same steady state error.
R(t) = Kp * ( e(t) + Td * de(t)/dt )
Rn = Rn-1 + Kp * (en - en-1) + Kd * (en – 2en-1 + en-2)
The Integral Term
SET
Zero steady
state error
Ki
Kd
Kp
Time
The addition of the integral term sums the error over time, reducing the
steady state error to zero
R(t) = Kp * ( e(t) + 1/Ti * ∫e(t)dt + Td * de(t)/dt )
Rn = Rn-1 + Kp * (en - en-1) + Ki * (en + en-1)/2 + Kd * (en – 2en-1 + en-2)
Code example
You might think that the code for a PID loop would be complex and unreadable:
void PID (void) {
current_error = desired_speed – measured_speed;
pwm_duty = pwm_duty
+ KP * (current_error - last_error)
+ KI * (current_error + last_error)/2
+ KD * (current_error - 2*last_error + last_but_one_error);
last_but_one_error = last_error;
last_error = current_error;
}
Is it? ............
Control theory is just one of the many areas that must be learned, applied,
understood in order to persuade a micromouse to give its all Most of us get by with hand-waving and reading code examples ....!
Summary : Skills
The design, build, and programming of a micromouse requires multidisciplinary skills.
It provides the opportunity for :• an individual student to develop broad technical skills in new areas
or
• the development of team-working skills amongst a group of
mechanical, electronic, and embedded software students.
( Of course, the same skills will be gained by employees who are
encouraged to get involved with micromouse ..... )
Summary : Skills
A complete Micromouse design demands expertise in :
• Mechanical design: statics and dynamics
• CAD for chassis, drive train, integration with electronic subsystems
• Analogue and digital electronic design
• Embedded microprocessor design
• Printed Circuit Board design/ prototyping skills
• Real-time embedded software development for uP, uC, SOC or
DSP
• Control system design
HINT: many components and some mice are available commercially ....!
What everyone wants ….