Vous êtes sur la page 1sur 19

Robotics Tutorial

Every autonomous robot has a processor which accepts input signals from
various sensors, analyzes them and decides an appropriate action.

Here we will be using a microcontroller as a processor.

MICROCONTROLLER
Data storage and processing is an integral part of any automatic control
system.The need to have a device ,so called “microcontroller”,which allows
controlling and sequencing of these machines and processes. Further ,with
help of microcontroller,it is possible to carry out simple arthimetic and logical
operations.

Most commonly used microcontrollers used are:

 80C51

 Microchip PIC 16XX or PIC18xx

 Atmega AVR

Below is the information on 80C51 By Philips

P89V51RD2
The P89V51RD2 is an 80C51 microcontroller with 64 kB Flash and 1024
bytes of
data RAM.

Features
 1,80C51 Central Processing Unit
 5 V Operating voltage from 0 to 40 MHz
 64 kB of on-chip Flash program memory with ISP (In-System Programming)
 Supports 12-clock (default) or 6-clock mode selection via software or ISP
 SPI (Serial Peripheral Interface) and enhanced UART
 Four 8-bit I/O ports with three high-current Port 1 pins (16 mA each)
 Three 16-bit timers/counters
 TTL- and CMOS-compatible logic levels
 Crystal of frequency 12MHz is used.

PIN DIAGRAM

I/O PORTS
 80C51 has 4 I/O ports
 Each port is 8 bit wide

SYMBOL PIN NO. DESCRIPTION


PORT 0 P0.0-PO.7 39-32 Port 0 is an 8-bit
open drain bi-
directional I/O
port. Port 0 pins that
have ‘1’s written to
them float, and
in this state can be
used as high-
impedance inputs.
Port 0 is also the
multiplexed low-
order address and
data bus during
accesses to external
code and data
memory.
PORT 1 P1.0-P1.7 1-8 Port 1 is an 8-bit bi-
directional I/O port
with
internal pull-ups. The
Port 1 pins are pulled
high by the
internal pull-ups
when ‘1’s are written
to them and can
be used as inputs in
this state.For making
them o\p 0’s are
written to them
PORT 2 P2.0-P2.7 21-28 Port 2 is an 8-bit bi-
directional I/O port
with
internal pull-ups. The
Port 1 pins are pulled
high by the
internal pull-ups
when ‘1’s are written
to them and can
be used as inputs in
this state.For making
them o\p 0’s are
written to them

PORT 3 P3.0-P3.7 10-17 Port 1 is an 8-bit bi-


directional I/O port
with
internal pull-ups. The
Port 1 pins are pulled
high by the
internal pull-ups
when ‘1’s are written
to them and can
be used as inputs in
this state.For making
them o\p 0’s are
written to them and
every pin of port 3
has an alternative
function which is
mentioned below

P3.0 10 RXD: serial input


port
P3.1 11 TXD: serial output
port
P3.2 12 INT0: external
interrupt 0 input
P3.3 13 INT1: external
interrupt 1 input
P3.4 14 T0: external count
input to
Timer/Counter 0
P3.5 15 T1: external count
input to
Timer/Counter 1
P3.6 16 WR: external data
memory write
strobe
P3.7 17 RD: external data
memory read
strobe

PIN DESCRIPTION
SYMBOL PIN NO. TYPE DESCRIPTION
PSEN 29 I\O Program Store
Enable: PSEN is
the read strobe for
external program
memory. When the
device is executing
from internal
program memory,
PSEN is inactive
(HIGH). When the
device is executing
code from external
program memory
PSEN is active low
RST 9 I Reset: While the
oscillator is running,
a HIGH logic state
on this pin for two
machine cycles will
reset the device
EA 31 I External Access
Enable: EA must be
connected to VSS
in order to enable
the device to fetch
code from the
external program
memory. EA must
be strapped to VDD
for internal program
execution
XTAL1 15 I Crystal 1: Input to
the inverting
oscillator amplifier
and
input to the internal
clock generator
circuits.
XTAL1 14 O Crystal 2: Output
from the inverting
oscillator amplifier
Vdd 40 I Power supply
GND
Vss 20 I

Once you are familiar with 80C51 hardware ,the next step is programming.

You have a choice between assembly language or embedded C for


programming your microcontroller.

In this tutorial we will cover embedded C .

I f you are using kits given by TRI use TRIC as compiler and and flashmagic for
burning the hex file.

In system programming (ISP)is used and we will be using bootloader which is a


small program which resides on microcontroller and uC controls the
programming through serial port and no separate hardware is required.

Steps for using TRIC is similar to as shown below for keil but instead for keil
you will use TRIC.

Flash magic is used for burning


 Supports all 89XX series of Philips microcontrollers and their different
modes

 Communicates via COM port

 User selectable baud rates

If you are using Atmel uC you use KEIL

uvision keil is used as programming tool .


Steps for using keil:

1.Open keil and select project(menu bar)->new project


2.Give a name to your project and save it.

3.Select Atmel->AT89C51
4.After device selection a pop up will appear asking for inclusion of file ,select
NO.

5.Select new from file(menu bar) and select new ,a blank page would
appear.Save that page with extension “.c”example motor.c.
6.Add file to your project by clicking selecting target 1 in project
workspace-.right click on source group1 a ->select add file and browse to the
location of your file and add it.

