28029 Parallax Inc, 28029 Datasheet - Page 176

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 164 · Smart Sensors and Applications
LOOP
' -----[ Subroutine - Arcsine ]-----------------------------------------------
' This subroutine calculates arcsine based on the y coordinate on a circle
' of radius 127.
' calling this subroutine.
Arcsine:
' -----[ Subroutine - Arccosine ]---------------------------------------------
' This subroutine calculates arccosine based on the x coordinate on a circle
' of radius 127.
' calling this subroutine.
Arccosine:
PULSIN 6, 1, xTilt
PULSIN 7, 1, yTilt
' Scale and offset x and y-axis values to -127 to 127.
xTilt = (xTilt MIN 1875 MAX 3125) - 1875 ** 13369 - 127
yTilt = (yTilt MIN 1875 MAX 3125) - 1875 ** 13369 - 127
' Calculate and display Arcsine of x-axis measurement.
side = xTilt
GOSUB Arcsine
DEBUG HOME, "x tilt angle = ", CLREOL, SDEC3 angleTilt, CR
' Calculate and display Arcsine of y-axis measurement.
side = yTilt
GOSUB Arcsine
DEBUG "y tilt angle = ", CLREOL, SDEC3 angleTilt
GOSUB Compass_Get_Axes
angleCompass = xCompass ATN -yCompass
angleCompass = angleCompass */ 361
DEBUG CR, "Compass angle = ",
PAUSE 150
GOSUB Arccosine
angleTilt = 90 - angleTilt
RETURN
sign = side.BIT15
side = ABS(side)
angleTilt = 63 - (side / 2)
DO
DEC angleCompass, " degrees", CLREOL
Set the side variable equal to your y coordinate before
Set the side variable equal to your x coordinate before
' x-axis measurement
' y-axis measurement
' Get x, and y values
' Convert x and y to brads
' Convert brads to degrees
' Debug delay for slower PCs
' Repeat DO...LOOP
' Inverse sine subroutine
' Get inverse cosine
' sin(angle) = cos(90 - angle)
' Inverse cosine subroutine
' Save sign of side
' Evaluate positive side
' Initial angle approximation
' Successive approximation loop

Related parts for 28029