Pengujian Battery

Dependencies:   SDFileSystem TextLCD mbed

Fork of Seeed_SDCard_Shield by Shields

Revision:
6:1b08722d3aba
Parent:
5:47c9375675bb
diff -r 47c9375675bb -r 1b08722d3aba main.cpp
--- a/main.cpp	Thu Feb 02 08:01:29 2017 +0000
+++ b/main.cpp	Sat Feb 11 03:56:41 2017 +0000
@@ -249,6 +249,7 @@
             
     float Vsat=10.80; 
     int n=1000;
+    int k=1;
     
     ulang:       
     while(c==1)
@@ -314,7 +315,7 @@
         stat3=((m3*100)/jam);
         
             lcd.cls();
-            if(V1<=Vsat)
+            if(abc1<=Vsat)
             {
                 lcd.locate(10, 0);
                 lcd.printf("C1=%.1f",stat);
@@ -322,26 +323,26 @@
                 lcd.printf("%");
                 t.stop(); 
             }
-            if(V2<=Vsat)
+            if(abc2<=Vsat)
             {
                 lcd.locate(10, 1);
                 lcd.printf("C2=%.1f",stat1);
                 t1.stop();
             }
-            if(V3<=Vsat)
+            if(abc3<=Vsat)
             {       
                 lcd.locate(10, 2);
                 lcd.printf("C3=%.1f",stat2);
                 t2.stop();
             }          
-            if(V4<=Vsat)
+            if(abc4<=Vsat)
             {
                 lcd.locate(10, 3);
                 lcd.printf("C4=%.1f",stat3);
                 t3.stop();
             }
             
-            if((V4<Vsat)||(V3<Vsat)||(V2<Vsat)||(V1<Vsat))
+            if((abc4<=Vsat)||(abc3<=Vsat)||(abc2<=Vsat)||(abc1<Vsat))
             {
                 led=!led;
             }
@@ -383,18 +384,23 @@
             lcd.locate(0, 3);
             lcd.printf("V4=%.1fV",abc4);
             wait(1.0);
-            if(d4>902){
-            fprintf(fp,"%.0f,%.1f V,%.1f V,%.1f V,%.1fV,%.1f\r\n",m,abc1,abc2,abc3,abc4,VTOTAL);
-            //pc.printf("%.0f,Volt V1 = %.2f V, Volt V2 = %.2f V, Volt V3 = %.2f V, Volt V4 = %.2fV VTOTAL=%.2f\r\n",m,V1,V2,V3,V4,VTOTAL);
-            t4.reset();
+            
+            if (((abc4<=Vsat)||(abc3<=Vsat)||(abc2<=Vsat)||(abc1<=Vsat))&&(k==1)){
+                fprintf(fp,"%.0f,%.1f V,%.1f V,%.1f V,%.1fV,%.1f\r\n",m,abc1,abc2,abc3,abc4,VTOTAL);
+                k=0;
+                }
+                
+            if (d4>898){
+                fprintf(fp,"%.0f,%.1f V,%.1f V,%.1f V,%.1fV,%.1f\r\n",m,abc1,abc2,abc3,abc4,VTOTAL);
+                //pc.printf("%.0f,Volt V1 = %.2f V, Volt V2 = %.2f V, Volt V3 = %.2f V, Volt V4 = %.2fV VTOTAL=%.2f\r\n",m,V1,V2,V3,V4,VTOTAL);
+                t4.reset();
             }
             
-            if(mybutton==0)
-            {
-             c=0;
-             led=0;
-             fprintf(fp,"%.0f,%.1f V,%.1f V,%.1f V,%.1fV,%.1f\r\n",m,abc1,abc2,abc3,abc4,VTOTAL);
-             break;
+            if (mybutton==0){
+                c=0;
+                led=0;
+                fprintf(fp,"%.0f,%.1f V,%.1f V,%.1f V,%.1fV,%.1f\r\n",m,abc1,abc2,abc3,abc4,VTOTAL);
+                break;
             }
         }