ee401-3!2015 embeddedsystems
DESCRIPTION
EE401-3-2015-EmbeddedSystemsTRANSCRIPT
EE401. Engineering Design by
Teams: Robotics 1
Lecture 2. Embedded Systems
for Robotics
Instructor: Huynh Viet Thang
Aug. 2015
1
• Textbook: • T. Bräunl Embedded Robotics, Springer 2003
• The University of Western Australia, Electrical,
Electronic and Computer Engineering
Based on the materials of Prof. Marek A. Perkowski
Intelligent Robotics Laboratory
Portland State University
2
What are in this lecture?
• Embedded systems
• Robots and Controllers
• Sensors
• Actuators
• Control techniques
3
4
Embedded systems
5
Definition for Embedded System
• A combination of hardware and software which together form a component of a larger machine.
• An example of an embedded system is a microprocessor that controls an automobile engine.
• An embedded system is designed to run on its own without human intervention, and may be required to respond to events in real time.
• Source: www.computeruser.com/resources/dictionary
6
Applications Areas
7
Application Areas• TV• stereo• remote control• phone / mobile phone• refrigerator• microwave• washing machine• electric tooth brush• oven / rice or bread cooker• watch• alarm clock• electronic musical instruments• electronic toys (stuffed animals,handheld toys, pinballs, etc.)• medical home equipment (e.g. bloodpressure, thermometer)• …• [PDAs?? More like standard computer system]
Control Applications; Consumer Products
8
Application Areas
• Medical Systems– pace maker, patient monitoring systems, injection systems,
intensive care units, …
• Office Equipment– printer, copier, fax, …
• Tools– multimeter, oscilloscope, line tester, GPS, …
• Banking– ATMs, statement printers, …
• Transportation – (Planes/Trains/[Automobiles] and Boats)
• Radar, Traffic lights, Signalling systems, …
9
Application Areas• Automobiles
– engine management, trip computer, cruise control,
immobilizer, car alarm,
– airbag, ABS, ESP, …
• Building Systems
– elevator, heater, air conditioning, lighting, key card
entries, locks, alarm systems, …
• Agriculture
– feeding systems, milking systems, …
• Space
– satellite systems, …
10
Application Areas
• Facts:– 1997: The average U.S. household has over 10
embedded computers (source: www.it.dtu.dk/~jan)
• 1998: 90% Embedded Systems vs. 10% Computers– (source: Frautschi, www.caliberlearning.com)
• 2001: The Volvo S80 has 18 embedded controllers and 2 busses (source: Volvo)
11
Automobiles
12
13
14
Microcontrollers
15
Von-Neumann vs. Harvard
16
Microcontrollers
• Microprocessor– CPU (on single chip)
• Microcontroller
• CPU + Timers + I/O (+RAM) (+ROM)• Reduced chip count for board design
• Embedded system
• Today’s Technology:
– Surface Mount Device (SMD)
– Ball Grid Array (BGA)
17
Input and Output• Required to communicate with outside world
• PC System:– Keyboard
– Monitor
– Parallel port (printer port)
– Serial port + USB
• Embedded System:– Sensors (e.g. in automobile: acceleration sensor, seat
sensor)
– Actuators (e.g. in automobile: valves for airbags)
18
Input and Output
• Input / output device implementation can be:
• • Memory-mapped
• • I/O mapped (ports)
• • DMA (direct memory access)
19
20
21
Assignment
• You are required to design the controller (as an
embedded system) for a consumer product,
describe the system (give the specification) if the
product is
A) an air-conditioner
B) a washing machine
C) a smart TV
D) a smart phone
22
23
Robots and Controllers
What are the advantages of using mobile robot
systems as opposed to traditional ways of
education, for example mathematical models
or computer simulation?
3 advantages
• Students can relate to a robot much better than to a
piece of software; tasks to be solved involving a robot
are of a practical nature and directly “make sense” to
students;
• A working robot program will be a robust system that
takes into account and overcomes inaccuracies and
imperfections: a valid engineering approach to a typical
(industrial) problem;
• Mobile robot programming is enjoyable and an
inspiration to students;
24
Mobile robots
• A case study from the
Mobile Robot Lab at the
University of Western
Australia [Braunl 2006]
• “EyeBot family” using
“EyeCon”
– Wheeled robots
– Tracked robots
– Legged robots
– Flying robots
– Underwater robots
25
An example: Wheeled Robot
• Require 2 motors for driving and steering
• Differential Drive is the most commonly used mobile
robot design
Driven and steered wheel Driven wheels Driven wheels
Steered wheels
Differential Drive “Ackermann Steering”Single Drive
26
Braitenberg vehicles
• A conceptual abstraction of actuators, sensors, and
robot control by Braitenberg (1984)
– Simple interaction between motors and sensors
– If a light sensor is activated by a light source, it will proportionally increase the speed of the motor it is linked to.
• Braitenberg vehicles avoiding light
• How does it work?
Light source
27
Braitenberg vehicles (cont.)
• Braitenberg vehicles searching light
Light source
28
Embedded controllers
• The EyeCon: 32-bit CPU
• “RoBIOS” (Robot Basic Input Output System) operating
system
• What are the advantages of using 32-bit CPUs vs. Using
8-bit CPUs? 29
30
RoBIOS
31
32
Sensors
What is important is to find the right sensor for a particular application.
Overview
• Data transfer from the sensor to CPU
– either CPU-initiated (polling)
– or sensor-initiated (interrupt)
33
Sensor categories
• Based on sensor output
34
Other sensor classification
35
Binary sensor
• Simplest
• Easy to design
• Active low in
this example
• What if “active high”?
36
Analog vs. Digital sensors
• A number of sensors produce analog signals,
A/D converter is required
– Microphone
– Analog infrared distance sensor
– Analog compass
• Digital sensors are usually more complex and
more accurate than analog ones
37
Synchronous serial interface
• “synchronous serial” means that the converted
data value is read bit by bit from the sensor
38
Shaft encoder
• Encoder is fundamental feedback sensor for
motor control
• Magnetic encoders and Optical encoders
• Incremental encoders:
– Count number of
segments passed from
a certain starting point
– Not sufficient to locate
a certain absolute position
39
Gray code disk
• help locate a certain absolute position
• How to determine orientation of the motor?
– use 2 sensors (magnetic or optical) positioned with a
small phase shift to each other (see previous slide).
40
Other sensors
• Sonar (ultra-sound)
• Infrared sensors
41
Other sensors (cont.)
• Compass,
• Orientation sensors– Gyroscope: rotational change of orientation about one axis
– Accelerometer: acceleraion along one axis
– Inclinometer: absolute orientation angle about one axis
• Digital Camera
• Microphone
42
43
Actuators for Robots
Actuators are used in order to produce mechanical movement in robots.
Slides from Braunl and Jussi Suomela
Actuators• Motor and Encoder
• H-Bridge
• Pulse-Width-Modulation (PWM)
• Servos
• Other robotic actuators
44
45
Actuator Types• Electrical
• Hydraulic
• Pneumatic
• Others
• Actuators can be built in may different ways, most prominently:– electrical motors– pneumatics and valves.
• we will only deal with electrical motors
46
DC-Motors• simple, cheap
• easy to control
• 1W - 1kW
• can be overloaded
• brushes wear
• limited overloading
on high speeds
DC-motor control
• Controller + H-bridge
• PWM-control
• Speed control by controlling motor current=torque
• Efficient small components
• PID control
47
H-Bridge
48
49
H-Bridge• Hardware Implementation with
Microcontroller:
• 2 Digital output pins from microcontroller,
[one at Gnd, one at Vcc] feed into a power amplifier
• Alternative: use only 1 digital output pin plus one inverter, then feed into a power amplifier
50
Stepper Motors
51
52
Reluctance (Stepper) Motors
• angle control
• slow
• usually no feedback used
• accurate positioning
• easy to control
Stepper Motors• Stepper motors are another type of motors that do not require feedback
• A stepper motor can be incrementally driven, one step at a time, forward or backward
• Stepper motor characteristics are:– Number of steps per revolution (e.g. 200 steps per revolution = 1.8°
per step)– Max. number of steps per second (“stepping rate” = max speed)
• Driving a stepper motor requires a 4 step switching sequence for full-step mode
• Stepper motors can also be driven in 8 step switching sequence for half-step mode (higher resolution)
• Step sequence can be very fast, the resulting motion appears to be very smooth
53
54
55
Stepper Motors
• Advantages– No feedback hardware required
• Disadvantages– No feedback (!)
Often feedback is still required,
e.g. for precision reasons, since a stepper motor can “lose” a step signal.
• Requires 2 H-Bridges plus amplifiers instead of 1
• Other– Driving software is different but not much more complicated
– Some controllers (e.g. M68332) support stepper motors in firmware (TPU)
56
Motor and Encoder
57
Motor and Encoder
• Motor speed determined by:
supplied voltage
• Motor direction determined by:
polarity of supplied voltage
• Difficult to generate analog power signal
(1A ..10A) directly from microcontroller
→ external amplifier (pulse-width modulation)
58
Motor and Encoder
• Encoder disk is turned once for each rotor revolution
• Encoder disk can be optical or magnetic
• Single detector can determine speed
• Dual detector can determine speed and direction
• Using gears on motor shaft increases encoder accuracy
59
Pulse-Width Modulation (PWM)
• A/D converters are used for reading analog sensor signals
• Why not use D/A converter for motor control?– Too expensive (needs power circuitry)
– Better do it by software, switching power on/off in intervals
– This is called “Pulse-Width Modulation” or PWM
60
61
Pulse-Width Modulation
• How does this work?
– We do not change the supplied voltage
– Power is switched on/off at a certain pulse ratio
matching the desired output power
• Signal has very high frequency (e.g. 20kHz)
• Motors are relatively slow to respond
– The only thing that counts is the supplied power
– ⇒ Integral (Summation)
• Pulse-Width Ratio = ton / tperiod
62
Servos
63
Servos
64
65
Servos
• Terminology:
• Do not confuse “servos” with “servo motors”
• DC motors (brushed or brushless) are also sometimes also referred to as “servo motors”
• See: http://www.theproductfinder.com/motors/bruser.htm
• “So when does a motor become a servo motor? There are certain design criteria that are desired when building a servo motor, which enable the motor to more adequately handle the demands placed on a closed loop system.
• First of all, servo systems need to rapidly respond to changes in speed and position, which require high acceleration and deceleration rates.
• This calls for extremely high intermittent torque. 66
67
Hydraulic Actuators• linear movement
• big forces without gears
• actuators are simple
• in mobile machines
• Bad efficiency
• motor, pump, actuator combination is lighter than motor, generator, battery, motor & gear combination
Hydraulic actuators
68
69
Pneumatic Actuators�like hydraulic except power from compressed air
�fast on/off type tasks
�big forces with elasticity
�no leak problems
70
Control techniques
Closed loop control is an essential topic for
embedded systems, bringing together actuators
and sensors with the control algorithm in software
Control Techniques
Problem: supplying the same analog voltage (or the same
PWM signal) to a motor does not guarantee that the motor
will run at the same speed under all circumstances!
• On-off control
• PID control
• Others: • Adaptive control (LMS, NLMS, RLS)
• Fuzzy control
• Neural Networks
Solution: Feedback is everything!
71
On-off control
• The power to motor is either switched on or
switched off
72R(t): control signal (control voltage) over time
• Behavior over time
• Advantage: simplest control method; used in
refridgerators, heater, thermostat, etc.
• Disadvantage: the motor control signal is only updated at fixed time intervals (e.g., 10ms) � hysteresis (trễ)
On-off control (cont.)
73
On-off control (cont.)
• Use a hyteresis band with 2 desired signals to prevent a
high switching frequency
74
On-off control (cont.)
• Software implementation
• See: Chapter 4, T. Bräunl Embedded Robotics, Springer 2003
75
Step-response of an on-off
controller
• Not smooth
• Can we improve this?76
PID Control
• PID = P + I + D
• P = Proportional
• I = Integral
• D = Derivative
77
Proportional Controller (P)
• The control voltage is directly proportional to the error
signal (error function)
• P controller is only slightly different from on-off controller
• Varying the “controller gain” Kp will change the behavior
of the P controller
78
Proportional Controller (cont.)
• Step response for P controller
• Higher Kp � Faster response
• Important: Too high Kp
leads to undesirable
oscillating system!
• Require fast response
and stable system
(e.g., Kp = 0.45)
79
Proportional Controller (cont.)
• P controller’s equilibrium state is not at the desired
velocity due to control formula
• Steady-state error is the difference between desired
velocity and equilibrium-state’s velocity
• Can we reduce the
steady-state error?
� Integral controller
80
Integral Controller (I)
• The idea of the I controller is to reduce the steady-state
error of P controller
• The I controller is commonly used with the P or PD
controller
81
Integral Controller (cont.)
• Define the error function : e(t) =
• The formula for PI controller is
• Rewrite for 2 independent additive terms for P and I
• How can we compute the integral?
– naive way (see textbook)
– proper implementation: replace the integral with a sum and use the trapezoidal rule
82
Integral Controller (cont.)
• Use the term Rn-1 to remove the sum
• Substitute KI for
• We only need to store
– the previous control value Rn-1
– the previous error value en-1
to calculate the PI output
83
• The idea of using the D controller is to speed up the P
controller’s response to a change of input
• The D controller is commonly used with the P or PI
controller
• Recall:
– P provides a better step response than on-off controller
– I for reducing steady-state error of P
– D for speeding up step response of P
• How can a PID controller help us?
Derivative Controller (D)
84
P, PD and PID
85
• A complete PID formula
PID controller
86
PID parameter tuning
Find parameters experimentally
87
Other control techniques
• Adaptive control (LMS, NLMS, RLS)
• Fuzzy control
• Control using Neural Network
88
Summary
• Embedded systems– MCU vs. Computer
• Robots and Controllers– Braitenberg vehicles, Operating System (RoBIOS)
• Sensors– Binary, Encoder, Sonar, Infrared sensors, Orientation sensors,
Cameras, Microphones
• Actuators– DC motor, Servo, Stepper motors, H-Bridge and PWM
• Control techniques– On-off, PID
• Next: “artificial intelligence of robots”89
Projects
1. Auto-driving Car
2. Smart 2-DOF Robot Arm
90