Professional Documents
Culture Documents
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.