0% found this document useful (0 votes)
56 views34 pages

Technical Science II Robotics Hand Guide

Robotics involves creating robots, or machines called robots, that can perform tasks automatically or with human assistance. Robots consist of sensors, actuators, a controller, a power supply, and other components. There are many types of robots for different purposes, including industrial robots for manufacturing, service robots for assistance, educational robots for learning, and more. Programming robots involves providing instructions using languages like Python or C++ to control the robot's movements and integrate sensors. Proper programming allows robots to navigate, make decisions, and complete complex tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views34 pages

Technical Science II Robotics Hand Guide

Robotics involves creating robots, or machines called robots, that can perform tasks automatically or with human assistance. Robots consist of sensors, actuators, a controller, a power supply, and other components. There are many types of robots for different purposes, including industrial robots for manufacturing, service robots for assistance, educational robots for learning, and more. Programming robots involves providing instructions using languages like Python or C++ to control the robot's movements and integrate sensors. Proper programming allows robots to navigate, make decisions, and complete complex tasks.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 34

Technical Science II

Robotics Hand Guide

S.M. Nipuna Nilupul Samarakoon


BEng (Hons) Mechatronics Engineering
University of Wolverhampton UK

1
Introduction

What is Robotics?

Robotics is about creating smart machines called robots. These robots can do tasks
on their own or with some help. They can be programmed to do things like cleaning,
building, or exploring places that might be risky for people.

More.

Robotics is a fascinating field that combines science, technology, engineering, and


mathematics (STEM) to create machines called robots. These robots can perform
tasks on their own or be controlled by humans.

Fun Fact:

The word "robot" comes from the Czech word "robota," which means forced labor or
work.

Your Role in Robotics

You can be a future robot creator, programmer, or even a robotics engineer. The
possibilities are endless!

2
Parts of a Robot

Robots consist of several essential parts that work together to enable their
functionality. Here are the main components of robots:

1.Sensors:

- Function: Sensors act as the robot's "senses" by detecting and collecting


information from the environment. They provide data that helps the robot make
decisions.

- Examples: Light sensors, proximity sensors, touch sensors, and cameras.

2.Actuators:

- Function: Actuators are responsible for the movement and manipulation of the
robot. They convert electrical signals into physical actions, allowing the robot to
perform tasks.

- Examples: Motors, servos, and pneumatic actuators.

3.Controller/Processor:

- Function: The controller or processor serves as the robot's "brain." It processes


information from sensors and sends commands to actuators, determining the robot's
actions.

- Examples: Microcontrollers, microprocessors, and central processing units


(CPUs).

4. Power Supply:

- Function: Robots need a source of power to operate. This can be in the form of
batteries, electricity, or a combination of power sources.

3
- Examples: Rechargeable batteries, power cables.

5. Mechanical Structure:

- Function: The mechanical structure provides the physical framework and support
for the robot. It determines the robot's shape, size, and range of motion.

- Examples: Frames, joints, links, wheels, and legs.

6. End-Effector/Manipulator:

- Function: The end-effector or manipulator is the tool or device at the end of the
robot's arm that interacts with the environment or performs specific tasks.

- Examples: Grippers, claws, welding tools, and 3D printing nozzles.

7. Communication Interface:

- Function: Robots often need to communicate with other devices or systems. The
communication interface enables data exchange between the robot and external
sources.

- Examples: Wired or wireless communication modules, such as Bluetooth or Wi-


Fi.

8. Programming Interface:

- Function: The programming interface allows humans to give instructions to the


robot. It can be through physical buttons, a remote control, or a software interface for
coding.

- Examples: Control panels, programming languages like Scratch or Python.

4
9. Feedback System:

- Function: Robots may have a feedback system to receive information about their
own state or the success of a task. This helps in adjusting actions for better
performance.

- Examples: Encoders, feedback sensors, and error correction systems.

Understanding these components provides insight into how robots function and how
they can be designed for specific applications. Depending on the type and purpose
of the robot, these parts may vary in complexity and arrangement.

5
Types of Robots

Certainly! There are several main types of robots, each designed for specific
purposes. Here are some of the key categories:

