Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <math.h>
- #include <DueTimer.h>
- int r;
- float Fs = 10000;
- float out = 0;
- const float BL = 11;
- float X[11] = {
- 0, 0, 0, 0,
- 0, 0, 0, 0,
- 0, 0, 0
- };
- const float B[11] = {
- 0.02285587755007, 0.01644493311478, -0.1103146181308, -0.1996653808026,
- 0.1052876191363, 0.3774952159645, 0.1052876191363, -0.1996653808026,
- -0.1103146181308, 0.01644493311478, 0.02285587755007
- };
- void timerInterrupt(void)
- {
- X[0] = analogRead(A0);
- out = 0;
- for(int i = 0; i < BL; i++)
- {
- out += X[i] * B[i];
- }
- X[10] = X[9];
- for(int i = (BL - 1); i > 0; i--)
- {
- X[i] = X[i - 1];
- }
- analogWrite(DAC1, out + 1000);
- }
- void setup() {
- analogReadResolution(12);
- analogWriteResolution(12);
- pinMode(A0,INPUT);
- Timer3.attachInterrupt(timerInterrupt);
- Timer3.start(100); //10khz sampling
- }
- void loop() {
- r++; //do something useless
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement