You are on page 1of 6

ROLLING ROBOT NAVIGATION USING PIC16F877A

Experiment no. ___


Name: __________________________________
Course/Yr: ________
Day/Time: ____________
I. OBJECTIVES
1. To demonstrate basic navigation techniques of rolling robot using Basic Stamp
Microcontroller or LiKHABot
2. To be able to use basic formula to calculate the number of pulses to deliver to
make the robot to travel a predetermined distance.
3. To write a simple program that enables subroutines that can be used to be
used all over and over again without making long programs.
II. BASIC CONCEPTS
Robots, either be walking, bipedaling, or rolling, can be programmed in variety
of ways. The maneuvering techniques depend on how you control the servos. Luckily,
servos are precise due to its potentiometer connected inside it that center its
alignment. For most servos delivering 1.5 ms stops the servos and increasing it to 2
ms will rotate the servo counterclockwise direction and decreasing it to 1 ms will
rotate the servo clockwise direction.
A pulsout pin, pulseduration is the command used to rotate, or stop the servo.
A convention pin allocation used in this experiment is pin 13 for the left servo and pin
12 for the right servo. You can use another pin assignment for your right or left
servos, just be consistent throughout the experiment and other experiments. Here
are the basic maneuver techniques:
Forward:
PULSOUT LWheel, 200
Backward/Reverse: PULSOUT
LWheel, 100
PULSOUT RWheel, 100
PULSOUT
RWheel, 200
Right Turn 90 deg : PULSOUT LWheel, 200
Left Turn 90 deg :
PULSOUT
LWheel, 150
PULSOUT RWheel, 150
PULSOUT
RWheel, 100
Stop:
PULSOUT LWheel 150
PULSOUT RWheel, 150
There are two ways how to calibrate a continuous servos: (1) manually
centering it by adjusting its potentiometer, and (2) by using digital (or virtual)
oscilloscope by viewing the selected pulse duration to obtain a 1.5 ms pulse width on
a rectangular pulse. The second step is quite expensive but more accurate. If you
happen to convert a standard servo into continuous servo and not able to connect a
potentiometer outside its case (or modify its internal circuitry for centering) use the
second step.
III. TOOLS AND EQUIPMENT
(1) PC
(1) Connecting wires
(1) gm LIKHA Robot
IV. PROCEDURE
1. Calibration of Servos. A continuous servo, that is, that perform a 360 degrees
rotation as opposed to a standard servo which can only make 180 degrees
rotation, has potentiometer outside its casing. Adjusting it to obtain pulse
duration of 750 will give us a 1.5 ms to stop the movement of servo. Adjust
gradually the potentiometer of the continuous servos connected in Pin 12 in
your robot (be careful not to press too hard as you may break the servos) and

run this simple program. If your servo is still moving it means that it is not yet
at 1.5 ms. If your rotation is on a counter direction, just bring your
potentiometer adjustment a little backward.
FileName: SERVO_CENTER
define LOADER_USED 1
SYMBOl Rwheel = portb.5
symbol Lwheel = portb.6
symbol RLed = portd.3
symbol LLed = portc.5
symbol Beef = porta.5
symbol Neck = portb.7
counter var byte
move var byte
x var byte
gosub ncenter
Main:
for counter = 1 to 100
pulsout Rwheel, 150
pause 20
next
goto main
'-----------------subroutines-----------------------Ncenter:
move = 40
for counter = 1 to move
pulsout neck,150
pause 30
next
return
2. Do step (1) for your servo connected in Pin 13 (Lwheel). Replace the Pin
assignment in PULSOUT command from 12 to 13 (or replace Rwheel by
Lwheel) and re-run the program.
3. Are your two servos calibrated? ____________
4. The BUZZER is connected to a transistor amplifier. Use the beef port to
produce a sound. Enter the code, and run the program using the MicroCode
Studio Plus.
FileName: Tunog
DEFINE LOADER_USED 1
blg var byte
main:
for blg = 1 to 100
Sound PORTA.5,[100,10,100,10]
pause 1000
next

