COPYRIGHT © MICHAEL J. PONT, 2001-2006. Contains material from: Pont, M.J. (2002) “Embedded C”, Addison-Wesley. PES I - 263 Seminar 10: Case Study: Controlling a Mobile Robot COPYRIGHT © MICHAEL J. PONT, 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 COPYRIGHT © MICHAEL J. PONT, 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 COPYRIGHT © MICHAEL J. PONT, 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 COPYRIGHT © MICHAEL J. PONT, 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 COPYRIGHT © MICHAEL J. PONT, 2001-2006. Contains material from: Pont, M.J. (2002) “Embedded C”, Addison-Wesley. PES I - 268 Pulse-width modulation x y V Time Duty cycle (%) = x xy+ × 100 Period = x + y, where x and y are in seconds. Frequency = 1 xy+ , where x and y are in seconds. 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 COPYRIGHT © MICHAEL J. PONT, 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 COPYRIGHT © MICHAEL J. PONT, 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 … > COPYRIGHT © MICHAEL J. PONT, 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 COPYRIGHT © MICHAEL J. PONT, 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! . Contains material from: Pont, M.J. (2002) “Embedded C”, Addison-Wesley. PES I - 263 Seminar 10: Case Study: Controlling a Mobile Robot COPYRIGHT © MICHAEL J. PONT, 2001-2006 controlled by an 8051 microcontroller (an AT89C2051). We’ll use a pin-compatible AT89C4051 in this study. http://www.microrobotna.com COPYRIGHT © MICHAEL J. PONT, 2001-2006. Contains