Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2022:robert:robotfollower [2022/05/27 11:04]
ioan_ovidiu.stiru [Software Design]
pm:prj2022:robert:robotfollower [2022/06/01 20:06] (current)
ioan_ovidiu.stiru [Hardware Design]
Line 1: Line 1:
-====== ​Nume proiect ​======+====== ​Human Follower Robot ====== 
 + 
 +Name: Tanase Paul-Gabriel 
 + 
 +Group: 1221 A 
 + 
 +Faculty: FILS
 ===== Introducere ===== ===== Introducere =====
  
Line 19: Line 25:
 O schemă bloc cu toate modulele proiectului vostru, atât software cât şi hardware însoţită de o descriere a acestora precum şi a modului în care interacţionează. O schemă bloc cu toate modulele proiectului vostru, atât software cât şi hardware însoţită de o descriere a acestora precum şi a modului în care interacţionează.
  
-Schemă bloc: {{:​pm:​prj2022:​robert:​schema_bloc_paul.png|}}+Schemă bloc: {{:​pm:​prj2022:​robert:​schema_bloc_paul.png?300|}} 
 + 
 +Poze robot: ​  
 +{{:​pm:​prj2022:​robert:​tanase_paul_robo_front.jpg?​300|}} 
 + 
 +{{:​pm:​prj2022:​robert:​tanase_paul_robo_side.jpg?​300|}}
 </​note>​ </​note>​
  
Line 32: Line 43:
  - 2 senzori IR  - 2 senzori IR
  - Jumper Wires  - Jumper Wires
- - 2 bateri ​Li-on+ - 2 Li-Ion Battery *
   ​   ​
 {{:​pm:​prj2022:​robert:​schema_circuit.jpg?​300|}} {{:​pm:​prj2022:​robert:​schema_circuit.jpg?​300|}}
 </​note>​ </​note>​
  
 +<note tip>
 +* Couldn'​t find Li-ion batteries. Replaced with a 9V battery
 +</​note>​
 ===== Software Design ===== ===== Software Design =====
  
Line 42: Line 56:
 <note tip> <note tip>
 Descrierea codului aplicaţiei (firmware): Descrierea codului aplicaţiei (firmware):
