Sei sulla pagina 1di 27

High Pass Filter

Source Code:

int sensorPin = 0; //pin number to use the ADC

int sensorValue = 0; //initialization of sensor variable, equivalent to EMA Y

float EMA_a = 0.3; //initialization of EMA alpha

int EMA_S = 0; //initialization of EMA S

int highpass = 0;

void setup(){

Serial.begin(9600); //setup of Serial module, 9600 bits/second

EMA_S = analogRead(sensorPin); //set EMA S for t=1

void loop(){

sensorValue = analogRead(sensorPin); //read the sensor value using ADC

EMA_S = (EMA_a*sensorValue) + ((1-EMA_a)*EMA_S); //run the EMA

highpass = sensorValue - EMA_S; //calculate the high-pass signal

Serial.println(highpass);

delay(20); //20ms delay

}
Block Circuit/Circuit Diagram:

Flowchart:
Discussion:

A Filter is a device that eliminates unwanted noise or signals depending on the condition. A high-
pass filter only accepts signals with high frequencies and eliminates frequencies which do not make the
cut. The output are processed by the Arduino. The Arduino processes the analog input depending on the
source code given to it. The Arduino then outputs the desired signal. In this case, the sensor value must
exceed EMA_s to output the signal.

Screenshots:

i High Pass Filter at High Resistance


ii High Pass Filter at Low Resistance

Data Collected:

0
0

0
0

0
0

0
0

0
0

10

12

12

15

14

13

13
10

16

13

11

14

14

15

12

12

13

12

12

12

14

11

10

11

10

11

11

12

12

14
11

12

13

17

14

17

14

17

16

17

13

16

18

12

17

14

12

15

12

16

14

13

16

20

16

16

14

17

15
14

15

17

16

16

18

19

21

20

20

22

26

23

24

24

32

31

31

28

31

33

30

35

36

38

42

42

45

45
53

52

53

52

50

49

48

43

47

47

44

44

43

42

41

41

42

28

23

17

12

3
3

-17

-25

-34

-39

-44

-51

-48

-49

-49

-46

-49

-48

-48

-45

-48

-50
-55

-58

-53

-55

-53

-53

-46

-46

-46

-44

-42

-40

-43

-44

-49

-44

-44

-46

-46

-48

-44

-44

-42

-39

-39

-37

-40

-34

-35
-33

-33

-30

-30

-28

-23

-22

-21

-21

-18

-12

-8

-5

-3

-1

-1

2
0

0
0

0
0

11

19

22

28

32

35

37

40

40

42

41

40

40

39

43

40

38

37

36

37

35

37

36
35

36

37

35

36

38

39

42

42

40

42

42

40

42

46

44

47

42

42

42

44

45

47

49

45

45

43

40

38
35

24

18

13

11

2
2

1
0

1
2

2
0

1
2

2
0

Observation:

The researchers saw that when increasing the resistance of the potentiometer, the program accepts the
analog input. As the resistance of potentiometer decreases, the program surges to negative value then
stabilizes to zero.

Potrebbero piacerti anche