Shop OBEX P1 Docs P2 Docs Learn Events
Accelerometer Reading Speed — Parallax Forums

Accelerometer Reading Speed

dkwondkwon Posts: 13
edited 2005-10-20 18:52 in General Discussion
Hello Experts,

I am trying to get accelerometer data from memsick.

How many data·I can get per second at most?

I've used peter's example code and it gives·two or three values per seocnd.

How can·I·improve the speed?

Thanks in advance.

Best Regards,

Doo Young Kwon

Comments

  • Peter VerkaikPeter Verkaik Posts: 3,956
    edited 2005-10-19 18:58
    What example code would that be?

    I have never used the memsic 2125.

    According to the BS example, you must use pulseIn to read the data.

    regards peter
  • dkwondkwon Posts: 13
    edited 2005-10-19 19:54
    Sorry Peter,

    It wasn't provided by you. There was an attached code in the topic "Mesmic 2125 accelerometer". And I tried and it worked.

    It used pulseIn as you mentioned. The timeout value is 10000.

    Is there any way I can get sensor value faster?
    If I change the timeout value smaller, would it help?

    Best Regards,

    Doo Young Kwon
  • bearclawbearclaw Posts: 10
    edited 2005-10-20 18:52
    I tryed the following code, moves a servo according to the accelerometer value. I don't know exactly, but my "framerate" is higher than 3 /s


    import stamp.core.*;

    class TestAS {
    static PWM servo = new PWM(CPU.pin12,173,2304);

    public static void main() {
    while (true) {
    CPU.writePin(CPU.pin7, false);
    int pulse = CPU.pulseIn(2400,CPU.pin1, true); //20 ms
    if (pulse==0 || pulse == -1)
    CPU.writePin(CPU.pin7, true);

    //pulse
    int gunconv = pulse - 576; //5000 usec § 8.68 => ampli
    servo.update(179+gunconv/4, 2000);

    CPU.delay(200);
    }
    }
    };
Sign In or Register to comment.