1 // sketch_13_05_band_stop_due
3 const long samplePeriod = 23L; // micro seconds
5 const int analogInPin = A0;
6 const int analogOutPin = DAC0;
8 // 1000 to 1500 band stop filter
9 // 44100 Hz sample rate
10 // http://www.schwietering.com/jayduino/filtuino/index.php?characteristic=bu&passmode=bs&order=1&usesr=usesr&sr=44100&frequencyLow=1000¬eLow=&frequencyHigh=1500¬eHigh=&pw=pw&calctype=float&run=Send
12 //Band stop butterworth filter order=1 alpha1=0.022675736961451 alpha2=0.034013605442177
28 v[2] = (9.655920584452e-1 * x)
29 + ( -0.9311841169 * v[0])
30 + ( 1.9018448769 * v[1]);
43 // http://www.djerickson.com/arduino/
44 REG_ADC_MR = (REG_ADC_MR & 0xFFF0FFFF) | 0x00020000;
45 analogWriteResolution(8);
46 analogReadResolution(8);
51 static long lastSampleTime = 0;
52 long timeNow = micros();
53 if (timeNow > lastSampleTime + samplePeriod)
55 int raw = analogRead(analogInPin);
57 float filtered = f.step(raw);
59 analogWrite(analogOutPin, (int)filtered);
60 lastSampleTime = timeNow;