Sei sulla pagina 1di 10

Presented to the Manufacturing Engineering and Management Department

De La Salle University - Manila


Term 3, A.Y. 2018-2019

In partial fulfillment
of the courses
In LBYMREL EG and MIPROCB EG

Tethered Robot Car

Submitted by:
CASTAÑEDA, Ramon David V.
CHOA, Gabriel Kester T.
MASCARDO, Earl Joseph R.
PRESTOSA, Marianne Claire R.
ROASA, Maria Lorenza Antonette P.

Submitted to:
Engr. Rhen Anjerome R. Bedruz

August 27, 2019


1. Introduction

Typically, robots are either programmed to be able to carry out certain and specific tasks or be

programmed to be controlled via a controller—which may or may not be directly attached to the

robot’s body itself. The idea of being able to control the robot from an external device is the main

concept of this experiment and prototype project. The researchers were able to accomplish this by

making use of a robot car build, while incorporating the use of the ESP32, which has an integrated

Wi-Fi and Bluetooth modules in its system; connecting wires; Direct Current (DC) motors; an

L293D, a motor driver which controls two DC motors simultaneously and allows them to drive in

either direction; the Arduino UNO; and a power source.

The prototype is in the form of a tethered robot car. The ESP32 will first to connect to an accessible

and stable Wi-Fi network, and retrieve an IP Address. With the Wi-Fi connectivity, the user can

access the app that facilitates the controlling of the robot. For this prototype, the researchers made

use of an Android mobile phone and the MIT App Inventor to be able to project the desired

application interface and layout of its buttons and controls. The command for the robot is sent via

Wi-Fi connection, to which the robot is also connected to. Through the connection, the ESP32 will

get the code of command and decipher it into an action it can do.

As for the uses or application of prototypes such as that of the researchers, tethered devices or

tethered robot cars can be useful to transport objects from one point to another, given that the car’s

build can carry a certain weight. Furthermore, it can maximize the available technologies and

capabilities devices available in the market can offer. With the use of Wi-Fi and Bluetooth

modules, devices such as mobile phones can be used for more than just messaging, internet

browsing, and leisure. Especially for engineering students, this presents an opportunity to learn

about topics beyond one’s syllabi.


2. Schematic Diagrams

Figure 1. Schematic diagram of the experiment output.


3. Implementation and Application
4. Program Code

Code to Control the Car


#include <WiFi.h>

const int LMotorPin1 = 16;


const int LMotorPin2 = 17;
const int RMotorPin1 = 18;
const int RMotorPin2 = 19;
int LEnablePin = 25;
int REnablePin = 26;

// PWM properties for Left Motor


const int freq = 30000;
const int pwmChannel = 0;
const int res = 8;
int dutyCycle = 255;
int dutyCycle2 = 100;
int dutyCycle3 = 50;

// PWM properties for Right Motor


const int freq1 = 30000;
const int pwmChannel1 = 0;
const int res1 = 8;

const char* ssid = "CHOAFAMILY";


const char* password = "CHOACHOACHOA";

WiFiServer server(80);
WiFiClient client;
String data ="";

void setup() {

pinMode(LMotorPin1, OUTPUT);
pinMode(LMotorPin2, OUTPUT);
pinMode(RMotorPin1, OUTPUT);
pinMode(RMotorPin2, OUTPUT);
pinMode(LEnablePin, OUTPUT);
pinMode(REnablePin, OUTPUT);

ledcSetup(pwmChannel, freq, res);


ledcSetup(pwmChannel1, freq1, res1);

ledcAttachPin(LEnablePin, pwmChannel);
ledcAttachPin(REnablePin, pwmChannel1);

WiFi.begin(ssid, password);
server.begin();

void GoForward() {
// Move the DC motor forward at maximum speed
Serial.println("Moving Forward");
digitalWrite(LMotorPin1, HIGH);
digitalWrite(RMotorPin1, HIGH);
digitalWrite(LMotorPin2, LOW);
digitalWrite(RMotorPin2, LOW);
ledcWrite(pwmChannel, dutyCycle);
ledcWrite(pwmChannel1, dutyCycle);
}

void GoBackward() {
// Move the DC motor backward at maximum speed
Serial.println("Moving Backward");
digitalWrite(LMotorPin1, LOW);
digitalWrite(RMotorPin1, LOW);
digitalWrite(LMotorPin2, HIGH);
digitalWrite(RMotorPin2, HIGH);
ledcWrite(pwmChannel, dutyCycle);
ledcWrite(pwmChannel1, dutyCycle);
}

void GoRight() {
// Move the DC motor to the right at maximum speed
Serial.println("Moving Right");
digitalWrite(LMotorPin1, HIGH);
digitalWrite(RMotorPin1, LOW);
digitalWrite(LMotorPin2, LOW);
digitalWrite(RMotorPin2, HIGH);
ledcWrite(pwmChannel, dutyCycle);
ledcWrite(pwmChannel1, dutyCycle);
}

void GoLeft() {
// Move the DC motor to the right at maximum speed
Serial.println("Moving Left");
digitalWrite(LMotorPin1, LOW);
digitalWrite(RMotorPin1, HIGH);
digitalWrite(LMotorPin2, HIGH);
digitalWrite(RMotorPin2, LOW);
ledcWrite(pwmChannel, dutyCycle);
ledcWrite(pwmChannel1, dutyCycle);
}

void StopCar() {
// Stop the DC Motor
Serial.println("Motor Stopped");
digitalWrite(LMotorPin1, LOW);
digitalWrite(RMotorPin1, LOW);
digitalWrite(LMotorPin2, LOW);
digitalWrite(RMotorPin2, LOW);
}

String checkClient()
{
while(!client.available()) delay(1);
String request = client.readStringUntil('\r');
request.remove(0, 5);
request.remove(request.length()-9,9);
return request;
}

void loop()
{

client = server.available();
if (!client) return;
data = checkClient();
if (data == "Forward") GoForward();
if (data == "Backward") GoBackward();
if (data == "Left") GoLeft();
if (data == "Right") GoRight();
if (data == "Stop") StopCar();

Code for Getting IP Address from Network


#include <WiFi.h>
WiFiClient client;
WiFiServer server(80);
const char* ssid = "CHOAFAMILY";
const char* password = "CHOACHOACHOA";

void setup()
{
Serial.begin(115200);
connectWiFi();
server.begin();
}

void loop()
{

void connectWiFi()
{
Serial.println("Connecting to WIFI");
WiFi.begin(ssid, password);
while ((!(WiFi.status() == WL_CONNECTED)))
{
delay(300);
Serial.print("..");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("NodeMCU Local IP is : ");
Serial.print((WiFi.localIP()));
}

Figure 2. Mechanism of tethered car prototype.


Figure 3. Interface and layout of the tethered car prototype controller.

Potrebbero piacerti anche