28029 Parallax Inc, 28029 Datasheet - Page 115

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
perform these functions on his web site www.emesystems.com. The next example
program uses modified versions of these subroutines.
Remember that the
divide the result by 127, you'll get a value between −1 and 1 that is an approximation of
the actual sine (y/h) or cosine (x/h) ratios.
subroutines, you can set a variable named
subroutine will store the degree measurement results in the
Example Program: TestArcsine.bs2
This next program sweeps sine values from −127 to 127, and its
converts these sine values back to degree angles. Keep in mind that this is the reverse of
the calculations in the previous example program.
displayed sine values for given angles. This one displays angles for given sine values.
' -----[ Title ]--------------------------------------------------------------
' Smart Sensors and Applications - TestArcsine.bs2
' Test arcsine for sine values from -127 to 127.
' {$STAMP BS2}
' {$PBASIC 2.5}
Enter, save, and run TestArcsine.bs2
Compare the results to the sine values calculated in the previous example
program.
If you want the Arcsine and Arccosine subroutines to return brads instead of
degrees, just make three changes:
In the Arccosine subroutine, comment the line of code that converts from brads to
degrees:
Then, in the IF...THEN statement change 180 to 128 because we are now using a 256-
division circle:
Likewise, in the Arccosine subroutine change 90 to 64:
'
IF sign = Negative THEN angle = 128 - angle
angle = 64 - angle
SIN
angle = angle */ 361
and
COS
operators return values between −127 and 127. If you
Chapter 3: Tilt with the Memsic Accelerometer · Page 103
side
' BASIC Stamp Directive
' PBASIC Directive
to a value between −127 and 127, and the
' Convert brads to degrees
With the
The previous example program
angle
Arcsine
variable.
Arcsine
and
Arccosine
subroutine

Related parts for 28029