1. Industrial Robots:

- Purpose: Used in manufacturing and industrial settings for tasks like welding,
assembly, painting, and packaging.

- Characteristics: Often large and designed to perform repetitive tasks with


precision.

2. Service Robots:

- Purpose: Intended to assist humans in various settings.

- Examples: Robotic vacuum cleaners, medical robots, delivery robots, and


entertainment robots.

3. Educational Robots:

- Purpose: Designed to help people, especially students, learn about robotics and
programming.

- Examples: Robots used in educational settings to teach coding and STEM


concepts.

4. Medical Robots:

- Purpose: Used in healthcare for tasks like surgery, rehabilitation, and diagnostics.

- Examples: Surgical robots, robotic prosthetics, and telepresence robots for


remote medical consultations.

6
5. Military and Defense Robots:

- Purpose: Used for tasks in military and defense applications to reduce risks to
human personnel.

- Examples: Unmanned Aerial Vehicles (UAVs), bomb disposal robots, and


surveillance robots.

6. Entertainment Robots:

- Purpose: Created for entertainment and leisure purposes.

- Examples: Robotic toys, animatronics in theme parks, and interactive robots for
entertainment shows.

7. Domestic Robots:

- Purpose: Designed to assist with household tasks and chores.

- Examples: Robotic vacuum cleaners, lawn mowers, and smart home devices.

8. Research Robots:

- Purpose: Used in laboratories and research institutions for scientific experiments


and studies.

- Examples: Humanoid robots used for studying human behavior, robot arms for
research purposes.

7
9. Humanoid Robots:

- Purpose: Designed to resemble and imitate human movements and behaviors.

- Examples: ASIMO by Honda, Atlas by Boston Dynamics, and Pepper by


Softbank.

10. Autonomous Vehicles:

- Purpose: Vehicles that can operate without human intervention, often using
robotics and artificial intelligence.

- Examples: Self-driving cars, drones, and unmanned underwater vehicles.

These categories demonstrate the diverse applications of robotics across various


industries and everyday life. Each type of robot is designed with specific
functionalities and capabilities to perform tasks efficiently in its intended
environment.

8
How to Program Robots

Programming robots involves providing a set of instructions that the robot follows to
perform specific tasks. The programming language and approach can vary
depending on the type of robot and the complexity of the task. Here's a general
overview of robot programming:

1. Selecting a Programming Language:

- Choose a programming language suitable for the robot's hardware and your skill
level.

- Common languages for robotics include:

• Blockly: A visual programming language suitable for beginners.


• Python: A versatile language with extensive libraries for robotics.
• C/C++: Lower-level languages commonly used in embedded systems.
• Java: Suitable for robotics applications, especially on larger platforms.

2. Understanding the Robot's Hardware:

- Familiarize yourself with the robot's components, sensors, actuators, and


communication interfaces.

- Know the capabilities and limitations of the hardware.

3. Basic Motion Programming:

- Start with simple movements to understand how to control the robot's actuators.

- Examples include moving forward, backward, turning, and stopping.

4. Sensor Integration:

9
- Incorporate sensor data into your program to make the robot responsive to its
environment.

- Program conditional statements based on sensor readings.

5. Conditional Statements and Decision Making:

- Use if-else statements to make decisions in response to specific conditions.

- For example, if a robot's sensor detects an obstacle, instruct it to change direction

6. Loops:

- Implement loops to make the robot perform repetitive tasks efficiently.

- For instance, instruct a robot to patrol an area continuously.

7. Functions and Procedures:

- Break down complex tasks into smaller, manageable functions or procedures.

- This makes your code modular and easier to understand.

8. Object-Oriented Programming (OOP):

- For more advanced programming, consider using OOP principles if the chosen
language supports it.

- Create classes and objects to model different aspects of the robot.

9. Path Planning and Navigation:

- For mobile robots, implement algorithms for path planning and navigation.

- Use mapping and localization techniques to help the robot navigate its
environment.

10
10. Testing and Debugging:

- Test your code in a controlled environment before deploying it in the real world.

