ec

Dependents:   F3RC

Fork of EC by ROBOSTEP_LIBRARY

Revision:
11:b96009f8b9fd
Parent:
10:216d5a573dc7
Child:
26:45a53e3c81b1
diff -r 216d5a573dc7 -r b96009f8b9fd EC.cpp
--- a/EC.cpp	Tue Nov 29 12:45:45 2016 +0000
+++ b/EC.cpp	Tue Dec 13 07:38:51 2016 +0000
@@ -41,13 +41,21 @@
 
 void Ec::upZ(){
     if(first==false){
+        static int res_count;
         rev++;
         first=true;
         now_time=timer.read();
         RPM=60/(now_time-old_time);
         if((RPM_old-RPM)>RPM_th){
-            printf("\r\n CAUTION : speed downed drastically\r\n");
-            NVIC_SystemReset();
+            if(res_count >= 5){
+                printf("\r\n CAUTION : speed downed drastically\r\n");
+                NVIC_SystemReset();
+                res_count=0;
+            }else{
+                res_count++;
+            }
+        }else{
+            res_count=0;
         }
         RPM_old=RPM;
         old_time=timer.read();