#include <signal.h>
#include <stdio.h>
#define SAMPLE_RATE 50
#define TIME_CONSTANT 2.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 lp,hp,i,u,lpb,hpb;
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("\nIntegrator:\n");
printf("\nLow Pass Butterworth:\n");
printf("\nHigh Pass Butterworth:\n");
printf("\n\n");
printf(" input u |");
printf(" lowpass |");
printf(" highpass |");
printf("complement|");
printf("integrator|");
printf(" lp_butter|");
printf("hp_butter |");
printf("\n");
signal(SIGINT, __signal_handler);
running = 1;
u=1.0;
while(running){
printf("\r");
printf("%8.3f |", u);
printf("%8.3f |", lp);
printf("%8.3f |", hp);
printf("%8.3f |", lp+hp);
printf("%8.3f |", i);
printf("%8.3f |", lpb);
printf("%8.3f |", hpb);
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;
}