You are on page 1of 68

LAB SESSION I

Proposed Solutions

Sensor Based Guidance

Image Based Guidance


Microprocessor vs Microcontroller
Microcontroller
Amicrocontrolleris a small computer on a singleintegrated
circuitcontaining a processor core, memory, and
programmableinput/outputperipherals.
8051
PIC
Atmel AVR
PIC vs AVR vs 89c55

PART NO. FLASH (KB) SRAM (B) EEPROM (B) MAX FREQ IO PINS PWM ADC

PIC16F77 14 368 No 20MHz 36 1 x 10bit 8x10bits

ATMEGA164P 16 1024 512 16MHz 32 3 x 16bits 8x10bits

AT89C55WD 20 256 0 24MHz 32 No No


AVR
The AVR is a modified Harvard architecture 8-bit RISC
single chip microcontroller which was developed by Atmel
in 1996.

The AVR was one of the first microcontroller families to use


on-chip flash memory for program storage, as opposed to
one-time programmable ROM, EPROM, or EEPROM used by
other microcontrollers at the time.
Basic Families (6 groups)
tinyAVR theATtiny series
0.516kB program memory
632-pin package
Limited peripheral set

megaAVR the ATmega series


4512kB program memory
28100-pin package
Extended instruction set (multiply instructions and instructions for handling larger
program memories)
Extensive peripheral set

XMEGA the ATxmega series


16384kB program memory
4464100-pin package (A4, A3, A1)
Extended performance features, such as DMA, "Event System", and cryptography
support.
Extensive peripheral set with DACs
Arduino Board
An Arduino board consists of an Atmel 8-bit AVR microcontroller with
complementary components to facilitate programming and incorporation
into other circuits.
Built-in Libraries to facilitate Programmers
Allowing the CPU board to be connected to a variety of interchangeable
add-on modules known as shields
Atmega328
Microcontroller:ATmega328
Operating Voltage:5V
Input Voltage (recommended):7-12V
Input Voltage (limits):6-20V
Digital I/O Pins:14 (of which 6 provide PWM output)
Analog Input Pins:6
DC Current per I/O Pin:40 mA
DC Current for 3.3V Pin:50 mA
Flash Memory:32 KB (ATmega328) of which 0.5 KB
used by bootloader
SRAM:2 KB (ATmega328)
EEPROM:1 KB (ATmega328)
Clock Speed:16 MHz
Arduino UNO
(Atmega328)
Uno provide 14 digital I/O pins, six
of which can producepulse-width
modulatedsignals, and six analog
inputs.
Programming of Arduino

// the setup routine runs once when you press


reset:
void setup()
{
}

// the loop routine runs over and over again forever:


void loop()
{
digitalWrite
int led = 9;

void setup() {

pinMode(led, OUTPUT);
}

void loop() {
digitalWrite(led, HIGH);
delay(1000); // wait for a second
digitalWrite(led, LOW);
delay(1000); // wait for a second
}
DC Motor
BreadBoard
Rotating Motor in 1
direction
int led = 9;

void setup() {

pinMode(led, OUTPUT);
}

void loop() {
digitalWrite(led, HIGH);
delay(1000);
digitalWrite(led, LOW);
delay(1000);
}
Rotating Motor in both direction
int mot1= 5;
int mot2= 6;

void setup() {

pinMode(mot1, OUTPUT);
pinMode(mot2, OUTPUT);
}

void loop() {
, digitalWrite(mot1, HIGH);
digitalWrite(mot2, LOW);
delay(1000);
digitalWrite(mot1, LOW);
digitalWrite(mot2,HIGH);
delay(1000);
}
Larger DC Motors
Servo Motor
Servo Motor with
Arduino
Interfacing of Servo
Motor
#include <Servo.h>

Servo myservo;

int pos = 0;

void setup()
{
myservo.attach(9);
}

void loop()
{
myservo.write(pos);
delay(15);
}
Interfacing of Servo
Motor
#include <Servo.h>

Servo myservo;

int pos = 0;

void setup()
{
myservo.attach(9);
}
void loop()
{
for(pos = 0; pos < 180; pos += 1)
{
myservo.write(pos);
delay(15);
}
for(pos = 180; pos>=1; pos-=1)
{
myservo.write(pos);
delay(15); }}
Potentiometer with Arduino

void setup() {

Serial.begin(9600);
}

void loop() {

int sensorValue =
analogRead(A0);
float y=5.0*sensorValue/1023.0;

Serial.println(y);
delay(1000);
Distance Measurement

Infrared Sensors

Sonar Sensors
Sonar Sensor
(Max Sonar ez0 Mb 1000)

const int pwPin = 7;


long pulse, inches, cm;
void setup() {
Serial.begin(9600);
}
void loop() {
pinMode(pwPin, INPUT);
pulse = pulseIn(pwPin, HIGH);
inches = pulse/147;
cm = inches * 2.54;
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(500); }
Ultrasonic Sensor HC-SR04
#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED

Int maximumRange = 200;


Int minimumRange = 0;
long duration, distance;

void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin, OUTPUT);
}

