1. Trang chủ
  2. » Luận Văn - Báo Cáo

IMPLEMENT A LINE MAZE ROBOT WITH LEFT FORWARDING RIGHT PRIORITY

93 0 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Nội dung

LUNGHWA UNIVERSITY of Science and Technology Technology Reports IMPLEMENT A LINE MAZE ROBOT WITH LEFT-FORWARDING-RIGHT PRIORITY Students:Tran, Khuong Duy Tran, Hoang Tuan Advisor:Hsin-Hsiung Huang Dec 31, 2010 -1- DESIGN A LINE MAZE ROBOT WITH LEFT-FORWARDING-RIGHT PRIORITY Student: TRAN, KHUONG DUY TRAN, HOANG TUAN Advisor:Dr Hsin-Hsiung Huang A Report Submitted to Department of Electronic Engineering Lunghwa University of Science and Technology in Partial Fulfillment of the Requirements for the Degree of Bachelor in Electronic Engineering June 2010 Taoyuan, Taiwan, Republic of China -2- Abstract In the project, we suggested the LFR algorithm, which first searches the right routing path, forwarding and left routing path at each crossroad, to visit the shortest path from the start point to the target The purpose is to find the shortest path after searching the unknown routing map We memorize the routing map into the data structure containing a set of edges and nodes, respectively In the project, we focus on the firmware and algorithm to guide the line following robot to make the proper motion and find the shortest path Experimental results show that our line following robot can work properly to find the shortest path according to our algorithm design -3- CONTENTS Chapter Introduction 6  1.1 BRIEF DESCRIPTION 6  1.2 THE LINE MAZE ROBOT WITH LEFT-FORWARDING-RIGHT PRIORITY: 7  1.4 APPLICATION: 19  Chapter Hardware Design 24  2.1 BLOCK DIAGRAM: 25  2.1.1 PIC 18F4550: 25  2.1.2 Power circuit: 26  2.1.3 The Voltage Multiplier Circuit: 26  2.1.4 LED Circuit: 27  2.1.5 LCD Circuit: 27  2.1.6 Button Circuit: 28  2.1.7 Voltage Detection Circuit: 28  2.1.8 Buzzer Circuit: 29  2.1.9 Burning Circuit: 29  2.1.10 H-Bridge Motor Driver: 30  2.1.11 CNB1001 Light Sensor Circuit: 24  2.1.12 Component Supply: 25  Chapter Left-Forwarding-Right Algorithm 28  3.1 DESCRIBE THE DETERMINE FUNCTION: 29  3.2 DESCRIBE THE NOTE SUB-ROUTINE: 30  3.2.1 Description of the line_formation: 30  3.2.2 Description of the mode_formation: 31  3.2.3 Description of the car_direction: 32  3.3 DESCRIBE THE MOTION CONTROL: 33  3.4 THE RIGHT-FORWARDING-LEFT ALGORITHM: 34  3.5 AN EXAMPLE OF THE ALGORITHM : 35  Chapter Experimental results 42  Chapter Conclusions 44  -4- Reference 45 APPENDIX : The determine sub-routine 46  APPENDIX : The note sub-routine 56  APPENDIX : The motion sub-routine 83 -5- Chapter Introduction What is the importance of the robot? It contains the HW, SW and algorithm to train the student What we want to is provide the platform to train students according to their studying time and their background If the time is too short, student may just learn some topics, such as the firmware code and algorithm If the time is over 18 weeks, we will arrange the other topics to train them from the hardware, software and algorithm Our goal is to help everyone learn the proper materials by using the platform, line following maze robot 1.1 Brief description Chapter 1: The concept of the line maze robot with Left-Forwarding-Right priority Chapter 2: We discuss Hardware design, such as: PIC 18F4550, Voltage multiplier circuit, LED Circuit, Button Circuit, Buzzer Circuit Chapter 3: We discuss Determine sub-routine for the crossroad, storing node information, direction, path-visit, mode, motion control, and the right-forwarding-left algorithm Chapter 4: We discuss Experimental Results Chapter 5: We make some conclusions -6- 1.2 The concept of the line maze robot with left-Forwarding-Right priority: What is a line maze? A line maze is usually a black line on a white background It could also be a white line on a black background, but for this paper, black lines on a white background will be used Each line maze has a Start point and a Finish point The robot is expected to follow the lines and find the way from Start to Finish in the fastest time possible Notice that there are a number of dead-end paths in the maze The robot typically cannot traverse the maze without first taking a number of wrong turns In the two mazes below, notice that: The left hand maze has no loops Using the left hand (or right hand) rule will always get you to the end of the maze Figure A tree-based routing map The right hand maze has several loops Figure A cyclic-based routing map -7- At the present time, this paper does not address how to solve the maze below This algorithm may be added at a future date The robot includes hardware, firmware with algorithm The hardware contains: PIC 18F4550, Power circuit, Voltage multiplier circuit, LED circuit, LCD circuit, Button circuit, Buzzer circuit, Burning circuit, H-Bridge circuit and CNB1001 light sensor The robot uses PIC 18F4550 as a key part; LCD displays the parameter of the robot; light sensors are used to detect the maze line; H-Bridge circuit controls two motor to create the motion modes The advantage of the following line maze robot is to follow the line in the direction priority, then, robot will define the shortest path The robot follows the line maze three times In the first time, the robot runs from the start point to the end point in the searching path passage In the second time, the robot will comes back the start point from the end point according the shortest path Finally, the robot runs the shortest path from the start point to the end point In the searching path passage, the robot will follow the line according the direction priority What is the direction priority? There are two types of direction priorities: Left –Forward-Right (LFR) and Right-Forward-Left (LFR) LFR: In this paper, we use LFR priority 1.Always prefer a left turn over going straight ahead or taking a right turn 2.Always prefer going straight over going right If the maze has no loops, this will always get you to the end of the maze RLF: 1.Always prefer a right turn over going straight ahead or taking a left turn 2.Always prefer going straight over going left If the maze has no loops, this will always get you to the end of the maze There are situations the robot can encounter: -8- Figure Eight types of robot motion over the crossroad The robot, most of the time, will be involved in one of the following behaviors: 1.Following the line, looking for the next intersection 2.At an intersection, deciding what type of intersection it is 3.At an intersection, making a turn These steps continue looping over and over until the robot senses the end of the maze The robot needs to be taught the correct behavior depending on the type of turn or intersection it encounters An intersection is the place where the robot has more than one choice of direction -9- Figure Motions of turn-left and turn-right In these above two cases, the robot has no choice but to make a 90 degree turn Since the robot will always make the same 90 degree turn and it has no other option, this turn need not be stored when solving the maze In the below case, the robot has no choice but to make a 180 degree turn (U-Turn) to exit the dead end Since reaching a dead-end means that the robot has recently made a bad turn, we need to store this fact so that a previous turn can be corrected The robot should not visit this dead-end on the next run The correct behavior at a dead-end is to make a U-Turn Figure Motion of Dead end In the first run, it goes down some number of dead-ends, and records these as “bad” paths so that they can be avoided on the second run - 10 - case 5: // "├ ┼" car_direction = 2; line_information[line_node] = line_information[line_node]|0x20; break; case 6: // "┤ ┼" car_direction = 4; line_information[line_node] = line_information[line_node]|0x80; break; case 7: //stopping car_direction = 1; break; } break; case 2: switch (mode) { case 0: //Forward car_direction = 2; break; case 1: //Folow the line car_direction = 2; line_information[line_node] = line_information[line_node]|0x20; break; case 2: // U-turn -car_direction = 4; break; case 3: // Turn right -car_direction = 3; - 75 - line_information[line_node] = line_information[line_node]|0x40; break; case 4: // Turn left -car_direction = 1; line_information[line_node] = line_information[line_node]|0x10; break; case 5: // "├ ┼" car_direction = 3; line_information[line_node] = line_information[line_node]|0x40; break; case 6: // "┤ ┼" car_direction = 1; line_information[line_node] = line_information[line_node]|0x10; break; case 7: //Stopping car_direction = 2; break; } break; case 3: switch (mode) { case 0: //Forward car_direction = 3; break; case 1: //Follow the line car_direction = 3; - 76 - line_information[line_node] = line_information[line_node]|0x40; break; case 2: // U-turn -car_direction = 1; break; case 3: // Turn right -car_direction = 4; line_information[line_node] = line_information[line_node]|0x80; break; case 4: // Turn left -car_direction = 2; line_information[line_node] = line_information[line_node]|0x20; break; case 5: // "├ ┼" car_direction = 4; line_information[line_node] = line_information[line_node]|0x80; break; case 6: // "┤ ┼" car_direction = 2; line_information[line_node] = line_information[line_node]|0x20; break; case 7: //stopping car_direction = 3; break; } break; - 77 - case 4: switch (mode) { case 0: //Forward car_direction = 4; break; case 1: //Forward and follow the line car_direction = 4; line_information[line_node] = line_information[line_node]|0x80; break; case 2: // U-turn -car_direction = 2; break; case 3: // Turn right -car_direction = 1; line_information[line_node] = line_information[line_node]|0x10; break; case 4: // Turn left -car_direction = 3; line_information[line_node] = line_information[line_node]|0x40; break; case 5: // -"├ ┼" -car_direction = 1; line_information[line_node] = line_information[line_node]|0x10; break; case 6: // "┤ ┼" - 78 - car_direction = 3; line_information[line_node] = line_information[line_node]|0x40; break; case 7: //stopping car_direction = 4; break; } break; } //更改 mode_information if(((mode_information[line_node] & 0xF0) >> 4) == 1) { if((line_information[line_node] & 0x01) == 0)//沒線 { switch(car_direction) { case 1: mode_information[line_node] = 0x11; break; case 2: mode_information[line_node] = 0x13; break; case 3: mode_information[line_node] = 0x12; break; case 4: mode_information[line_node] = 0x14; break; } } else //有線 - 79 - { switch(car_direction) { case 1: mode_information[line_node] = 0x11; break; case 2: mode_information[line_node] = 0x15; break; case 3: mode_information[line_node] = 0x12; break; case 4: mode_information[line_node] = 0x16; break; } } } else if(((mode_information[line_node] & 0xF0) >> 4) == 2) { if((line_information[line_node] & 0x02) == 0)//沒線 { switch(car_direction) { case 1: mode_information[line_node] = 0x24; break; case 2: mode_information[line_node] = 0x21; break; case 3: mode_information[line_node] = 0x23; break; - 80 - case 4: mode_information[line_node] = 0x22; break; } } else { //有線 switch(car_direction) { case 1: mode_information[line_node] = 0x26; break; case 2: mode_information[line_node] = 0x21; break; case 3: mode_information[line_node] = 0x25; break; case 4: mode_information[line_node] = 0x22; break; } } } else if(((mode_information[line_node] & 0xF0) >> 4) == 3) { if((line_information[line_node] & 0x04) == 0)//沒線 { switch(car_direction) { case 1: mode_information[line_node] = 0x32; break; - 81 - case 2: mode_information[line_node] = 0x34; break; case 3: mode_information[line_node] = 0x31; break; case 4: mode_information[line_node] = 0x33; break; } } else { //有線 switch(car_direction) { case 1: mode_information[line_node] = 0x32; break; case 2: mode_information[line_node] = 0x36; break; case 3: mode_information[line_node] = 0x31; break; case 4: mode_information[line_node] = 0x35; break; } } } else if(((mode_information[line_node] & 0xF0) >> 4) == 4) { if((line_information[line_node] & 0x08) == 0)//沒線 - 82 - { switch(car_direction) { case 1: mode_information[line_node] = 0x43; break; case 2: mode_information[line_node] = 0x42; break; case 3: mode_information[line_node] = 0x44; break; case 4: mode_information[line_node] = 0x41; break; } } else { //有線 switch(car_direction) { case 1: mode_information[line_node] = 0x45; break; case 2: mode_information[line_node] = 0x42; break; case 3: mode_information[line_node] = 0x46; break; case 4: mode_information[line_node] = 0x41; - 83 - break; } } } } } } - 84 - APPENDIX 3: Describe the Motion Control: The function of the motion sub-routine is to create the forwarding, turning-left, turning-right, turning-left at the crossroad, turning-right at the crossroad, rotating, stopping movement After the determine sub-routine, the necessary motion is stored in the array and the robot will perform the corresponding motion Source code: void Motion(void) { switch(mode) { case 0: LATDbits.LATD0=0; LATDbits.LATD1=0; CCPR1L = 20; CCPR2L = 20; break; //go straight // register with the relative bit case 1: position_calculate( ); PD_control(); LATDbits.LATD2=0; LATDbits.LATD3=0; LATBbits.LATB7=0; if(decelerate==60) { position_calculate( ); PD_control_decelerate(); } else { // follow the line // calculate the position // PD_control sub-routine // calculate the position // PD_control_decelerate - 85 - decelerate++; position_calculate( ); PD_control(); } break; // calculate the position // PD_control sub-routine case 2: //turn-round U_turn( ); LATBbits.LATB7=~LATBbits.LATB7; LATDbits.LATD2=1; LATDbits.LATD3=1; decelerate=0; break; case 3: LATDbits.LATD3=1; R_turn( ); decelerate=0; break; // turn right case 4: LATDbits.LATD2=1; L_turn( ); decelerate=0; break; // turn left case 5: LATDbits.LATD3=1; decelerate=0; break; // "├ ┼" SR_turn( ); case 6: LS_turn( ); // "┤ ┼" - 86 - LATDbits.LATD2=1; decelerate=0; break; case 7: Stop( ); decelerate=0; break; // case 8: LATDbits.LATD0=0; LATDbits.LATD1=1; CCPR1L = 80; CCPR2L = 15; break; } // } - 87 - - 88 - ...DESIGN A LINE MAZE ROBOT WITH LEFT-FORWARDING-RIGHT PRIORITY Student: TRAN, KHUONG DUY TRAN, HOANG TUAN Advisor:Dr Hsin-Hsiung Huang A Report Submitted to Department of Electronic

Ngày đăng: 30/10/2022, 19:20

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w