28123 Parallax Inc, 28123 Datasheet - Page 133

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
As in previous examples, the
loop. Up until this example, all the
150 for
control the
delivered to the servo. The end result is that the
servo holds a given position. Up until now, constant values such as 500, 750, and 1000
were also used for the
FOR…NEXT
Your Turn – Setting Limits in Software
The example program doesn’t stop you or anybody else from entering a
duration
be fixed if you are designing this system into a product.
Let’s imagine that this computer servo control system is one that has been developed for
remote-controlling a door. Perhaps a security guard will use this to open a shipping door
that he or she watches on a remote camera. Maybe a college student will use it to control
doors in a maze that mice navigate in search of food. Maybe a military gunner will use it
to point the cannon at a particular target. If you are designing the product for somebody
else to use, the last thing you want is to give the user (security guard, college student,
military gunner) the ability to enter the wrong number and damage the equipment.
To fix this problem, try this:
EndValue
Save the example program ServoControlWithDebug.bs2 under the new name
ServoControlWithDebugYourTurn.bs2.
Replace these two commands:
Take some time to understand this
amazing things you can do with variables in PBASIC command arguments, and it also
highlights how useful a programmable microcontroller like the BASIC Stamp can be.
DEBUG "Enter pulsout duration:", CR
DEBUGIN DEC duration
loop to see where and how these variables are used:
such as 1500, which is not good for the servo. This is a problem that needs to
FOR counter = 1 to pulses
NEXT
EndValue
PULSOUT 14, duration
PAUSE 20
. In this
of the
PULSOUT
FOR…NEXT
FOR…NEXT
counter
command’s
FOR…NEXT
loop. This, in turn, controls how many pulses are
loop, the value of the pulses variable is used to
variable is used as an index for the
FOR…NEXT
Duration
loops have used constants such as 10 or
pulses
loop. It is one of the first examples of the
argument. Look carefully at this
variable controls how long the
FOR…NEXT
PULSOUT

Related parts for 28123