Page 114 · Robotics with the Boe-Bot
FOR counter = 1 TO 244
PULSOUT 12, pulseWidth
PULSOUT 13, pulseWidthComp
PAUSE 20
NEXT
LOOP
How TestServoSpeed.bs2 Works
Three variables are declared,
and
DEBUGIN
PULSOUT
used in a second
PULSOUT
counter
pulseWidth
pulseWidthComp VAR
The
command is used to signal that the program has started.
FREQOUT
FREQOUT 4,2000,3000
The remainder of the program is nested within a
over again. The Debug Terminal's operator (that's you) is asked to enter a pulse width.
The
command stores this value in the
DEBUGIN
DEBUG "Enter pulse width: "
DEBUGIN DEC pulseWidth
To make the measurement more accurate, two
making one
command the same amount below 750 as the other is above 750,
PULSOUT
the sum of the two
PULSOUT Duration
two
commands combined take the same amount of time. The result is that no
PULSOUT
matter the
of your
Duration
same amount of time to execute. This will make the
the Your Turn section more accurate.
This next command takes the pulse width you entered, and calculates a pulse width that
will make 1500 when the two are added together. If you enter a pulse width of 650,
will be 850. If you enter a pulse width of 850,
pulseWidthComp
for the
counter
commands, and
pulseWidthComp
command.
VAR
Word
VAR
Word
Word
pulseWidth
PULSOUT
arguments is always 1500. That ensures that the
command, the
PULSOUT
loop,
FOR...NEXT
pulseWidth
which stores a value that is
, so it will execute over and
DO...LOOP
variable.
commands have to be sent. By
loop will still take the
FOR...NEXT
measurements you will take in
RPM
pulseWidthComp
for the
will
Need help?
Do you have a question about the Boe-Bot and is the answer not in the manual?