- Debug any issues and refine your program for better performance.

11. Continuous Learning:

- Stay updated on advancements in robotics and programming techniques.

- Explore additional features and capabilities as you become more proficient.

12. Documentation:

- Document your code to make it easy for others (or yourself) to understand and
maintain.

Remember that the specifics of robot programming can vary based on the type of
robot and its intended application. Whether you're working with educational robots,
industrial robots, or autonomous vehicles, adapting your programming approach to
the specific requirements is essential.

Robotics in the Future

Exciting Trends

1. Artificial Intelligence: Robots learning and making decisions on their own.

2. Human-Robot Collaboration: Robots working alongside humans in


various tasks.

11
Chapter 1 - ESP 32

12
The ESP32 Dev Module is a development board based on the ESP32
microcontroller, which is a powerful and versatile chip designed for IoT (Internet of
Things) applications. Here's an overview of the ESP32 Dev Module and some key
information:

ESP32 Dev Module Features:

1. Microcontroller:

- The ESP32 Dev Module is powered by the Espressif ESP32 microcontroller.

- It has dual-core processors (Xtensa LX6), providing high computing power.

2. Wireless Connectivity:

- Built-in Wi-Fi (802.11 b/g/n) and Bluetooth (Bluetooth Low Energy) capabilities.

- Allows for IoT applications, connecting to the internet, and communication with
other devices.

3. GPIO Pins:

- Provides a variety of GPIO (General Purpose Input/Output) pins for interfacing


with sensors, actuators, and other external components.

4. Programming Interface:

- Can be programmed using the Arduino IDE, PlatformIO, or other development


environments.

- USB-to-UART bridge for easy programming and debugging.

13
5. Integrated Peripherals:

- Includes peripherals such as SPI, I2C, UART, ADC, and more.

- Supports various protocols for communication with sensors and other devices.

6. Memory:

- Flash memory for program storage.

- SRAM for data storage.

7. Power Options:

- Can be powered via USB or an external power supply.

- Low-power modes for energy-efficient applications.

8. Development Environment:

- Arduino core for ESP32 allows for easy and familiar programming.

- Supports both C and C++ programming languages.

9. Form Factor:

- Compact and easy-to-use development board with standard pin headers.

14
ESP 32 for what?

The ESP32 microcontroller is highly versatile and finds applications in a wide range
of projects, especially in the field of IoT (Internet of Things). Here are some common
usages of the ESP32:

1. IoT Devices:

- ESP32 is widely used in IoT applications due to its built-in Wi-Fi and Bluetooth
capabilities. It can connect to the internet, enabling devices to communicate and
share data.

2. Home Automation:

- ESP32-based devices are used in smart home applications for controlling lights,
thermostats, door locks, and other home appliances remotely.

3. Sensor Networks:

- ESP32 can interface with various sensors (temperature, humidity, motion, etc.)
and create sensor networks for monitoring and data collection.

4. Industrial Automation:

- In industrial settings, ESP32 devices can be employed to monitor and control


machinery, collect data, and facilitate communication between different components.

5. Robotics:

- ESP32 can be used in robotics projects for motor control, sensor integration, and
wireless communication. It's suitable for both educational and hobbyist robotics
applications.

15
6. Wearable Devices:

- Due to its small form factor and low power consumption, ESP32 is used in
wearable electronics, including smartwatches, fitness trackers, and health monitoring
devices.

7. Data Logging:

- With its ability to interface with sensors and store data, ESP32 is often used for
data logging applications, such as weather stations, environmental monitoring, and
energy consumption tracking.

8. Wireless Communication:

- ESP32 can be employed for wireless communication between devices, enabling


applications like remote control systems, telemetry, and wireless sensor networks.

9. Educational Projects:

- ESP32 is popular in educational settings for teaching programming, electronics,


and IoT concepts due to its ease of use and compatibility with the Arduino IDE.

10. Mesh Networking:

- The ESP32 supports mesh networking, allowing devices to communicate with


each other in a decentralized manner. This is useful for creating robust and scalable
networks.

11. Smart Agriculture:

