Memsic 2125 code?


Closed Thread
Results 1 to 25 of 25

Hybrid View

  1. #1
    Join Date
    Feb 2006
    Location
    Gilroy, CA
    Posts
    1,530


    Did you find this post helpful? Yes | No

    Default 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

  2. #2
    Join Date
    Mar 2011
    Location
    Los Angeles, California
    Posts
    322


    Did you find this post helpful? Yes | No

    Default Re: Memsic 2125 code?

    Hi Walter,
    You are correct and just a minor "brain cramp" with the * vs /. With the logic analyzer results (Pulse Width.doc) the results showed a T1 of 502 which is why I used this number. The sensor document, 28017, says the "duty cycle" can be from 48.7% to 51.3% so the logic analyzer reading of 50.2% made sense. In the formula they use 50%. It is also assumed that the pulse timing is 10 ms which would be true if if the PWM signal were 100 hz. Again the logic analyzer show a frequency of 101 hz so the overall timing becomes 9.9 ms. Okay, both are minor corrections. You can not do a divide by 9.9 as it is not a whole number so to change the *2 to *20 allows the divide by 99 (9.9). Where I am having trouble with the formula is that if you point the sensor front edge down by 30-40 degrees then xRaw reading becomes about 414 which results in a number in the 65,000 range as 414 - 494 will give a result of -80. My best guess is that one would have to a lower number such as the 414 rather than 494 for the range of the sensor pointed down? Thanks, Ed

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts