28029 Parallax Inc, 28029 Datasheet - Page 102

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 90 · Smart Sensors and Applications
' Smart Sensors and Applications - TestAtn.bs2
' Test BASIC Stamp arctangent calculations.
'{$STAMP BS2}
'{$PBASIC 2.5}
angle
x
y
DO
LOOP
Your Turn - Testing Brad to Degree Conversion
As mentioned earlier, the ideal integer result comes from calculating angle
(360/256) x angle
is 5 to 9 or down if it is 1 to 4. You can generate a list of all 256 brad to degree
conversions with this program.
' Smart Sensors and Applications - BradsToDegrees.bs2
' Display brad to degree conversions for */ 360 and */ 361.
'{$STAMP BS2}
'{$PBASIC 2.5}
DEBUG "Enter y: "
DEBUGIN SDEC y
DEBUG "Enter x: "
DEBUGIN SDEC x
angle = x ATN y
DEBUG "brad ", SDEC ? angle
angle = angle */ 361
DEBUG "degree ", SDEC ? angle, CR
Some values will be lower than you predict. For example, when h = 100 and θ = 30°,
y = 50 and x = 87. The Debug Terminal will display 21 for the brad angle, which is correct,
but 29 for the degree angle is not correct. It should be 30. This happens occasionally when
scaling from a smaller range to a larger range. The 21 brads measurement corresponds to
29° and 22 brads corresponds to 31°.
VAR
VAR
VAR
brands
and then rounding up if the value to the right of the decimal point
Word
Word
Word
degrees
=

Related parts for 28029