0

I get all 3 axes using this

timer = [NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(Accelerometer) userInfo:nil repeats:YES];
[timer fire];

Edit

-(void)Accelerometer
{
    float accex1 = motionManager.accelerometerData.acceleration.x;
    float accey1 = motionManager.accelerometerData.acceleration.y;
    float accez1 = motionManager.accelerometerData.acceleration.z;

    float mAccelCurrent1 = sqrtf(pow((accex1 * accex1),2) + pow((accey1 * accey1),2) + pow((accez1 * accez1),2));
    float Acc = fabsf(mAccelCurrent1-Prv_Acceleration);

    Prv_Acceleration = mAccelCurrent1;
    [R1_Changes addObject:[NSString stringWithFormat:@"%f",Acc]];
}

Thanks to Hanno Binder Now i get Accretion. Now

Q2. How i get total Accretion in 1 Minute or 10 Minute?

Thanks in Advance.....

Chirag Dj
  • 630
  • 2
  • 9
  • 27
  • 2
    `accex1 - accex1` is 0, `accey1 - accey1` is 0, `accez1 - accez1` is 0 -> result is 0. – JimmyB Dec 09 '14 at 09:50
  • There is no such thing as 'total' acceleration. It can't be added like distance. What you can get is the 'max' 'min' or 'average' acceleration and getting the correct value still depends on how often you sample the acceleration values. But average accelration calculated like this is still kind of moot. What exactly are you trying to achieve? – Swapnil Luktuke Dec 09 '14 at 10:25
  • @SwapnilLuktuke i want to display total accretion changes done in 1 or 10 minute in Graph (using FSLineChart) – Chirag Dj Dec 09 '14 at 10:32
  • What do you mean by 'total' acceleration'? e.g. If you accelerate at 5 m/s^2 for a minute and 10 m/s^2 another minute your total acceleration in 2 minutes is not 15 m/s^2. What you can do however, is periodically (say every 5 seconds) record the 'current' acceleration value and plot it on a graph. – Swapnil Luktuke Dec 09 '14 at 10:38

1 Answers1

0

Is what you mean by "total acceleration" perhaps the velocity? If you take every acceleration value and multiply it by the time between the two readings, say every minute as in your example, that would give you an approximation of your velocity (assuming you knew what your starting velocity was).

float self.totalAcc = 0.0;  // EDITED HERE
-(void)Accelerometer
{
    float accex1 = motionManager.accelerometerData.acceleration.x;
    float accey1 = motionManager.accelerometerData.acceleration.y;
    float accez1 = motionManager.accelerometerData.acceleration.z;

    float mAccelCurrent1 = sqrtf(pow((accex1 * accex1),2) + pow((accey1 * accey1),2) + pow((accez1 * accez1),2));
    float Acc = fabsf(mAccelCurrent1-Prv_Acceleration);
    totalAcc += (mAccelCurrent1 - prvAcceleration) * timeChange // EDITED HERE
    Prv_Acceleration = mAccelCurrent1;
    [R1_Changes addObject:[NSString stringWithFormat:@"%f",Acc]];
}

Velocity is the time integral of acceleration. Not sure how much physics/calculus you've had but you can learn more here:khanAcademy - Integrals