- In agriculture, ESP32 devices can be used for monitoring soil conditions,


weather, and crop health. This information can help optimize farming practices.

16
12. Audio Processing:

- The ESP32 features capabilities for audio processing, making it suitable for
projects involving sound, music, and voice recognition applications.

13. Security Systems:

- ESP32 can be integrated into security systems for tasks such as surveillance
camera control, access control, and monitoring.

14. Remote Monitoring and Control:

- ESP32 allows for remote monitoring and control of devices and systems, making
it suitable for applications like remote home security, smart agriculture, and industrial
monitoring.

These are just a few examples, and the applications of the ESP32 are continuously
expanding as developers explore its capabilities in various projects. The versatility,
low cost, and ease of use make the ESP32 a popular choice in the maker and IoT
communities.

17
Getting Started:

1. Setup Arduino IDE:

- Install the Arduino IDE on your computer.

- Add the ESP32 board support to the Arduino IDE.

2. Connect ESP32 Dev Module:

- Use a USB cable to connect the ESP32 Dev Module to your computer.

3. Select Board and Port:

- In the Arduino IDE, select the ESP32 Dev Module as the target board.

- Choose the correct COM port.

4. Upload Code:

- Write or open a sample code and upload it to the ESP32 Dev Module.

5. Monitor Serial Output:

- Open the serial monitor in the Arduino IDE to view the output and debug
messages.

18
Chapter 2 – LED Blinking

Certainly! Blinking an LED is a common beginner's project to get started with the
ESP32..

Here's a step-by-step guide to help you set up and run the code:

1. Connect an LED to the ESP32:

- Connect the longer leg (anode) of the LED to pin 13 on the ESP32.

- Connect the shorter leg (cathode) of the LED to the ground (GND) pin on the
ESP32.

19
2. Set Up Arduino IDE:

- Make sure you have the Arduino IDE installed on your computer.

- Add the ESP32 board support to the Arduino IDE. You can follow the instructions
provided by Espressif: [Installing the ESP32 Board in Arduino IDE]

3. Select Board and Port:

- Open the Arduino IDE.

- Select the "ESP32 Dev Module" board from the "Tools" > "Board" menu.

- Choose the correct COM port from the "Tools" > "Port" menu.

4. Upload the Code:

- Copy and paste the provided code into the Arduino IDE.

- Click the "Upload" button (arrow icon) to upload the code to the ESP32.

5. Observe LED Blinking:

- After the code is uploaded, the LED connected to pin 13 on the ESP32 should
start blinking.

20
CODE

Below is a simple example code using the Arduino IDE This code will make an LED
connected to pin 13 on the ESP32 Dev Module blink:

// Pin number for the LED


const int ledPin = 13;

void setup() {
// Set the LED pin as an output
pinMode(ledPin, OUTPUT);
}

void loop() {
// Turn the LED on (HIGH)
digitalWrite(ledPin, HIGH);

// Wait for 1 second


delay(1000);

// Turn the LED off (LOW)


digitalWrite(ledPin, LOW);

// Wait for 1 second


delay(1000);
}

This simple project is a great way to verify that your ESP32 development
environment is set up correctly and that you can successfully upload code to the
board.

21
More – Blink Multiple LEDs

Blinking multiple LEDs with an ESP32 is a straightforward extension of the previous


example. You just need to connect additional LEDs to different GPIO pins and
modify the code accordingly. Here's an example code for blinking three LEDs
connected to pins 13, 14, and 15:

// Pin numbers for the LEDs


const int ledPin1 = 13;
const int ledPin2 = 14;
const int ledPin3 = 15;

void setup() {
// Set the LED pins as outputs
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
pinMode(ledPin3, OUTPUT);
}

void loop() {
// Turn the first LED on (HIGH) for 1 second
digitalWrite(ledPin1, HIGH);
delay(1000);
digitalWrite(ledPin1, LOW);

// Turn the second LED on (HIGH) for 1 second


digitalWrite(ledPin2, HIGH);
delay(1000);
digitalWrite(ledPin2, LOW);

// Turn the third LED on (HIGH) for 1 second


digitalWrite(ledPin3, HIGH);

22
delay(1000);
digitalWrite(ledPin3, LOW);

// Wait for 1 second before restarting the loop


delay(1000);
}

