Re: Memsic 2125 code?
Looking at your result for xRaw pulse (in your level.doc), and running through the formula, it looks to be correct using the original formula given:
Code:
PULSIN PORTB.1, HiPulse, xRaw
xRaw = xRaw * 2
' g = ((t1 / 0.01) - 0.5) / 12.5% ' formula from data sheet
xGForce = ((xRaw / 10) - 500) * 8 ' Modified for our PIC - Converts to 1/1000 g's
xRaw = 2472
xRaw * 2 = 4944
xRaw /10 = 494
494 - 500 = -6
-6 * 8 = -48 (-.048 g's which can probably be calibrated for.)
57.5*(-48/10) =274 hundredths degrees, or -2.74 degrees.
seems like its pretty close given the original equation. Since your total period is short, that might explain why its off a little bit. T2 was supposed to be 10ms (and is assumed as such in the code.)
I would try calibrating it using a -494 , instead of a -500 and see what you get.
Edit: I see now you are calibrating with the *20 and /99.
This method workes pretty good to 45 degrees or so. At 90 degrees, it obviously doesn't work very well, and is about 24 degrees off.
Last edited by ScaleRobotics; - 23rd June 2012 at 18:17.
http://www.scalerobotics.com
Bookmarks