adfadsf

Dependencies:   QEI mbed

Files at this revision

API Documentation at this revision

Comitter:
MTSAung
Date:
Sun Jul 22 15:22:22 2018 +0000
Parent:
0:f2a2b5a88616
Commit message:
second order filter

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Sun Jul 22 09:41:09 2018 +0000
+++ b/main.cpp	Sun Jul 22 15:22:22 2018 +0000
@@ -12,9 +12,10 @@
 double   b              = 0.0;
 double   c              = 0.0;
 double   PI             = 3.1416;
-double   fc             = 0.05/(2*PI);
-double   C              =(2*PI*fc)*(2*PI*fc) ;
-double   B              = sqrt(2*C);
+double   fc             = 15.0;
+double   C              = (2.0*PI*fc)*(2.0*PI*fc);
+double   B              = (2.0*PI*fc)*sqrt(2.0);
+
 int main()
 {
     Timer myTime;
@@ -24,13 +25,13 @@
     while(1) {
         now_time  = myTime.read_ms()/1000.0;
         samp_time = now_time - prv_time;
-        now_x     = sin(2*PI*0.5*now_time) + 0.5*sin(2*PI*100*now_time);
+        now_x     = sin(2.0*PI*0.5*now_time) + 0.25*sin(2*PI*50.0*now_time);
         a         = ((samp_time*samp_time)*C)*now_x;
-        b         = (2+(samp_time*B))*prv_d;
+        b         = (2.0+(samp_time*B))*prv_d;
         c         = pr2v_d;
-        now_d     = (a+b-c)/(((samp_time*samp_time)*C)+(samp_time*B)+1);
-    
-        pc.printf("   %F      %F     %F      %F\r", now_time, samp_time, now_x, now_d);
+        now_d     = (a+b-c)/(((samp_time*samp_time)*C)+(samp_time*B)+1.0);
+            
+        pc.printf("   %F      %F\r", now_x, now_d);
         printf("\n\r");
         prv_time = now_time;
         prv_d    = now_d;