#include <signal.h>
#include <stdio.h>
#define SAMPLE_RATE 50
#define TIME_CONSTANT 2.0
#define DAMP 1.0
static int running = 0;
static void signal_handler(__attribute__ ((unused)) int dummy)
{
running=0;
return;
}
int main()
{
const double dt = 1.0/SAMPLE_RATE;
double lpf,hpf,lpt,hpt,u;
int counter = 0;
printf("\nSample Rate: %dhz\n", SAMPLE_RATE);
printf("Time Constant: %5.2f\n", TIME_CONSTANT);
printf("\nLow Pass:\n");
printf("\nHigh Pass:\n");
printf("\nLow Pass Third Order Complement:\n");
printf("\nHigh Pass Third Order Complement:\n");
printf("\n\n");
printf(" input u |");
printf(" lp_first |");
printf(" hp_first |");
printf(" sum |");
printf(" lp_third |");
printf(" hp_third |");
printf(" sum |");
printf("\n");
signal(SIGINT, signal_handler);
running = 1;
u=1.0;
while(running){
printf("\r");
printf("%8.3lf |", u);
printf("%8.3lf |", lpf);
printf("%8.3lf |", hpf);
printf("%8.3lf |", lpf+hpf);
printf("%8.3lf |", lpt);
printf("%8.3lf |", hpt);
printf("%8.3lf |", lpt+hpt);
fflush(stdout);
counter++;
if(counter >= SAMPLE_RATE*10){
counter = 0.0;
if(u>0.0) u = 0.0;
else u = 1.0;
}
}
printf("\n");
return 0;
}