Page 1 of 1

x-y confusion in MEMS demo

Posted: Mon Dec 28, 2015 9:10 pm
by chibby
I don't know whether this is some hardware variation anomaly but the MEMS demo has the LEDS on the accelerometer all confused.

Current SVN has x and y inverted and one of the axes responding in the opposite manner to the other one.

The following code make tipping the board left and right light up the left-most and right-most LEDs. It changes the reaction to be consistent on both pairs: highest side of the board lights up.

Code: Select all

    /* Calculating average of the latest four accelerometer readings.*/
    y = ((int32_t)xbuf[0] + (int32_t)xbuf[1] +
         (int32_t)xbuf[2] + (int32_t)xbuf[3]) / 4;
    x = ((int32_t)ybuf[0] + (int32_t)ybuf[1] +
         (int32_t)ybuf[2] + (int32_t)ybuf[3]) / 4;

    /* Reprogramming the four PWM channels using the accelerometer data.*/
    if (y < 0) {
      pwmEnableChannel(&PWMD4, 2, (pwmcnt_t)-y);
      pwmEnableChannel(&PWMD4, 0, (pwmcnt_t)0);
    }
    else {
      pwmEnableChannel(&PWMD4, 0, (pwmcnt_t)y);
      pwmEnableChannel(&PWMD4, 2, (pwmcnt_t)0);
    }
    if (x < 0) {
      pwmEnableChannel(&PWMD4, 1, (pwmcnt_t)-x);
      pwmEnableChannel(&PWMD4, 3, (pwmcnt_t)0);
    }
    else {
      pwmEnableChannel(&PWMD4, 3, (pwmcnt_t)x);
      pwmEnableChannel(&PWMD4, 1, (pwmcnt_t)0);
    }


OK , it's only a demo and it does demonstrate the RTOS functionality but it seems like it was written by someone who did not have access to the hardware. It would look a bit sharper if the LEDs came on in a logical way.

Re: x-y confusion in MEMS demo

Posted: Mon Dec 28, 2015 9:50 pm
by Giovanni
There are two revisions of the board, one of them has the MEMS rotated.

Giovanni

Re: x-y confusion in MEMS demo

Posted: Tue Dec 29, 2015 6:21 am
by chibby
Thanks, I suspected there may be different versions. For the record the above code matches board version MB887C, which I think is still the current version.