ee401-3!2015 embeddedsystems

90
EE401. Engineering Design by Teams: Robotics 1 Lecture 2. Embedded Systems for Robotics Instructor: Huynh Viet Thang Aug. 2015 1

Upload: penny-nguyen

Post on 11-Jan-2016

217 views

Category:

Documents


0 download

DESCRIPTION

EE401-3-2015-EmbeddedSystems

TRANSCRIPT

Page 1: EE401-3!2015 EmbeddedSystems

EE401. Engineering Design by

Teams: Robotics 1

Lecture 2. Embedded Systems

for Robotics

Instructor: Huynh Viet Thang

Aug. 2015

1

Page 2: EE401-3!2015 EmbeddedSystems

• 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

Page 3: EE401-3!2015 EmbeddedSystems

What are in this lecture?

• Embedded systems

• Robots and Controllers

• Sensors

• Actuators

• Control techniques

3

Page 4: EE401-3!2015 EmbeddedSystems

4

Embedded systems

Page 5: EE401-3!2015 EmbeddedSystems

5

Page 6: EE401-3!2015 EmbeddedSystems

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

Page 7: EE401-3!2015 EmbeddedSystems

Applications Areas

7

Page 8: EE401-3!2015 EmbeddedSystems

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

Page 9: EE401-3!2015 EmbeddedSystems

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

Page 10: EE401-3!2015 EmbeddedSystems

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

Page 11: EE401-3!2015 EmbeddedSystems

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

Page 12: EE401-3!2015 EmbeddedSystems

Automobiles

12

Page 13: EE401-3!2015 EmbeddedSystems

13

Page 14: EE401-3!2015 EmbeddedSystems

14

Page 15: EE401-3!2015 EmbeddedSystems

Microcontrollers

15

Page 16: EE401-3!2015 EmbeddedSystems

Von-Neumann vs. Harvard

16

Page 17: EE401-3!2015 EmbeddedSystems

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

Page 18: EE401-3!2015 EmbeddedSystems

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

Page 19: EE401-3!2015 EmbeddedSystems

Input and Output

• Input / output device implementation can be:

• • Memory-mapped

• • I/O mapped (ports)

• • DMA (direct memory access)

19

Page 20: EE401-3!2015 EmbeddedSystems

20

Page 21: EE401-3!2015 EmbeddedSystems

21

Page 22: EE401-3!2015 EmbeddedSystems

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

Page 23: EE401-3!2015 EmbeddedSystems

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?

Page 24: EE401-3!2015 EmbeddedSystems

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

Page 25: EE401-3!2015 EmbeddedSystems

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

Page 26: EE401-3!2015 EmbeddedSystems

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

Page 27: EE401-3!2015 EmbeddedSystems

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

Page 28: EE401-3!2015 EmbeddedSystems

Braitenberg vehicles (cont.)

• Braitenberg vehicles searching light

Light source

28

Page 29: EE401-3!2015 EmbeddedSystems

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

Page 30: EE401-3!2015 EmbeddedSystems

30

Page 31: EE401-3!2015 EmbeddedSystems

RoBIOS

31

Page 32: EE401-3!2015 EmbeddedSystems

32

Sensors

What is important is to find the right sensor for a particular application.

Page 33: EE401-3!2015 EmbeddedSystems

Overview

• Data transfer from the sensor to CPU

– either CPU-initiated (polling)

– or sensor-initiated (interrupt)

33

Page 34: EE401-3!2015 EmbeddedSystems

Sensor categories

• Based on sensor output

34

Page 35: EE401-3!2015 EmbeddedSystems

Other sensor classification

35

Page 36: EE401-3!2015 EmbeddedSystems

Binary sensor

• Simplest

• Easy to design

• Active low in

this example

• What if “active high”?

36

Page 37: EE401-3!2015 EmbeddedSystems

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

Page 38: EE401-3!2015 EmbeddedSystems

Synchronous serial interface

• “synchronous serial” means that the converted

data value is read bit by bit from the sensor

38

Page 39: EE401-3!2015 EmbeddedSystems

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

Page 40: EE401-3!2015 EmbeddedSystems

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

Page 41: EE401-3!2015 EmbeddedSystems

Other sensors

• Sonar (ultra-sound)

• Infrared sensors

41

Page 42: EE401-3!2015 EmbeddedSystems

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

Page 43: EE401-3!2015 EmbeddedSystems

43

Actuators for Robots

Actuators are used in order to produce mechanical movement in robots.

Slides from Braunl and Jussi Suomela

Page 44: EE401-3!2015 EmbeddedSystems

Actuators• Motor and Encoder

• H-Bridge