-  * mediu de dezvoltare: ​Arduino IDE +   ​Mediu ​de dezvoltare: ​**ArduinoIDE** 
-  librării şi surse 3rd-party ​NewPing ​AVRlib, Servo lib, AFMotor ​lib +    
-  ​* algoritmi şi structuri pe care plănuiţi să le implementaţi +   ​Librarii folosite: **NewPing**,**Servo**,**AFMotor** 
-  ​(etapa 3) surse şi funcţii implementate+    
 + ​Cod:​ 
 + 
 +<code cpp> 
 +#​include<​NewPing.h> ​           
 +#​include<​Servo.h> ​             
 +#​include<​AFMotor.h> ​           
 + 
 +#define RIGHT A2              // Right IR sensor connected to analog pin A2 of Arduino Uno: 
 +#define LEFT A3               // Left IR sensor connected to analog pin A3 of Arduino Uno: 
 +#define TRIGGER_PIN A1        // Trigger pin connected to analog pin A1 of Arduino Uno: 
 +#define ECHO_PIN A0           // Echo pin connected to analog pin A0 of Arduino Uno: 
 +#define MAX_DISTANCE 200      // Maximum ping distance: 
 + 
 +unsigned int distance = 0;    //Variable to store ultrasonic sensor distance: 
 +unsigned int Right_Value = 0; //Variable to store Right IR sensor value: 
 +unsigned int Left_Value = 0;  //Variable to store Left IR sensor value: 
 +  ​ 
 + 
 +NewPing sonar(TRIGGER_PIN,​ ECHO_PIN, MAX_DISTANCE); ​ //NewPing setup of pins and maximum distance: 
 + 
 +AF_DCMotor Motor1(1,​MOTOR12_1KHZ);​ 
 +AF_DCMotor Motor2(2,​MOTOR12_1KHZ);​ 
 +AF_DCMotor Motor3(3,​MOTOR34_1KHZ)
 +AF_DCMotor Motor4(4,​MOTOR34_1KHZ);​ 
 + 
 + Servo myservo; 
 + int pos=0; ​    //​variable to store the servo position: 
 + 
 +void setup() { // the setup function runs only once when power on the board or reset the board: 
 +   
 +   ​Serial.begin(9600);​ //​initailize serial communication at 9600 bits per second: 
 +   ​myservo.attach(10);​ // servo attached to pin 10 of Arduino UNO 
 +
 +for(pos = 90; pos <= 180; pos += 1){    // goes from 90 degrees to 180 degrees: 
 +  myservo.write(pos); ​                  //​tell servo to move according to the value of '​pos'​ variable: 
 +  delay(15); ​                           //wait 15ms for the servo to reach the position: 
 +  }  
 +for(pos = 180; pos >= 0; pos-= 1) {     // goes from 180 degrees to 0 degrees: 
 +  myservo.write(pos); ​                  //​tell servo to move according to the value of '​pos'​ variable: 
 +  delay(15); ​                           //wait 15ms for the servo to reach the position: 
 +  } 
 +for(pos = 0; pos<=90; pos += 1) {       //​goes from 180 degrees to 0 degrees: 
 +  myservo.write(pos); ​                  //​tell servo to move according to the value of '​pos'​ variable: 
 +  delay(15); ​                           //wait 15ms for the servo to reach the position: 
 +  } 
 +
 +   ​pinMode(RIGHT,​ INPUT); //set analog pin RIGHT as an input: 
 +   ​pinMode(LEFT,​ INPUT); ​ //set analog pin LEFT as an input: 
 +
 + 
 +// the lope function runs forever 
 +void loop() {                              
 +   
 +delay(50); ​                                       //wait 50ms between pings: 
 +distance = sonar.ping_cm(); ​                      //​send ping, get distance in cm and store it in '​distance'​ variable: 
 +Serial.print("​distance"​); ​                   
 +Serial.println(distance); ​                        // print the distance in serial monitor: 
 + 
 + 
 +    Right_Value = digitalRead(RIGHT); ​            // read the value from Right IR sensor: 
 +    Left_Value = digitalRead(LEFT); ​              // read the value from Left IR sensor: 
 +  
 +Serial.print("​RIGHT"​); ​                      
 +Serial.println(Right_Value); ​                     // print the right IR sensor value in serial monitor: 
 +Serial.print("​LEFT"​); ​                       
 +Serial.println(Left_Value); ​                      //​print the left IR sensor value in serial monitor: 
 + 
 +if((distance > 1) && (distance < 15)){            //check wheather the ultrasonic sensor'​s value stays between 1 to 15. 
 +                                                  //If the condition is '​true'​ then the statement below will execute: 
 +  //Move Forward: 
 +  Motor1.setSpeed(130); ​ //define motor1 speed: 
 +  Motor1.run(FORWARD); ​  //​rotate motor1 clockwise:​ 
 +  Motor2.setSpeed(130); ​ //define motor2 speed: 
 +  Motor2.run(FORWARD); ​  //​rotate motor2 clockwise:​ 
 +  Motor3.setSpeed(130); ​ //define motor3 speed: 
 +  Motor3.run(FORWARD); ​  //​rotate motor3 clockwise:​ 
 +  Motor4.setSpeed(130); ​ //define motor4 speed: 
 +  Motor4.run(FORWARD); ​  //​rotate motor4 clockwise:​ 
 +   
 +}else if((Right_Value==0) && (Left_Value==1)) { 
 +   
 +  //Turn Left                                                 
 +  Motor1.setSpeed(150); ​ //define motor1 speed: 
 +  Motor1.run(FORWARD); ​  //​rotate motor1 cloclwise:​ 
 +  Motor2.setSpeed(150); ​ //define motor2 speed: 
 +  Motor2.run(FORWARD); ​  //​rotate motor2 clockwise:​ 
 +  Motor3.setSpeed(150); ​ //define motor3 speed: 
 +  Motor3.run(BACKWARD); ​ //rotate motor3 anticlockwise:​ 
 +  Motor4.setSpeed(150); ​ //define motor4 speed: 
 +  Motor4.run(BACKWARD); ​ //rotate motor4 anticlockwise:​ 
 +  delay(150);​ 
 +   
 +}else if((Right_Value==1)&&​(Left_Value==0)) { 
 +   
 +  //Turn Right 
 +  Motor1.setSpeed(150); ​ //define motor1 speed: 
 +  Motor1.run(BACKWARD); ​ //rotate motor1 anticlockwise:​ 
 +  Motor2.setSpeed(150); ​ //define motor2 speed: 
 +  Motor2.run(BACKWARD); ​ //rotate motor2 anticlockwise:​ 
 +  Motor3.setSpeed(150); ​ //define motor3 speed: 
 +  Motor3.run(FORWARD); ​  //​rotate motor3 clockwise:​ 
 +  Motor4.setSpeed(150); ​ //define motor4 speed: 
 +  Motor4.run(FORWARD); ​  //​rotate motor4 clockwise:​ 
 +  delay(150);​ 
 +   
 +}else if(distance > 15) { 
 +   
 +  //Stop 
 +  Motor1.setSpeed(0); ​   //define motor1 speed: 
 +  Motor1.run(RELEASE); ​  //​stop motor1: 
 +  Motor2.setSpeed(0); ​   //define motor2 speed: 
 +  Motor2.run(RELEASE); ​  //​stop motor2: 
 +  Motor3.setSpeed(0); ​   //define motor3 speed: 
 +  Motor3.run(RELEASE); ​  //​stop motor3: 
 +  Motor4.setSpeed(0); ​   //define motor4 speed: 
 +  Motor4.run(RELEASE); ​  //​stop motor4: 
 +
 +
 +</​code>​
 </​note>​ </​note>​
  
Line 57: Line 190:
  
 ===== Download ===== ===== Download =====
 +
 +{{:​pm:​prj2022:​robert:​tanase_paul.rar|Resurse proiect}}
  
 <note warning> <note warning>
Line 73: Line 208:
  
 <​note>​ <​note>​
-Listă cu documente, datasheet-uri,​ resurse Internet folosite, eventual grupate pe **Resurse Software** ​şi **Resurse Hardware**.+**Listă cu documente, datasheet-uri,​ resurse Internet folosite** 
 + 
 + 
 +**Resurse Software:** 
 +  * [[https://​github.com/​adafruit/​Adafruit-Motor-Shield-library|AFMotor GitHub documentation]] 
 +  * [[https://​bitbucket.org/​teckel12/​arduino-new-ping/​wiki/​Home|NewPing lib wiki]] 
 +  * [[https://​docs.arduino.cc/​tutorials/​|Arduino Tutorials]] 
 + 
 +**Resurse Hardware:** 
 +  * [[https://​www.instructables.com/​Arduino-Motor-Shield-Tutorial/​|Arduino Motor Shield L293D General info]] 
 +  * [[https://​www.quora.com/​How-do-I-connect-a-sensor-with-Arduino-when-Im-using-the-L293D-motor-shield-as-the-shield-takes-all-the-pins| How to connect sensors to Motor Shield (Quora answer)]] 
 +  * [[https://​forum.arduino.cc/​t/​using-a-motor-shield-where-to-plug-other-sensors-ir/​80842|How to connect IR sensors to shield (Arduino forums)]] 
 +  * [[https://​www.instructables.com/​Arduino-HC-SR04-Ultrasonic-Rover/​| Example to attach Ultrasonic sensor]]
 </​note>​ </​note>​
  
 <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
  
pm/prj2022/robert/robotfollower.1653638645.txt.gz · Last modified: 2022/05/27 11:04 by ioan_ovidiu.stiru
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0