
Originally Posted by
Charles Linquis
I'm sure there are equations out there, but I imagine most are a bit hard for integer math.
An approach I would use:
Assuming that your A/D readings decrease with altitude:
Build an array (array 1) with ArrayWrite that has as many points as you can easily create that contains the A/D readings of increasing altitude.
If the elements of your array are at even altitudes (100, 200, 300, 400 feet, for example), create a simple equation of altitude vs. array element.
example - element 1 = 100 feet, element 2 = 200 feet. Then the translation is element X 100 = altitude.
If the elements of your array are not at evenly spaced altutudes, they you will have to create another array (array 2) with the translation.
example - element 1 = 132 feet, element 2 = 619 feet,
Take your A/D reading and check against every element of array 1 in a for-next loop.
When the A/D is larger than the reading, note the element (n). Also note the value in element n-1.
Subtract the value of element n from the value in n-1. Call this value "DELTA". If you are using array2, do the subtraction on those elements.
Subtract the value of your A/D from the value in n. Call this value DELTA2
divide DELTA by DELTA2 (you may have to multiply and use LONGs to get adequate resolution).
Multiply the altitude difference of n and n-1 by the previous result.
Bookmarks