28029 Parallax Inc, 28029 Datasheet - Page 156

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 144 · Smart Sensors and Applications
One effective way to eliminate the effects of noise is by taking an average of the
compass' x and y axis measurements. That way, if noise causes one measurement to be a
little high, the next one a little low, and the one after that is about right, the average of all
the measurements will eliminate the highs and lows and settle on the right value.
One of the reasons the calibration and calibration testing activities may not have yielded
the best results is because of noise. This activity demonstrates how you can modify any
of the example programs in this chapter, including the calibration and calibration test
programs, to take averaged measurements and eliminate the effects of noise.
Incorporating Averaging into the Compass Programs
There are three major steps to incorporating averaging into this chapter’s example
programs. First, add a couple of
Then, add four variables to the program's Variables section.
Finally, modify the
original
running sum of the x and y-axis measurements with the
the average of a group of measurements is the sum of the measurements divided by the
number of measurements taken, there are code blocks after the
equal to
Negative
Positive
mCount
xSum
ySum
sign
xSum ÷ 10
Compass_Get_Axes:
Compass_Get_Axes
xSum = 0
ySum = 0
FOR mCount = 1 TO 10
NEXT
' *** Original code from Compass_Get_Axes subroutine goes here ***
xSum = xSum + x
ySum = ySum + y
Compass_Get_Axes
and y equal
CON
CON
VAR
VAR
VAR
VAR
subroutine is nested in a
to ySum ÷ 10
CON
1
0
Nib
Word
Word
Bit
directives to the program's Constants section.
subroutine as shown below. The code from the
.
' Word.bit15 = 1 -> negative
' Word.bit15 = 0 -> positive
' Measurement count
' x-axis measurement accumulator
' y-axis measurement accumulator
' Sign bit
' Modified subroutine
' Accumulators to zero
' Take ten measurements
' Keep a running sum of x
' Keep a running sum of y
xSum
FOR
...
and
FOR
NEXT
ySum
...
NEXT
loop that keeps a
variables. Since
loop that set x

Related parts for 28029