In this code:

- `ledPin1`, `ledPin2`, and `ledPin3` represent the GPIO pins to which the LEDs are
connected.

- Inside the `setup` function, these pins are set as outputs using `pinMode`.

- The `loop` function contains a sequence to turn each LED on for 1 second and then
off, repeating the process for each LED.

- A delay of 1 second is added between each LED action to make the blinking easily
observable.

You can modify the code further by adding more LED pins and adjusting the delays
according to your preferences. Make sure to connect the LEDs to the specified GPIO
pins on the ESP32.

23
Chapter 3 – Sensors

IR sensor with LED

Here are the step-by-step instructions for connecting an IR sensor and an LED to
your ESP32:

Components Required:

1. ESP32 Dev Module

2. IR Sensor (e.g., a simple IR obstacle avoidance sensor)

3. LED

4. Resistor (optional, depending on the LED specifications)

5. Jumper wires

24
Pin Connections:

1. IR Sensor to ESP32:

- Connect the VCC (power) pin of the IR sensor to the 3.3V pin on the ESP32.

- Connect the GND (ground) pin of the IR sensor to the GND pin on the ESP32.

- Connect the OUT (signal) pin of the IR sensor to a digital input pin on the ESP32
(e.g., pin 33 as per your code).

2. LED to ESP32:

- Connect the anode (longer leg) of the LED to a current-limiting resistor (if
needed) and then connect it to a digital output pin on the ESP32 (e.g., pin 32 as per
your code).

- Connect the cathode (shorter leg) of the LED to the GND pin on the ESP32.

Optional: Resistor for LED:

- Depending on the specifications of your LED, you might need a current-limiting


resistor in series with the LED. The resistor value can be calculated based on the
LED's forward voltage and forward current.

25
Wiring Example:

There's a simplified representation of the connections:

ESP32 with IR Sensor and LED

-------------------------------------

3.3V -------- VCC ------------- Anode (+)

GND --------- GND ------------- Cathode (-)

33 ---------- OUT -------------

32 ----------------------------- Anode (+) through Resistor (if needed) (LED)

GND ---------------------------- Cathode (-) (LED)

Notes:

- Ensure that the IR sensor and LED have their specifications and pinouts available
and match them accordingly.

- Double-check the polarity of the LED. The longer leg is the anode (+), and the
shorter leg is the cathode (-).

- Make sure the connections are secure, and there are no loose wires.

- Modify the code if you change the pin assignments in your hardware connections.

After making the connections, upload your code to the ESP32, open the Serial
Monitor in the Arduino IDE to monitor the IR sensor readings, and observe the LED
responding to the IR sensor's output.

26
CODE

#include <Arduino.h>
const int irSensor = 33; // Pin connected to the IR sensor
const int ledPin = 32; // Pin connected to the LED

int irReading;

void setup()
{
Serial.begin(115200); // Initialize serial communication for debugging
pinMode(irSensor, INPUT); // Set the IR sensor pin as INPUT
pinMode(ledPin, OUTPUT); // Set the LED pin as OUTPUT
}
void loop()
{
irReading = digitalRead(irSensor); // Read the state of the IR sensor
// If the IR sensor detects an object (LOW state), turn on the LED; otherwise, turn it
off
if (irReading == LOW)
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}

27
Ultrasonic Sensor with ESP 32

To use an ultrasonic sensor with an ESP32, you can measure the distance to an
object by sending ultrasonic waves and measuring the time it takes for the waves to
bounce back.

Here's a step-by-step guide to help you set up and run this code:

Components Required:

1. ESP32 Dev Module

2. Ultrasonic Sensor (e.g., HC-SR04)

3. Jumper wires

28
Pin Connections:

1. Ultrasonic Sensor to ESP32:

- Connect the VCC (power) pin of the ultrasonic sensor to the 5V pin on the
ESP32.

- Connect the GND (ground) pin of the ultrasonic sensor to the GND pin on the
ESP32.

