11 years, 1 month ago.

Hey..help me 3axis accelerometer

i have bought mbed application board designed for mbed NXP LPC 1768,i am working with accelerometer on application board.a project related to active ankle foot movements.i want to know the orientation and side when i move my leg.Whwn i use functions getSide() and getOrientation() i am not geting the result on lcd .please any one help me with the code which displays side and orientation on lcd...

2 Answers

11 years, 1 month ago.

Those functions will return which side the device is on, but they won't automatically print it. To do that you need something like:

if (mma.getSide() == MMA7660::Front)
  lcd.printf("Side is front");
if (mma.getSide() == MMA7660::Back)
  lcd.printf("Side is back");
if (mma.getSide() == MMA7660::Unknown)
  lcd.printf("Side is unknown"); 

And especially for orientation it might be nicer to use a switch statement, but that is in principle the same.

Although for ankle movement I would expect that you want to use the actually measured acceleration values. The front/back stuff is mainly meant for for example a smartphone, that automatically turns its display off when it is bottom-down.

-deleted-
11 years, 1 month ago.

Erik sir,i want to work on tap detection ..can u give me an idea to find whether my foot is on ground or air.

Well start with reading the MMA's datasheet and looking how far you get from there. Or just try it by reading the acceleration data, might be easier. (Something like checking if the acceleration in the relevant axis is larger than a certain value. Although the MMA might not be ideal for this).

Honestly I have no problem with helping people, but you two aren't even trying it yourself.

posted by Erik - 01 May 2013

sir,i worked for tapdetection..here is the code please go through the code..

  1. include "mbed.h"
  2. include "MMA7660.h"
  3. include "C12832_lcd.h" C12832_LCD lcd; MMA7660 MMA(p28, p27);

DigitalOut connectionLed(LED1);

int main() { int n=0; while(n<10) { int z; if (MMA.testConnection()) connectionLed = 1;

z= MMA.tapDetection(); if(z==5) { lcd.printf("there is a tap");

} else { lcd.printf("There is no tap"); } n++; } }

sir,In MMA7660 i added a function int tapDetection()

nt MMA7660::tapDetection() { int k;

char intreg = read(MMA7660_INT_R); intreg &= 0x04; write(MMA7660_INT_R,intreg); for enabling the interupt char sample = read(MMA7660_SR_R); sample &= 0x00; for seting samplerate 120samples/second write(MMA7660_SR_R,sample); char detectreg = read(MMA7660_PDET_R); detectreg &= 0x00; for enabling tap in all directions char tiltreg = read(MMA7660_TILT_R); if(tiltreg == 0x32) { k=5; return (k); } else(tiltreg == 0x00) { k=10; return (k);

} }

posted by -deleted- 02 May 2013