You are on page 1of 26

Robotics: A Noob’s Guide to

Things that Move Around

1
What Exactly are We Trying to do?
Introduction Cyber-Physical Systems
• Move stuff around with a piece you write and manifest in physical world.

• Program ‘behaviors’ to a simple robot and see how it affects how it interacts
with surroundings.

Digital Electronics
• Understand how individual bits (0s and 1s) behave as voltage signals.

• Interface sensors, actuators, driving circuits and powering them up.

Perception
• Gather data about real, physical world with simple sensors.

• Interpret digital signals and make sense out of it and see how it describes
the surroundings.
What Exactly are We Trying to do?

Get a Glimpse of What's Under the Hood


• See how a microcontroller (ATMega 328) works without the gobbledygooks of
embedded system architecture.

• Master Arduino, the holy grail of rapid prototyping and simplifying physical
computing (It’s easier than it sounds).

• Get a bird’s eye view of how devices communicate with each other and how
programs translate to electrical signals.

And Most Importantly . . .


• Get your hands dirty, the Plaksha way, and have tons of fun in the
process.

• And make a robot in the process, I guess?


Prerequisites for the Workshop
Hardware Software
• The kit that you are provided with • Arduino IDE for your OS

• Some double-sided tape https://www.arduino.cc/en/software)

• A PC with active internet connection

Set of Skills

• Some basic understanding of some programming language

• You must know how to use double-sided tape :)

• Lots of elbow grease


What is This Robot Made of?

Well, basically stardust, just like you!

However, as an engineering student, you deserve a better description

Basically, there are three things that make this robot a robot:

Some sensors to gather information about the


physical world

Actuators that enable the robot to move around


and do things in the physical world

A “brain” that processes all this information in a hurry


(like you before the end-sem exam) and makes
decisions
The Eyes (Well, Ears)
Of some 900 species of bats, more than half rely on
echolocation to detect obstacles in flight!

• Echolocation - the active use of sonar (SOund Navigation


And Ranging) along with special morphological (physical
features) and physiological adaptations - allows bats to
"see" with sound..

• The robot uses pretty much the same mechanism to


locate obstacles (does it make it batmobile? )

• HC SR-04 ultrasonic sensor enables our little batmobile do


the same, only cooler.
The “Eyears” (That’s a Better Word)

HC SR-04 has a transmitter that sends ultrasonic pulses and a receiver to detect the pulses
that reflect from Cheems (we don’t want the robot to hit Cheems, do we?) and the distance
can be calculated form the time delay, provided that the acoustic velocity is known.
The “Eyears”

HC SR-04 has 4 pins:

Vcc: 5V pin to power up

Ground Pin: Keep your feet firmly on the ground while you wield great power!

Trigger Pin: Used to initialize measurement by transmitting ultrasonic waves by


keeping this pin high for 10us.

Echo Pin: Goes high for a specific time period equivalent to the time it takes for
the wave to return from Cheems.
Proper Eyes (But Simpler)
IR sensor for “seeing” stuff:
Uses reflected IR rays to estimate detect differences in color (reflectivity) on the
floor, enabling the robot to trace a line.
The Muscles
Brushed PMDC motors: Not the most efficient, but certainly the simplest to begin with

• Geared to provide a lower speed and greater torque for any given power input.

• Speed is controllable by controlling the power input.


The Muscles
Controlling the Muscles
Controlling the Muscles (Direction)

Direction of force (thereby torque) is dependent on current,


given by Flemings left hand rule.

Current can be reversed by changing polarity across motor


terminals.

An H bridge makes this happen with 4


switches, as shown here.

Combination of switches determines the


polarity and hence direction.
Controlling the Muscles (Speed)

It’s tempting to use a variable resistor/potentiometer to drop voltage or reduce current and
thereby power.

However, that is waste of power (resistive heating) and certainly not the Plaksha way.

Pulse Width Modulation (PWM)


Controlling the Muscles (Speed)
Implementing PWM to control a DC motor

