Nuts & Volts Volume 3, Column 92 It's All About Angles pg. 257 is missing somet
Hello.
I have purchased the Memsic accelerometer.· While reading column 92, I noticed that the 5th page of this article (pg. 257) is largely blank.· It only has two lines at top and rest is blank.
Is something missing?
Can Parallax please correct this?·
Specifically, I'm trying to understand this snippet of code from the article and find it difficult to do so because of the missing page.
Can someone please explain how·the subroutine Read_X_Tilt·works, line by line?
More specifically, what is
xTilt = mult * (ABS xGForce / 10) + (frac ** (ABS xGForce / 10))·· for?
Read_X_Tilt:
· GOSUB Read_X_Force
· ' tilt = g x k
· '
· ' Select tilt conversion factor based on static
· ' G force.· Table data derived from Memsic specs.
· LOOKDOWN ABS xGForce, <=[noparse][[/noparse]174, 344, 508, 661, 2000], idx
· LOOKUP idx, [noparse][[/noparse]57, 58, 59, 60, 62], mult
· LOOKUP idx, [noparse][[/noparse]32768, 10486, 3277, 30802, 22938], frac
· ' G Force is divided by 10 to prevent roll-over errors at end
· ' of range.· Tilt is returned in 100ths degrees.
· xTilt = mult * (ABS xGForce / 10) + (frac ** (ABS xGForce / 10))
Check_SignX:
· IF (xGForce.BIT15 = 0) THEN XT_Exit·········· ' if positive, skip
· xTilt = -xTilt······························· ' correct for g force sign
XT_Exit:
· RETURN
I have purchased the Memsic accelerometer.· While reading column 92, I noticed that the 5th page of this article (pg. 257) is largely blank.· It only has two lines at top and rest is blank.
Is something missing?
Can Parallax please correct this?·
Specifically, I'm trying to understand this snippet of code from the article and find it difficult to do so because of the missing page.
Can someone please explain how·the subroutine Read_X_Tilt·works, line by line?
More specifically, what is
xTilt = mult * (ABS xGForce / 10) + (frac ** (ABS xGForce / 10))·· for?
Read_X_Tilt:
· GOSUB Read_X_Force
· ' tilt = g x k
· '
· ' Select tilt conversion factor based on static
· ' G force.· Table data derived from Memsic specs.
· LOOKDOWN ABS xGForce, <=[noparse][[/noparse]174, 344, 508, 661, 2000], idx
· LOOKUP idx, [noparse][[/noparse]57, 58, 59, 60, 62], mult
· LOOKUP idx, [noparse][[/noparse]32768, 10486, 3277, 30802, 22938], frac
· ' G Force is divided by 10 to prevent roll-over errors at end
· ' of range.· Tilt is returned in 100ths degrees.
· xTilt = mult * (ABS xGForce / 10) + (frac ** (ABS xGForce / 10))
Check_SignX:
· IF (xGForce.BIT15 = 0) THEN XT_Exit·········· ' if positive, skip
· xTilt = -xTilt······························· ' correct for g force sign
XT_Exit:
· RETURN
Comments
Dunno if something from that article·is missing there, but the two lines of text at the top of the page continue on immediately at the top of the next page, following Figure 92-2.
PAR
That text explains specifically, for example, why the absolute value of xGForce, "ABS xGForce" is used.
It explains specifically why "ABS xGForce" is divided by 10.
It explains specifically why the first instance of "ABS xGForce / 10" is multiplied using the "*" operator by "mult", and why the second instance is multiplied using the "**" operator by "frac".
It explains how the values in Lookup and Lookdown are derived.
It explains the need for scaling some of the values.
So, my question to you is: Which specific step(s) / operation(s) don't you understand? I.e., what about the author's explanations do you want to have further explanation on?
PAR
I don't see the explanation why
+ (frac ** (ABS xGForce / 10)) is needed.
Where do you see the explanation for this?
Is + (frac ** (ABS xGForce / 10)) to get the portion after the whole numbers (i.e. .50 that belongs to 57.50 and .16 that belongs to 58.16 etc.?)
The explanation is on page 256-258:
"In our case, LOOKDOWN will identify the first location of table data that is less than or equal to ( <= ) the gforce value. This position is moved into the variable idx and serves as an index for the next two LOOKUP tables."
"In order to use the ** operator – which gives us the best resolution when multiplying by fractional values – we have to separate the conversion factors into their whole and fractional elements. The first table contains the whole part, the second table contains the fractional part. The entries for the second table are calculated by multiplying the fractional portion of each conversion factor by 65,536."
and,
"We do a straight multiply with the whole part, use ** with the fractional part, then add them together."
Of course, knowing what the * and ** math operators do is necessary to really appreciate the explanation. Take a look at the description and examples of use of those two Multiplication operators in the BASIC Stamp Syntax and Reference Manual (ver. 2.1), pp 107-109. The examples are directly relevant to this article.
PAR