28029 Parallax Inc, 28029 Datasheet - Page 94

KIT PARTS SMART SENSORS W/TEXT

28029

Manufacturer Part Number
28029
Description
KIT PARTS SMART SENSORS W/TEXT
Manufacturer
Parallax Inc
Datasheet

Specifications of 28029

Accessory Type
Parts Kit
Product
Microcontroller Accessories
Lead Free Status / RoHS Status
Contains lead / RoHS non-compliant
For Use With/related Products
BASIC Stamp® or Javelin Modules
Lead Free Status / RoHS Status
Lead free / RoHS Compliant, Contains lead / RoHS non-compliant
Other names
28029PAR
Page 82 · Smart Sensors and Applications
Your Turn - A Closer Look at the ScaleConstant and ** Operator
For small input and output ranges, we can examine them with a calculator, pencil and
paper. Let's take 0 to 10 as our input scale, and 0 to 2 as our output scale. The first step
is to figure out what the constant for the
scale constant equation.
There are three elements in the output scale, 0, 1, and 2. There are 11 elements in the
input scale, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and 10. Remembering to round down to the nearest
integer, the result is 19660 which is the constant to use with the
The term
Table 3-2 shows some examples of the BASIC Stamp calculations for each of the values
in the input range for
as multiplying
math processor, it truncates any result to an integer value, effectively rounding down.
Notice how the first four input values result in outputs of zero. Then, when the input
value is 4, the result is 1.19996, which gets rounded to 1. As you perform the rest of the
calculations in the table, notice how the output scale of 2 receives four input elements. If
-1 was not used in the denominator, it would only receive one input element.
Finish the calculations in Table 3-2 for input values from 5 to 10.
19660
ScaleCons
ScaleCons
ScaleCons
ScaleCons
value = value ** 19660
value
÷
65536
tan
tan
tan
tan
value = value ** 19660
by 0.29999 with a calculator. Since the BASIC Stamp is an integer
t
t
t
t
=
=
=
=
19660
0
Int
Int
Int
.
29999
[
19
65536
65536
,
660
multiplies the value variable by:
.
8
value
input
11
output
]
3
1
=
scale
value
**
scale
. Keep in mind that it's about the same
operation should be, by using the
×
elements
0
elements
.
29999
**
1
operator.

Related parts for 28029