On/Off signals (0s and 1s) can be manipulated by


a microcontroller.

Insufficient to drive a motor.

A transistor (magical switch from the heavens)


could save the day.

These pulses can be used to turn a transistor on,


allowing greater voltages/currents across the
motor.

The duty cycles on the output will be


proportional to the input (low power) PWM.
Controlling the Muscles (Both Direction & Speed)

If the switches of the H-bridge are electrically controllable (magical


switches from the heaven), a microcontroller could easily control
direction and speed simultaneously.

The scary looking diagram on the


right is essentially the same
diagram on top, but cooler.

Luckily, the motor driver comes


pre-built, with all this fancy stuff
hidden from you.
The Brain (ATMega 328)

ATMega Microcontrollers belong to the AVR family of


microcontrollers and is manufactured by Atmel
Corporation. An ATMega Microcontroller is an 8-bit
microcontroller with Reduced Instruction Set (RISC) based
Harvard Architecture.

Uno variant of Arduino is built around this cute little guy


(or girl, or unicorn, let’s not assume gender).

A microcontroller an integrated circuit that contains a microprocessor along with memory and
associated circuits and that controls some or all the functions of an electronic device (such as a
home appliance) or system.

English Translation: Programmable small thingy (which you can have fun with)
Arduino: The Skull for the Delicate Brain
Arduino simplifies using a microcontroller by providing ways to flash programs, an easy language to
talk to ATMega328 and hiding all low-level electronic details like power management.
Cherry on top, it saves you lots of soldering and frying some components.

Chad Arduino Fragile ATMega 328

Gimme USB cable and send me to war! Solder bad, me ded


What is Arduino and What’s the Big Deal About it?

What Arduino team tells you: Arduino is an open-source electronics rapid-prototyping


platform based on easy-to-use hardware and software, utilizing microcontrollers from Atmel.

Translation to English: It’s a cool board you can program and have fun controlling things with.
Setting up the PC
Step I
• Download the IDE, it’s free, although you can donate to the Arduino team.

• Basically, accept all terms and conditions in the license agreement (it’s engineering
blasphemy to read them) and install the IDE for Windows, Linux, or Mac.

• This is possible with the GUI, for windows and Mac. For Linux, open Terminal and type
sudo apt install arduino and press enter.

The apt repository is not up to date but is good enough for this workshop. For detailed
information, visit https://www.arduino.cc/en/Guide/Linux and follow the steps.

Step II
• Plug in the USB cable and connect Arduino to your PC.

• You do not need to provide power to the Arduino, as the USB provides 5V up to 2A.
Setting up the PC
Step III

• Get the COM port number.

For Windows:
Open device manager (search this in
start menu)

In the Device Manager window, look for a


device under “Ports
(COM & LPT)”, and chances are the Arduino
will be the only device on the list
Setting up the PC
For Windows:
Arduino won’t always be recognized automatically. If your Arduino is not recognized. then
uninstall the driver, remove the Arduino, reinsert the Arduino, find the unrecognized device, right
click “Update driver”, and then click “Search automatically”.
Setting up the PC
For Mac:
Open terminal and type: ls /dev/*

Note the port number listed for /dev/tty.usbmodem* or /dev/tty.usbserial*


The port number is represented with * here.

Unplug and re-plug to find the device

For Linux:
Open terminal and type: ls /dev/*

Note the port number listed /dev/ttyUSB* or /dev/ttyACM*


The port number is represented with * here.

Unplug and re-plug to find the device


Configuring Arduino IDE
Go to Tools > Board > Arduino/ Genuino Uno to select the board as Uno (that’s the variant of
Arduino you’re provided with) and follow a similar procedure to select the COM port.
Line Follower Logic
Umm, Thank You, I Guess?

Have Fun Building Robots!

Disclaimer: Any action you take upon the information you


find here is strictly at your own risk. Plaksha University,
Professors or Tas won’t be accountable for Skynet and a
possible robot apocalypse (T 800 would be cool tho).

You might also like