#include unsigned int getData(File *data) { unsigned short int x,read; read = fread(&x,size(x),1,data); if(read == 0) { x = -1; } return x; } void signal(int *filteredData) { /*This code assumes a sampling frequency of 400Hz*/ float Phi = [0.25,0.25,0.25,0.25]; unsigned short int sig = 0; FILE *dummyData; int ctr=0; int sum,i; int acc1; /*accumulator for the 50Hz low pass*/ int dataBuffer[100]; int acc2[100]; /*accumulator for the 0.5Hz low pass*/ dummyData = fopen("fake.dat","rb"); while(ctr<400) /*Populate acc2, and phase shift the data by 200 cycles. A beter way would be prefered*/ { ctr++; sig = getdata(dummyData); acc1+= (unsigned int) sig; if(!(ctr%4)) { dataBuffer[(ctr/4)%100] = acc2[(ctr/4)%100] = acc1/4; } } while(sig != -1) /*We will need to integrate a shutdown sequence*/ { ctr++; sig = getdata(dummyData); acc1+= (unsigned int) sig; if(!(ctr%4)) { acc2[(ctr/4)%100] = acc1/4; for(int i = 99;i>=0;i--) { sum += acc2[i]; } *filteredData = dataBuffer[((ctr/4)+50)%100] - (sum/100); dataBuffer[(ctr/4)%100 ]= acc1/4; sum = 0; acc1 = 0; } if(ctr == 400) { ctr = 0; } } }