
Originally Posted by
amgen
any fast way to check 3 readings and discard high and low reading?
Code:
X1 VAR word ;1st data point
X2 VAR word ; 2nd data point
X3 VAR word ; 3rd data point
Xtemp VAR word ; temp variable
;******************
Gosub X2X1Compare
If X3 < X2 THEN ; swap if true
Xtemp = X2
X2 = X3
X3 = Xtemp
ENDIF
Gosub X2X1Compare
X2 is now your keep value ; <- here is your answer
END
;******************
X2X1Compare:
If X2 < X1 THEN ; swap if true
Xtemp = X1
X1 = X2
X2 = Xtemp
ENDIF
Return
;******************
However, it is would be much easier and computationally faster to sample 4 values, add them together, and divide by 4 (using shift right)
Code:
Xtemp = X1+X2+X3+X4
Xtemp = Xtemp >> 2 ; <- here is your answer
Paul Borgmeier
Salt Lake City, Utah
USA
Bookmarks