goto main
The command Sound Port #, [Note, Duration, {Note, Duration}] gives out
sound at note frequency for duration given as second parameter.
5. Change the Note to 1000 Hz, and duration of 100 ms, with the second set of
parameters unchanged. Re-run the program and observe how the sound
changes. Record your observation. Can you hear the sound produced at 1000
Hz?
_______________________________________________________________________________
________________________________________________________________________
In your Physics class, what is the range of frequency sound can human hear?
_______________________________________________________________________________
________________________________________________________________________
What
is
the
voice
(audio)
range
of
a
telephone
set?
_______________________________
6. RUNNING THE ROBOT IN A SQUARE PATTERN. Enter the code in your Microcode Studio
Plus. Observe how the robot perform and study the program as it is
performed/followed by the robot. For your information, comment is added in
the code.
FileName: SquareMove
DEFINE LOADER_USED 1
Symbol Rwheel = portb.5
symbol Lwheel = portb.6
symbol RLed = portd.3
symbol LLed = portc.5
symbol Beef = porta.5
symbol Neck = portb.7
counter var byte
move var byte
x var byte
RunStatus
DATA $00
' run status
temp
VAR
Byte
' -----[ Initialization ]------------------------------------------------------gosub ncenter
'Run_Check:
' user Reset button as On-Of
READ RunStatus, temp
' read current status
temp = ~temp
' invert status
WRITE RunStatus, temp
' save status for next reset
IF (temp = 0) THEN
HIGH rled
PAUSE 500
GOTO main
' run now?
ELSE
stop
ENDIF
'------------------------------------------------------------------------------Main:
'move = 200

gosub fwd
'forward drive
move = 75
'depending on the surface
'much friction causes a higher turn number
gosub LTurn
'make 90 degrees left turn
gosub fwd
move = 75
gosub LTurn
'make 90 degrees right turn
gosub fwd
'backward or reverse drive
move = 75
gosub Lturn
gosub fwd
move = 75
gosub Lturn
'end where it started
GOSUB Hinto
Stop
'-----------------subroutines-----------------------Ncenter:
center the neck
move = 40
for counter = 1 to move
pulsout neck,150
pause 30
next
return
fwd:
move = 200
for counter = 1 to move
pulsout Rwheel,100
'50
pulsout Lwheel, 200 '250
pause 10
next
return
LTurn:
left turn 90 degrees
for x = 1 to move
pulsout Rwheel,100
pulsout Lwheel, 100
pause 10
next
return
RTurn:
right turn 90 degrees
'move = 62
for x = 1 to move
pulsout Rwheel,200
pulsout Lwheel, 200
pause 10
next
return
rwd:
reverse direction
move = 200
for counter = 1 to move
pulsout Rwheel,200
pulsout Lwheel, 100
pause 10
next

return
Hinto:
stop
move = 20
for counter = 1 to move
pulsout Rwheel,150
pulsout Lwheel, 150
pause 10
next
return
7. (a) In SQUAREMOVE program, what do you call a function which is not a part
of the MAIN program but when called redirect it to that function?
_________________________________________________________________________
(b) What is the pulse width of a servo for a stop?
_________________________________________________________________________
(c) What is the pulse width of a servo for a forward on right servo? Left servo?
Right Servo: ______________ Left Servo: ______________________
(d) What is the pulse width for a servo for a reverse on right servo? Left servo?
Right Servo: ______________ Left Servo: ______________________
(e) The program output (or demonstration) may not be a perfect square
pattern. Site any reason why is that so?
_______________________________________________________________________________
________________________________________________________________________
8. Modify the program of SQUAREMOVE by adding a command that blink the
corresponding LED when it turns right or left. Write your program at the back
of this paper or on separate paper. Write also your pseudocode or flowchart.

9. Modify the program of SQUAREMOVE so that the robot can move forward
during the first half of the square pattern, but when it performs the second
half, the robot should move in a reverse direction (backward direction). Write
your program at the back of this paper.

10. Make a simple program that causes the robot to navigate in a circular pattern.

You might also like