27220 Parallax Inc, 27220 Datasheet - Page 159

BOOK STAMPWORKS

27220

Manufacturer Part Number
27220
Description
BOOK STAMPWORKS
Manufacturer
Parallax Inc
Datasheet

Specifications of 27220

Accessory Type
Booklet
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
StampWorks
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Not applicable / Not applicable
The value for the constant Scale is determined empirically. After constructing the
circuit, insert appropriate DEBUG statements to display the raw potentiometer
readings from both sides (they may not match exactly due to component
differences). Take the lower of the two values and divide that into 500 (desired
output). Convert this fractional value to the */ operand by multiplying by 256.
Example:
The difference between the two scaled RCTIME values is added to the centering
position of 1500 (microseconds). Remember that on the BASIC Stamp 2 module,
PULSOUT works in two-microsecond units. What this means is that the pulse width
value needs to be divided by two in order to create the correct pulse output for the
servo. This is done by using the */ with the PwAdj constant set to $0080 (0.5).
This program demonstrates that the BASIC Stamp does indeed work with negative
numbers. You can see the value of sPos by inserting this line after the calculation:
Negative numbers are stored in two’s complement format. The SDEC (signed
decimal) modifier prints standard decimal with the appropriate sign.
Challenge
Replace the potentiometer with two photocells and update the code to cause the
servo to point toward at the brightest light source.
Can you think of a method that uses two potentiometers and two servos to create a
sun tracker?
Raw RCTIME value:
DEBUG Home, "Position: ", SDEC sPos, "
645
250 / 645 = 0.775
0.775 x 256 = 198 (this is the value called Scale)
"

Related parts for 27220