Ultrasonic Sensor HC-SR04


void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = duration/58.2;
if (distance >= maximumRange || distance <= minimumRange)
{
Serial.println("-1");
digitalWrite(LEDPin, HIGH);
}
else {
Serial.println(distance);
digitalWrite(LEDPin, LOW);
}
delay(50);
}
Color Detection

ADJD-S371 Using LEDs


Color Sensor
Color SensorTCS 3200

#include <TimerOne.h>

#define S0 6
#define S1 5
#define S2 4
#define S3 3
#define OUT 2
Special Category & Scenario-3
IMAGE BASED
GUIDANCE
SBC
Single-board computer (SBC) is a complete computer built
on a single circuit board, with microprocessor(s), memory,
input/output (I/O) and other features required of a
functional computer

BeagleBoard
Pandaboard
Raspberry Pi
Panda Board
BeagleBoard

Has all the functionality of a basic


computer
Processor in GHz
Can run Linux, RISC OS, Symbian and
Android
Video out is provided through S-Video
or HDMI connections.
USB slots
Ethernet Port
A SD/MMC card slot supporting
USB and RS-232 serial connection
3.5 mm jacks for audio in/out are
provided.
Raspberry Pi
The Raspberry Pi is a credit-card-sized single-board computer
Step 1 (MATLAB)
How do we determine the distance between the Robot and
the Object?????

1. Loading the Image:


i=imread('update2.tif');
imshow(i)
Step 2 (MATLAB)
2. Detection of Blue Object
diffFrameBlue = imsubtract(i(:,:,3), rgb2gray(i));
% Get blue component of the image
diffFrameBlue = medfilt2(diffFrameBlue, [3 3]);
% Filter out the noise by using median filter
binFrameBlue = im2bw(diffFrameBlue, 0.15);
% Convert the image into binary image with the blue objects as white
imshow(binFrameBlue)

erodedImage = bwmorph(binFrameBlue , 'shrink',Inf);


imshow(erodedImage)
[yblue,xblue] = find(erodedImage)
Image based guidance
3. Detection of Red Object
diffFrameRed = imsubtract(i(:,:,1), rgb2gray(i)); %
Get blue component of the image
diffFrameRed = medfilt2(diffFrameRed, [3 3]); %
Filter out the noise by using median filter
binFrameRed = im2bw(diffFrameRed, 0.4); %
Convert the image into binary image with the blue
objects as white
imshow(binFrameRed)
erodedImage = bwmorph(binFrameRed ,
'shrink',Inf);
imshow(erodedImage)
[yred,xred] = find(erodedImage)
Image based guidance
4. Detection of Black Object
black=rgb2gray(i);
black12=[black==0];
imshow(black12)
erodedImage = bwmorph(black12 ,
'shrink',Inf);
imshow(erodedImage)
[yblack,xblack] = find(erodedImage)
imshow(i)
Image based guidance
5. Distance between Robot and Blue Object
p1=[xblue yblue];
p2=[xblack yblack];
x_move=p1(1)-p2(1)
y_move=p1(2)-p2(2)