- Connect the trigger pin of the ultrasonic sensor to a digital output pin on the
ESP32 (e.g., pin 23).

- Connect the echo pin of the ultrasonic sensor to a digital input pin on the ESP32
(e.g., pin 22).

Wiring Example:

Here's a simplified representation of the connections:

ESP32 Ultrasonic Sensor

--------------------------------

5V ---------- VCC

GND --------- GND

23 ---------- Trigger

22 ---------- Echo

Notes:

- Double-check the specifications of your ultrasonic sensor and match the pinouts
accordingly.
- Make sure the connections are secure, and there are no loose wires.
After making the connections, upload your code to the ESP32, open the Serial
Monitor in the Arduino IDE, and you should see distance measurements displayed
based on the readings from the ultrasonic sensor. The distance is measured in
centimeters.

29
CODE

#define TRIG_PIN 23
#define ECHO_PIN 22
float duration_us, distance_cm;

void setup() {
// begin serial port
Serial.begin (9600);
// configure the trigger pin to output mode
pinMode(TRIG_PIN, OUTPUT);
// configure the echo pin to input mode
pinMode(ECHO_PIN, INPUT);
}
void loop() {
// generate 10-microsecond pulse to TRIG pin
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
// measure duration of pulse from ECHO pin
duration_us = pulseIn(ECHO_PIN, HIGH);

// calculate the distance


distance_cm = 0.017 * duration_us;
// print the value to Serial Monitor
Serial.print("distance: ");
Serial.print(distance_cm);
Serial.println(" cm");
delay(500);
}

30
ESP 32 Motor controlling

Materials Needed:
- ESP32 Development Board
- L298N Motor Driver
- DC Motor
- Jumper Wires
- Breadboard
- Power Source (Battery Pack)

Step 1: Set up the Components.

- Place the ESP32 on the breadboard.


- Connect the L298N motor driver to the breadboard.
- Connect the DC motor to the L298N motor driver.

31
Step 2: Wiring

- Connect the wires from the ESP32 to the L298N motor driver:
- Connect GPIO pins 2, 4, 15, and 13 to the L298N inputs (IN1, IN2, IN3, IN4).
- Connect GPIO pins 5 and 14 to the L298N enable pins (ENA, ENB).

- Connect the motor to the L298N motor driver outputs (OUTA, OUTB).

- Double-check your connections.

Step 3: Write the Code

- Open the Arduino IDE on your computer.


- Copy and paste the following code into the Arduino IDE:

32
const int motorAInput1 = 2;
const int motorAInput2 = 4;
const int motorBInput1 = 15;
const int motorBInput2 = 13;
const int enableA = 5;
const int enableB = 14;

void setup() {
pinMode(motorAInput1, OUTPUT);
pinMode(motorAInput2, OUTPUT);
pinMode(motorBInput1, OUTPUT);
pinMode(motorBInput2, OUTPUT);
pinMode(enableA, OUTPUT);
pinMode(enableB, OUTPUT);
Serial.begin(115200);
}

void loop() {
motorControl(enableA, motorAInput1, motorAInput2, 255);
delay(2000);
motorControl(enableA, motorAInput1, motorAInput2, 0);
delay(1000);
motorControl(enableB, motorBInput1, motorBInput2, 255);
delay(2000);
motorControl(enableB, motorBInput1, motorBInput2, 0);
delay(1000);
}
void motorControl(int enablePin, int input1, int input2, int speed) {
analogWrite(enablePin, speed);
digitalWrite(input1, HIGH);
digitalWrite(input2, LOW);
}

33
Step 4: Upload the Code

- Connect the ESP32 to your computer using a USB cable.


- Select the correct board and port in the Arduino IDE.
- Click the "Upload" button to upload the code to the ESP32.

Step 5: Power Up and Test

- Connect a battery pack to power the motors.


- Watch as your motors move forward and backward!

Congratulations! You've successfully built a motor-controlled car with an ESP32 and


L298N motor driver. Feel free to experiment with the code and add more features to
your project. Have fun!

34

You might also like