This function sets the cut-off frequency of the low-pass filter.
dcmotor.setFilterFrequency(freq)
freq - a integer value which represents cut-off frequency of the low-pass filter
none
#include <PhpocExpansion.h>
#include <Phpoc.h>
byte spcId = 1;
int freq = 1000;
int count_prev = 0;
int count;
int diff;
ExpansionDCMotor dcmotor(spcId, 1);
void setup() {
Serial.begin(9600);
while(!Serial)
;
Phpoc.begin(PF_LOG_SPI | PF_LOG_NET);
Expansion.begin();
Serial.println(dcmotor.getPID());
Serial.println(dcmotor.getName());
dcmotor.setPeriod(10000);
dcmotor.setWidth(3000);
}
void loop() {
if(freq > 7000) {
dcmotor.setWidth(0);
return;
}
// set the cut-off frequency
dcmotor.setFilterFrequency(freq);
count = dcmotor.getFilterPNC();
diff = count - count_prev;
Serial.print("noise count at freq");
Serial.print(freq);
Serial.print(" : ");
Serial.println(diff);
freq += 200;
count_prev = count;
delay(200);
}