• Pulse-Width-Modulation (PWM)

• Servos

• Other robotic actuators

44

Page 45: EE401-3!2015 EmbeddedSystems

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

Page 46: EE401-3!2015 EmbeddedSystems

46

DC-Motors• simple, cheap

• easy to control

• 1W - 1kW

• can be overloaded

• brushes wear

• limited overloading

on high speeds

Page 47: EE401-3!2015 EmbeddedSystems

DC-motor control

• Controller + H-bridge

• PWM-control

• Speed control by controlling motor current=torque

• Efficient small components

• PID control

47

Page 48: EE401-3!2015 EmbeddedSystems

H-Bridge

48

Page 49: EE401-3!2015 EmbeddedSystems

49

Page 50: EE401-3!2015 EmbeddedSystems

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

Page 51: EE401-3!2015 EmbeddedSystems

Stepper Motors

51

Page 52: EE401-3!2015 EmbeddedSystems

52

Reluctance (Stepper) Motors

• angle control

• slow

• usually no feedback used

• accurate positioning

• easy to control

Page 53: EE401-3!2015 EmbeddedSystems

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

Page 54: EE401-3!2015 EmbeddedSystems

54

Page 55: EE401-3!2015 EmbeddedSystems

55

Page 56: EE401-3!2015 EmbeddedSystems

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

Page 57: EE401-3!2015 EmbeddedSystems

Motor and Encoder

57

Page 58: EE401-3!2015 EmbeddedSystems

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

Page 59: EE401-3!2015 EmbeddedSystems

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

Page 60: EE401-3!2015 EmbeddedSystems

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

Page 61: EE401-3!2015 EmbeddedSystems

61

Page 62: EE401-3!2015 EmbeddedSystems

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

Page 63: EE401-3!2015 EmbeddedSystems

Servos

63

Page 64: EE401-3!2015 EmbeddedSystems

Servos

64

Page 65: EE401-3!2015 EmbeddedSystems

65

Page 66: EE401-3!2015 EmbeddedSystems

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

Page 67: EE401-3!2015 EmbeddedSystems

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

Page 68: EE401-3!2015 EmbeddedSystems

Hydraulic actuators

68

Page 69: EE401-3!2015 EmbeddedSystems

69

Pneumatic Actuators�like hydraulic except power from compressed air

�fast on/off type tasks

�big forces with elasticity

�no leak problems

Page 70: EE401-3!2015 EmbeddedSystems

70

Control techniques

Closed loop control is an essential topic for

embedded systems, bringing together actuators

and sensors with the control algorithm in software

Page 71: EE401-3!2015 EmbeddedSystems

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

Page 72: EE401-3!2015 EmbeddedSystems

On-off control

• The power to motor is either switched on or

switched off

72R(t): control signal (control voltage) over time

Page 73: EE401-3!2015 EmbeddedSystems

• 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

Page 74: EE401-3!2015 EmbeddedSystems

On-off control (cont.)

• Use a hyteresis band with 2 desired signals to prevent a

high switching frequency

74

Page 75: EE401-3!2015 EmbeddedSystems

On-off control (cont.)

• Software implementation

• See: Chapter 4, T. Bräunl Embedded Robotics, Springer 2003

75

Page 76: EE401-3!2015 EmbeddedSystems

Step-response of an on-off

controller

• Not smooth

• Can we improve this?76

Page 77: EE401-3!2015 EmbeddedSystems

PID Control

• PID = P + I + D

• P = Proportional

• I = Integral

• D = Derivative

77

Page 78: EE401-3!2015 EmbeddedSystems

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

Page 79: EE401-3!2015 EmbeddedSystems

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

Page 80: EE401-3!2015 EmbeddedSystems

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

Page 81: EE401-3!2015 EmbeddedSystems

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

Page 82: EE401-3!2015 EmbeddedSystems

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

Page 83: EE401-3!2015 EmbeddedSystems

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

Page 84: EE401-3!2015 EmbeddedSystems

• 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

Page 85: EE401-3!2015 EmbeddedSystems

P, PD and PID

85

Page 86: EE401-3!2015 EmbeddedSystems

• A complete PID formula

PID controller

86

Page 87: EE401-3!2015 EmbeddedSystems

PID parameter tuning

Find parameters experimentally

87

Page 88: EE401-3!2015 EmbeddedSystems

Other control techniques

• Adaptive control (LMS, NLMS, RLS)

• Fuzzy control

• Control using Neural Network

88

Page 89: EE401-3!2015 EmbeddedSystems

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

Page 90: EE401-3!2015 EmbeddedSystems

Projects

1. Auto-driving Car

2. Smart 2-DOF Robot Arm

90