410 likes | 566 Vues
MICROCAMP V2.0. Introduction to Microcamp MCU Board What is in the Microcamp v2.0 (IROC) Kit Assembling the IROC MAZE ROBOT Simple programming of Microcamp Robot Maze Programming Logic Maze Programming of the Microcamp Robot. Intro to Microcamp.
E N D
MICROCAMP V2.0 • Introduction to Microcamp MCU Board • What is in the Microcamp v2.0 (IROC) Kit • Assembling the IROC MAZE ROBOT • Simple programming of Microcamp Robot • Maze Programming Logic • Maze Programming of the Microcamp Robot
Intro to Microcamp • Supports ATmega8 Flash memory 8KB. Clock rate 16MHz • 2-DC motor driver, 2 of Buttons, 2 LEDs, 5-Analog port for sensors and Serial communication port. • +5V switching power supply • Require 4 AA size battery. • Support In-system Programming with PX-400 Programmer • Piezo Speaker
What is in Microcamp (IROC) Serial LCD Display x 1 GP2D120 x 4 Infrared Reflector x 3 120:1 DC Motor Gearbox x 2 In System Programmer & Cables x 1
Assembling Maze Robot Infrared Reflector Sensor Custom Chassis 2 x AA Battery Holder DC Wheels & Tires Microcamp MCU 48:1 Gearbox
#include <in_out.h> #include <sleep.h> #include <motor.h> // Motor driver library void main() { while(1) // Endless loop { forward(100); // robot forward. sleep(1000); // Delays 1 second. backward(100); // robot backward. sleep(1000); // Delays 1 second. } } Library Includes Main Procedure Commands Calling Functions Simple Programming Basic Robot Movements
Simple Programming Display Value on LCD #include <soft_serout.h> #include <sound.h> #include <analog.h> unsigned char t_m_txt[4]; void main() // Main Program { sleep(1000); // Delay 1 Sec soft_serout_init(4,9600); // Initial 9600 8N1 on P4 for SLCD while(1) { serout_byte(4,0xFE);serout_byte(4,0x01); serout_byte(4,0xFE);serout_byte(4,0x80); utoa(analog(0),t_m_txt,10); // retrieve P0 data serout_text(4,t_m_txt); // Send Text "MicroCamp to SLCD sleep(500); } } Library Includes Declare Variables Commands Display P0 on SLCD
p4 P0 p3 p2 p1 p4 p3 p2 p1 p0 Maze Logic We will assume that the following sensors are linked to the respective ports on the Microcamp MCU.
Maze Logic • Basic Line Following Procedure • 5 Scenarios • Follow Straight Line (P2 activated) • Cross Junction / T Junction (ALL Activated) • Left Y Junction (P4 activated) • Right Y Junction (P0 activated) • Start and End (Similar to Cross Junction / T Junction)
p2 Maze Logic Follow Straight Line Procedure (P2 activated) void followline() { if (analog(2)<AD3) forward(60); if (analog(1)<AD3) { while (analog(2)>AD3) { s_right(60); } } if (analog(3)<AD3) { while (analog(2)>AD3) { s_left(60); } } }
p1 Maze Logic Follow Straight Line Procedure (P2 activated) void followline() { if (analog(2)<AD3) forward(60); if (analog(1)<AD3) { while (analog(2)>AD3) { s_right(60); } } if (analog(3)<AD3) { while (analog(2)>AD3) { s_left(60); } } }
p3 Maze Logic Follow Straight Line Procedure (P3 activated) void followline() { if (analog(2)<AD3) forward(60); if (analog(1)<AD3) { while (analog(2)>AD3) { s_right(60); } } if (analog(3)<AD3) { while (analog(2)>AD3) { s_left(60); } } }
p4 p0 p3 p2 p1 Maze Logic Cross Junction / T Junction (ALL Activated) void t_junction() { while(1) { followline(); if((analog(1)<AD3)&&(analog(2)<AD3) &&(analog(3)<AD3)) { break; } if(analog(0)<AD3) { break; } if(analog(4)<AD3) { break; } } }
p4 p3 p2 Maze Logic Left Y Junction (P4 Activated) void left_junction() { while(1) { followline(); if((analog(3)<AD3)&&(analog(4)<AD3)) { break; } } }
p0 p2 p1 Maze Logic Right Y Junction (P0 Activated) void right_junction() { while(1) { followline(); if((analog(0)<AD3)&&(analog(1)<AD3)) { break; } } }
p4 p0 p3 p2 p1 Maze Logic Start and End (ALL Activated) void end_junction() { while(1) { followline(); if((analog(1)>AD3)&&(analog(2)>AD3) &&(analog(3)>AD3)) { break; } } }
Maze Programming • - Find the Quickest Path • Plot it out • Program your Robot • Try and Try
Maze Programming Start Point
Maze Programming Start PointFollowLine
Maze Programming Start PointFollowLineCross-Junction, Go Straight
Maze Programming Start PointFollowLineCross-Junction, Go straightFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn Left
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn Right
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn Left
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go Straight
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLineY-Junction, Go Straight
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLineY-Junction, Go StraightFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLineY-Junction, Go StraightFollowLineCross-Junction, Go Straight
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLineY-Junction, Go StraightFollowLineCross-Junction, Go StraightFollowLine
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLineY-Junction, Go StraightFollowLineCross-Junction, Go StraightFollowLineY-Junction, Turn Right
Maze Programming Start PointFollowLineCross-JunctionFollowLineT-Junction, Turn LeftFollowLineY-Junction, Turn RightFollowLineY-Junction, Turn LeftFollowLineCross-Junction, Go StraightFollowLineY-Junction, Go StraightFollowLineCross-Junction, Go StraightFollowLineY-Junction, Turn RightFollowLine