6. Distance between Robot and Red Object


p1=[xred yred];
p2=[xblack yblack];
x_move=p1(1)-p2(1)
y_move=p1(2)-p2(2)
Hardware Structure
ROBOSPRINT
2012
STEP
RESEARCH
1
It is not always winning that
amazes people but it is your idea
that matters
ROBOSPRINT
2012
STEP
Robot
2
The mostDesign
simplest and the best
design is usually the most perfect
one
Simple 3
Wheels + Light weight
Gearbox
+ Simple to design
Gearbox

+ Inexpensive
Two wheel
drive
Motor(
s)
Motor(
s)
Driven
Wheel

+ Easy to design
+ Easy to build
+ Light weight
+ Inexpensive

- Not much power


- Will not do well on
ramps
- Less able to hold Caster
position
Four wheels two
gearboxes Driven
Wheel
s
Motor( Motor(
s) s)

+ Easy to design Chain


+ Easy to build or belt
+ Inexpensive
+ Powerful
+ Strong and stable

- Turning is
Driven
difficult Wheel
- Adjustments s
needed
Four wheels
four gearboxes Driven
Wheel
s
Motor( Motor(
s) s)

+ Easy to design
+ Easy to build
+ Powerful
+ strong and stable
+ Many options

- Heavy Driven
- Costly Wheel
Motor( Motor( s
s) s)
TANK DRIVE
Gearbox Gearbox

+ Powerful
+ VERY Stable

- HEAVY
- Inefficient
- EXPENSIVE
- Hard to
maintain
HOLONOMIC
DRIVES
HOLONOMIC
DRIVES
4 Wheel and 3 Wheel designs
Simple Mechanics
Immediate Turning
Freedom of movement
Use Dual Wheels to avoid
nervous drives
HOLONOMIC
DRIVES
Mecanum
Simple
Mechanics
Freedom of
movement
4 independent
wheels
Difficulty on
inclines
Slipping Issues
HOLONOMIC
DRIVES
Rota Caster
Simple
Mechanics
Freedom of
movement
3 or 4
independent
wheels
Difficulty on
inclines
HOLONOMIC
DRIVES
Swerve or Crab
All wheels steerable
High grip Wheels
No Friction Losses
Ability to Push or Hold
Wheels are Simple
Complex Design
Mechanical Issues
Wheel Turning Delay
Omni Directional
System
Mecanum
wheels
Rota Caster
wheels
Important
POINTS
CG or Centre Of
Gravity
Robot Mass is
represented at one point
Higher parts should be
light weight and lower
parts should be heavy
within reasons
Important
POINTS
CG or Centre Of
Gravity
Batter
y
motor
Ms Mobile s
pump,
etc.
Battery
Mr.
motors
Tippy
pump, etc.
Important
POINTS IS BAD
SLIPPAGE
Unnecessary
movement
Slippage is increased
when special wheels are
used
Good mechanical
design and good CG
management and weight
balancing decreases
Important
POINTS
Better Wiring
Believe it or not better
wiring can helps a lot
Use thick wires for
motors
Avoid mixing signal
and power wires
Use aluminum foil to
avoid noise.
Important
POINTS
NOISE IS BAD
REDUCE IT OR
ELSE
ROBOSPRINT
2013
STEP
Importance of motor
selection3
Stall current, RPM, torque,
power
GEAR RATIOS
Diameter
2:1 RIGHT
LEFT WHEEL
WHEEL
1x
2x Torque
2x
Torque
Speed
1x Rotates
Speed twice the
Left
wheel in
a single
rotation
Motors
ROBOSPRINT
2012
STEP
Sensors, Motor Drivers,
4 Products
Other
Know how technology
increases performance and
reliability
Websites which are usefull
www.arduino.cc
www.pandaboard.org
www.beagleboard.org
www.rasberrypi.org
www.roboticspk.com
www.robocave.pk
www.digipak.org
www.creativeelectron.net
ROBOSPRINT
2012
Final
Words
ROBOSPRINT
2012
Questions?
ROBOSPRINT
2012
THANK
YOU

You might also like