28123 Parallax Inc, 28123 Datasheet - Page 134

TEXT WHAT'S A MICROCONTROLLER

28123

Manufacturer Part Number
28123
Description
TEXT WHAT'S A MICROCONTROLLER
Manufacturer
Parallax Inc
Type
Programmingr
Datasheet

Specifications of 28123

Style
Book
Title
What's a Microcontroller?
Contents
Whats a Microcontroller? Text
Product
Microcontroller Accessories
Core Processor
PIC16C57c
Flash
128 Bytes
Operating Supply Voltage
9 V
Board Size
31 mm x 16 mm
Lead Free Status / RoHS Status
Not applicable / Not applicable
ACTIVITY #3: CONVERTING POSITION TO MOTION
In this activity, you will program the servo to change position at different rates. By
changing position at different rates, you will cause your servo horn to rotate at different
speeds. You can use this technique to make the servo control motion instead of position.
Programming a Rate of Change for Position
You can use a
this:
The
slowly counterclockwise until it gets to 10 o’clock. Because
FOR…NEXT
in the
pulse gets a little longer each time through the loop. Since the
does the position of the servo’s horn.
FOR…NEXT
make the servo rotate faster. For example, you can use the
FOR…NEXT
PULSOUT
with this code block:
FOR counter = 500 TO 1000
NEXT
Save the program.
Run the program and verify that it rejects values outside the appropriate range
for the servo.
loop, it increases by one each time through. The value of counter is also used
PULSOUT 14, counter
PAUSE 20
loops have an optional
DO
LOOP UNTIL duration > 499 AND duration < 1001
DEBUG "Enter pulsout duration:", CR
DEBUGIN DEC duration
IF duration < 500 THEN
ENDIF
IF duration > 1000 THEN
ENDIF
FOR…NEXT
loop causes the servo’s horn to start at around 2 o’clock and then rotate
command’s
DEBUG "Value of duration must be above 499", CR
PAUSE 1000
DEBUG "Value of duration must be below 1001", CR
PAUSE 1000
loop to make a servo sweep through its range of motion like
Duration
STEP
argument, which means the
argument. The
STEP
counter
STEP
argument can be used to
duration
argument to add 8 to
duration
is the index of the
changes, so
of each

Related parts for 28123