Contains material from: Pont, M.J... Contains material from: Pont, M.J.. PES I - 264 Overview In this session, we will discuss the design of software to control a small mobile robot.. T
Trang 1C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 263
Case Study:
Controlling a Mobile Robot
Trang 2C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 264
Overview
In this session, we will discuss the design of software to control a
small mobile robot
The robot is “Mr Line”
He is produced by “Microrobot NA”
http://www.microrobotna.com
Trang 3C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 265
What can the robot do?
The robot has IR sensors and transmitters that allow him to detect a black line on a white surface - and follow it
http://www.microrobotna.com
Trang 4C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 266
The robot brain
Mr Line is controlled by an 8051 microcontroller (an AT89C2051)
We’ll use a pin-compatible AT89C4051 in this study
http://www.microrobotna.com
Trang 5C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 267
How does the robot move?
Mr Line has two DC motors: by controlling the relative speed of
these motors, we can control the speed and direction in which he
will move
http://www.microrobotna.com
Trang 6C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 268
Pulse-width modulation
V
Time
Duty cycle (%) = x
x+y× 100
Period = x + y, where x and y are in seconds
Frequency = 1
The key point to note is that the average voltage seen by the load is given by the duty cycle multiplied by the load voltage
See: “Patterns for Time-Triggered Embedded Systems”, Chapter 33
Trang 7C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 269
Software PWM
PWM_PERIOD_G
PWM_position_G
if (PWM_position_G < PWM_G) {
PWM_pin = PWM_ON;
} else { PWM_pin = PWM_OFF;
} PWM_G
See: “Patterns for Time-Triggered Embedded Systems”, Chapter 33
Trang 8C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 270
The resulting code
< We’ll discuss the resulting code in the lecture … >
Trang 9C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 271
More about the robot
Please see:
http://www.le.ac.uk/engineering/mjp9/robot.htm
Trang 10C OPYRIGHT © M ICHAEL J P ONT , 2001-2006 Contains material from:
Pont, M.J (2002) “Embedded C”, Addison-Wesley PES I - 272
Conclusions
That brings us to the end of this course!