edited_01

Dependencies:   QEI mbed

Fork of 1stOfilter_DNNHL_e02 by velo_filter

Files at this revision

API Documentation at this revision

Comitter:
MTSAung
Date:
Sun Jul 22 14:38:12 2018 +0000
Parent:
0:e5ae46b065d3
Commit message:
second order low pass filter

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r e5ae46b065d3 -r 36f8de3d85bb main.cpp
--- a/main.cpp	Sun Jul 22 09:44:27 2018 +0000
+++ b/main.cpp	Sun Jul 22 14:38:12 2018 +0000
@@ -5,11 +5,12 @@
 double   now_time       = 0.0;
 double   samp_time      = 0.0;
 double   PI             = 3.1416;
-double   fc             = 0.5;
-double   tau            = 1/(2*PI*fc);
+double   fc             = 2.0*PI*5.0;
+double   tau            = 1/(fc);
 double   now_x          = 0.0;
 double   now_y          = 0.0;
 double   prv_y          = 0.0;
+
 int main()
 {
     Timer myTime;
@@ -19,10 +20,10 @@
     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.0*PI*50.0*now_time);
         now_y     = ( samp_time * now_x + (tau * prv_y) ) / ( samp_time + tau);
     
-        pc.printf("   %F      %F     %F      %F\r", now_time, samp_time, now_x, now_y);
+        pc.printf("  %F      %F\r", now_x, now_y);
         printf("\n\r");
         prv_time = now_time;
         prv_y    = now_y;