![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final project
Dependencies: MMA8451Q8a SLCD Vishal_LCD_punch_mtr_8_v5_class mbed
Fork of Vishal_LCD_punch_mtr_8_v5_class by
Diff: LCD_punch_mtr8_v5.cpp
- Revision:
- 9:0f3136c281d1
- Parent:
- 8:ce65e42b08c9
- Child:
- 10:66f5d56781d9
--- a/LCD_punch_mtr8_v5.cpp Mon Feb 02 18:23:30 2015 +0000 +++ b/LCD_punch_mtr8_v5.cpp Tue Apr 28 23:01:08 2015 +0000 @@ -73,7 +73,6 @@ char displayTitles[NUMSTATES][LCDLEN] = {XCOMP,YCOMP,ZCOMP,MAXVECT}; float accaxisdata[NUMSTATES]; char displayformats[NUMSTATES][LCDLEN] = {"%4.0f","y.%3.2f","z.%3.2f","v.%3.2f"}; -//char displayformats[NUMSTATES][LCDLEN] = {"%4.3f","%4.3f","%4.3f","%4.3f"}; void LCDMess(char *lMess, float dWait){ slcd.Home(); @@ -145,7 +144,7 @@ // http://cache.freescale.com/files/sensors/doc/data_sheet/MMA8451Q.pdf // See page 26 // Set 2 g max limit ****************** Note limits - acc.setGLimit(MAX_2G); // For now set to 2g + acc.setGLimit(MAX_4G); // For now set to 2g acc.readRegs(XYZ_DATA_CFG, ®Data, 1); sprintf (lcdData,"%d",regData); LCDMess(lcdData,BLINKTIME); @@ -167,27 +166,55 @@ // Change to switch/case soon. LCDMess(displayTitles[displayState],BLINKTIME); } - + +///STEPS PARAMETER +//Set up a digital filter using four registers and a summing unit + + +//Set up the dynamic threshold and dynamic precision +//continuously updates the maximum and minimumvalues of the 3-axis acceleration every 50samples +//the average value, (Max+min)/2 is the dynamic threshold level + + +//set up the peak Detection + +//set up time window + + +///DISTANCE PARAMETERS +//s=number of steps*distance per step + + +///SPEED PARAMETER +//d=s/t // -------------------------------------------- while (dataTimer.read() > DATATIME){ // No offset - xAcc = abs(acc.getAccX()); + xAcc = (acc.getAccX()); xCounts = acc.getAccAxis(REG_OUT_X_MSB); - yAcc = abs(acc.getAccY()); + yAcc = (acc.getAccY()); yCounts = acc.getAccAxis(REG_OUT_Y_MSB); - zAcc = abs(acc.getAccZ()); + zAcc = (acc.getAccZ()); zCounts = acc.getAccAxis(REG_OUT_Z_MSB); + +// xAccDiff = + printf("%1.2f %1.2f %1.2f\n", xAcc, yAcc, zAcc); +// printf("X: %1.2f, Y: %1.2f, Z: %1.2f\n", xAcc, yAcc, zAcc); +// printf("X-counts: %1.2f, Y-counts: %1.2f, Z-counts: %1.2f\n", xCounts, yCounts, zCounts); + // Calulate vector sum of x,y and z reading. vector = sqrt(pow(xAcc,2) + pow(zAcc,2)); - vector = zAcc; +// vector = zAcc; if (vector > vMax) { vMax = vector; } + //Prepare data for LCD display accaxisdata[XCOMPD] = abs((float)xCounts/COUNTSCALE); // scalling is set to 1 at this point accaxisdata[YCOMPD] = abs((float)yCounts/COUNTSCALE); accaxisdata[ZCOMPD] = abs((float)zCounts/COUNTSCALE); + accaxisdata[VMAXD] = vMax; dataTimer.reset(); LEDDwell = 1.1 - vMax/MAXGS; @@ -208,4 +235,4 @@ blinkTimer.reset(); } }//forever loop -}// main \ No newline at end of file +}// main