7.Write your program and and then build it by selecting “build target” from
project(menu bar).

8.For creating hex file choose “options of target” -> selct create hex file in
output tab.
Sample program for turning 2 motors alternatively

#include <reg51.h> //include header file

sbit ENABLE=P1^0; //assigning nme to a particular bit

sbit MTR_1=P1^1;

sbit MTR_2=P1^2;

void MSDelay(unsigned int value); //function declaration

void main()

while(1) //infinite loop

ENABLE = 1; //enabling motor driver

MTR_1= 1; //turning on motor1


MTR_2= 0; //turning off motor 2

MSDelay(5000); //5000ms or 5s delay

MTR_1= 0; //turning off motor1

MTR_2= 1; //turning on motor2

void MSDelay(unsigned int value) //delay function sub routine

unsigned char x, y;

for(x=0;x<1275;x++)

for(y=0;y<value;y++)

}}

The above tutorial is specifically designed for 8051 microcontroller,teams are


allowed to use any microcontroller either PIC or AVR.

Use of assembly language is prohibited.


Compilers

PIC-mikroc

AVR-AVR studio

8051-keil

Programmer

For burning the “hex file” into microcontroller you need a hardware for
burning the code.

AVR:USB programming kit is easily available.

PIC:Microchip PIC kit2 is available.

For 8051 and PIC16fxx program is burned using serial communication and if
you are using a laptop you need a serial to USB converter which is easily
available in market.

Book reference:Mazidi for 8051

For data sheets visit site :www..alldatasheets.org

Sensors
When u build an autonomous robot sensors are required for interacting with
external environment and taking the appropriate action ofter receiving inputs
from sensors.

We will use 2 types of sensors:

1.For detecting white line on black surface or vice versa.

2.Obstacle detecting sensors.

Line detection sensors


These are infrared sensors and are used for diffrentiating between white lines and black
surface.

Blackened LED is transmitter and it transmits infra-red rays which hits the surface and after
reflection from the surface it is received by reciver(transperent LED),since differnt colors
have different emmisivity it can easily distinguish between black and white surface.

These sensors can be callibrated by adjusting the potentiometer on the top of the sensor
module.

When sensors is on (led on sensor glows) O/P of sensor is HIGH i.e. +5V .

Precaution:Do not use 2 sensors close to each ,they might interfere with each other.

Obstacle detecting sensors

These are infrared sensors and are used for detecting the obstacle.
These sensors can be callibrated by adjusting the potentiometer on the top of the sensor
module.

When sensors is on (led on sensor glows) O/P of sensor is LOW.


Precaution:Do not use 2 sensors close to each ,they might interfere with each other.

5.DC motor:
It is an electromechanical device.Magnetic coils are excited by supplying
voltage.

They are 2 wires (RED and BLACK) ,the working of motor is controlled by giving
right combination of volatge to these 2 wires.

R B O/P

H L Motor rotates in one direction


L H Motor rotates in opposite direction

H H Motor stops

H=+5V

L=GND

R=Red wire

B=Black wire

For turning right stop your right motor and move forward your left motor.

For turning left stop your left motor and move forward your right motor.

The above mechanism is called differential drive.

When we use multiple motors we use a motor driving IC:

Motor Driver

L293D is Quadruple Half H-Driver


H bridge is used as switch for driving multiple motors. It is used for controlling
current and voltage supply for DC motor.
It has 4 driving channels.

Channel1 Channel2 Channel3 Channel4


Input 1A 2A 3A 4A
Output 1Y 2Y 3Y 4Y

4 DC motor or 2 stepper motor can be used with this driver.


Drivers are enabled in pairs with drivers 1 and 2 enabled by 1,2EN and drivers 3 and
4 enabled by 3,4EN.

When an enable input is high, the associated drivers are enabled, and their outputs
are active and in phase with their inputs. .

When the enable input is low, those drivers are disabled, and their outputs are off
and in a high-impedance state.

Pin number 4, 5, 13, 12 are GND

The voltage at which you want to run the motor is given to pin number 8
i.e.VCC2,this voltage can either be your battery potential (9V) or 5V depending upon
the motor specification and speed requirement.

VCC1-Logical supply voltage (+5V)

For using DC motor with L293D connect red wire of motor to O/P of channel

For turning on motor supply +5V to input of particular channel.

For using 2 DC motor we can use any 2 channels.


Voltage regulator
They are used for getting constant DC voltage .78XX is series for positive
voltage regulators,here XX is the O\P voltage .Since we are working on +5V
logic level we will be using 7805.For negative voltage use 79XX series.

IC used :7805

This IC supplies constant +5V

Left pin is I/p pin and is connected to battery.

Middle pin is GND

Right pin is O/P

Above figure is the test circuit.

I/P voltage>=Vout +2

So if we require +5V , the input should be greater than 7V.


Precaution: To avoid overheating input voltage should not be greater than 12V
or use a heat sink.

For reference you can visit:

www.embedded.com

www.sonsivri.com

Prepared by Ayush Dewan, for any queries contact at:pisces.aayush@gmail.com,09719755942

Vous aimerez peut-être aussi