Get total Acceleration from 3 axes?

876 Views Asked by At

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.....

1

There are 1 best solutions below

0
On

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