javaandroidanalog-digital-converter

Analog data to digital data conversion in android for accelerometer?


I used accelerometer sensor in my android app and implemented SensorEventListener to my acctivity

    public void onSensorChanged(SensorEvent event) {
    //acceleration.x,.y,.z is the input from the sensor
    //result.x,.y,.z is the filtered result
    //high pass filter to eliminate gravity
    accel[0]= event.values[0]*kFilteringFactor+accel[0]*(1.0f-kFilteringFactor);
    accel[1]= event.values[1]*kFilteringFactor+accel[1]*(1.0f-kFilteringFactor);
    accel[2]= event.values[2]*kFilteringFactor+accel[2]*(1.0f-kFilteringFactor);
    X=event.values[0]-accel[0];
    Y=event.values[1]-accel[1];
    Z=event.values[2]-accel[2];
    accel[0]=X;
    accel[1]=Y;
    accel[2]=Z;

    double result=X+Y+Z;

    readingData.setText("Data :"+ result);
    }

I am getting data in analog wave form, I want data in digital form. how to convert this data to something that if there is vibration and i plot the data then graph should be in square wave form.

Thank you.


Solution

  • What you want works similar to a pedometer that counts steps of the user based upon the movements, you can use the same concepts used there.

    You need to set a threshold for the accelrometer magnitude values (Cartesian sum of x,y,z values) and when the magnitude crosses the threshold. You can set the value as '1' I.e., in motion, otherwise zero. In pedometer , we use just the z axis readings to track the motion along z -axis.

    I have worked on Indoor Positioning system using these. Please find the Indoor tracking application here : https://github.com/ramakanthd92/IndoorMagMap

    A publication for the same can be found here http://ieeexplore.ieee.org/document/7106948/

    Hope this helps