I-O DATA DEV2 / Mbed 2 deprecated ud-gs4-R_400G_SD_Log_No1

Dependencies:   mbed SDFileSystem_

Revision:
42:f42b74882970
Parent:
41:43828af3765f
Child:
43:024421f7474c
--- a/main.cpp	Mon Sep 13 08:54:03 2021 +0000
+++ b/main.cpp	Mon Sep 13 10:09:47 2021 +0000
@@ -79,8 +79,8 @@
 short oldcount = 0;
 short newcount = 0;
 long max_g=0;
-long tmp_max=0;
-long tmp_max2=0;
+//long tmp_max=0;
+//long tmp_max2=0;
 short  update=0;
 char buffer1[DATA_SIZE] = {};
 char buffer2[DATA_SIZE] = {};
@@ -100,6 +100,7 @@
     static long scr2 = 0;
     static long ax,ay,az,as;
     static long ax2,ay2,az2,as2;
+    static long tmp_max = 0, tmp_max2 = 0;
     
     read3axes331(&tx,&ty,&tz);
     //キャリブレーションの補正
@@ -117,7 +118,7 @@
     as+= scr;
     //newcount++;
     //pc.printf("%d,%d,x:%2.2f y:%2.2f,z:%2.2f scaler = %2.2f \r\n",timecount,time(NULL),(float)tx*0.005,(float)ty*0.005,(float)tz*0.005,(float)scr*0.005);
-    //pc.printf("new x:%d y:%d,z:%d scaler = %d \r\n",tx,ty,tz,scr);
+    //pc.printf("new x:%d y:%d,z:%d scr=%d, max=%d\r\n",tx,ty,tz,scr,tmp_max);
     
     //Total Max G
     if ( max_g < scr) {
@@ -133,14 +134,15 @@
     
     //MAX G per cycle
     if(tmp_max < scr){
+        //pc.printf("tmp_max:%d,%d",tmp_max,scr);
         tmp_max = scr;
     }
     
     //平均(/s)
-    if (newcount == 500) {
-        float asc = (float)as / 500.0f;
+    if (newcount == 400) {
+        float asc = (float)as / 400.0f;
         pc.printf("avarage(new) x:%2.2f,y:%2.2f,z:%2.2f,scaler=%2.2f,max:%2.2f\r\n",
-            (float)ax/500.0f*0.005,(float)ay/500.0f*0.005,(float)az/500.0f*0.005,(float)as/500.0f*0.005, (float)tmp_max*0.005);
+            (float)ax/400.0f*0.005,(float)ay/400.0f*0.005,(float)az/400.0f*0.005,(float)as/400.0f*0.005, (float)tmp_max*0.005);
         sprintf(stracc1,"%d,%d,%2.2f,%2.2f\r\n",timecount,time(NULL),asc*0.005,(float)tmp_max*0.005);
         
         if((strlen(buffer1)+strlen(stracc1)) > DATA_SIZE) {
@@ -177,8 +179,8 @@
         //pc.printf("%d,%d,old x:%d,y:%d,z:%d scaler = %d\r\n",timecount,time(NULL),tx,ty,tz,scr);
         //sprintf(stracc2,"%d,%d,%d\r\n",timecount,time(NULL),scr);
         //pc.printf("lis3dh:%s",stracc2);
-        if(oldcount == 5000){
-            float asc2 = (float)as2 / 500.0f;
+        if(oldcount == 4000){
+            float asc2 = (float)as2 / 400.0f;
             //pc.printf("avarage(old) x:%2.2f,y:%2.2f,z:%2.2f,scaler=%2.2f,max:%2.2f\r\n",
             //(float)ax2/500.0f*0.005,(float)ay2/500.0f*0.005,(float)az2/500.0f*0.005,(float)as2/500.0f*0.005, (float)tmp_max2*0.005);
             sprintf(stracc2,"%d,%d,%2.2f,%2.2f\r\n",timecount,time(NULL),asc2*0.005,(float)tmp_max2*0.005);
@@ -342,7 +344,7 @@
         oldcount++;
         newcount++;
         sub();
-        //wait_ms(20);
+        wait_us(2500);
     }
     pc.printf("Program End.\r\n");
     return 0;