Sunteți pe pagina 1din 29

Activity No.

10
Programming a Microcontroller based Signal Filter for a Data Acquisition System
Course Code:CPE 006 Program: CPE
Course Title: Microprocessor Systems Date Performed: 09/04/2018
Section: CPE51FB1 Date Submitted: 09/04/2018
Name/s: Instructor: Engr. Cris Hate
De Leon, Dean Rowel T.
Diaz, Renzo Miguel C.
Enorme, Ruth S.
Gayas, Maron Marving A.
Jornales, Niño L.
1. Objective:

The activity aims to demonstrate the students’ capability to build a filter program system by using an
analog input and demonstrate how the program executes. By the end of the activity, an analysis of data
gathered is to be presented.

2. Intended Learning Outcomes (ILOs):


After completion of this activity the students should be able to:
1. Setup the analog inputs to the Arduino Uno
2. Write a program to test the system.
3. Conduct experimentation procedures to test the system.
4. Analyze the collected data.

3. Discussions
Smoothing filters is a filter that eliminates unwanted noise or signals depending on the condition. This
Smoothing Filter stores up to 10 readings from the analog into arrays. Each value is summed up and
divided then gets the average from the last reading. By averaging, the new output value is smoothened
from the original output value.

High Pass 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 is 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
exceeds EMA_s to output signal.

4. Resources:
 Computer
 Arduino Uno
 5Kohm Resistor
 Potentiometer
 Breadboard

5. Procedures:

Methodology: In this activity, to setup the potentiometer as the analog input for the program, the 5V
supply is inserted to the side of the potentiometer and the other side is connected to the ground. Then
for the center pin of the potentiometer will be the analog input A0 or any analog pin out the Arduino
Uno.
1
Smoothing Filter Flowchart

2
High-Pass Filter Flowchart

Program:

SMOOTHING FILTER
const int numReadings = 10;

int
readings[num
Readings]; int
readIndex =
0;
int total = 0;
int

aver

age

3
= 0;

int

input

Pin =

A0;

void
setup()
{
Serial.
begin(
9600);
for (int thisReading = 0; thisReading < numReadings;
thisReading++) { readings[thisReading] = 0;
}
}

void loop() {
total = total -
readings[readIndex];
readings[readIndex] =
analogRead(inputPin); total
= total +
readings[readIndex];
readIndex = readIndex + 1;

if (readIndex >=
numReadings) {
readIndex = 0;
}

average = total /
numReadings;
Serial.print(analog
Read(inputPin);
Serial.print("\t");
Serial.println(avera
ge);
delay(1);
}

HIGH-PASS

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

4
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(senso
rPin); //set EMA
S for t=1
}

void loop(){
sensorValue =
analogRead(senso
rPin);
//read the sensor
value using ADC
EMA_S =
(EMA_a*sensorVal
ue) + ((1-
EMA_a)*EMA_S);
//run the EMA
highpass =
sensorValue -
EMA_S;
//calculate the
high-pass signal

Serial.println(highp
ass);

delay(20);
//20ms delay
}

5
6. Results
The following are the data collected using a 5kohm potentiometer while varying its value.

Smoothing Filter
Screenshots:

While increasing Analog Input

6
While decreasing Analog Input

Data Collected
0 0
0 0
0 0
0 0
0 0
0 0
0 0
3 0
11 1
16 2
23 4
36 7
42 11
54 17
62 24
71 30
71 38
79 46
90 53
87 61
90 69
105 76
109 82
108 87
118 92
126 98

7
141 104
144 110
125 116
151 121
160 127
160 134
177 140
172 147
176 151
179 155
169 160
185 166
196 172
207 179
204 184
226 190
232 196
220 203
252 212
245 220
254 227
273 233
264 239
278 247
283 252
289 261
289 267
311 273
319 281
335 289
351 297
336 308
386 318
378 327
386 338
409 349
415 363
409 375
436 386
434 395
443 407
455 416
462 424
466 434
483 444
499 453
488 460
490 469

8
519 477
529 488
532 497
539 506
562 515
555 522
562 528
569 536
575 542
588 550
600 558
607 563
613 571
634 579
626 587
607 593
637 602
624 608
620 614
648 620
649 626
655 633
662 638
673 643
688 649
699 658
708 665
718 675
725 684
727 694
727 701
744 710
754 719
754 727
759 734
769 742
761 749
790 755
793 763
814 771
806 779
839 788
839 797
854 808
856 819
852 826
874 837
884 845

9
873 854
892 862
902 870
909 878
927 886
931 894
960 902
958 913
978 922
980 932
995 943
998 952
1011 963
1018 974
1023 984
1023 992
1023 999
1023 1005
1023 1011
1023 1016
1023 1019
1023 1021
1023 1022
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1023 1023
1015 1022
1004 1020
991 1017
976 1012
958 1006
954 999

10
939 989
918 979
900 967
889 953
875 940
868 927
859 913
848 901
839 889
841 877
821 867
802 855
825 845
809 836
792 829
767 821
780 812
771 804
762 797
751 787
749 777
728 771
718 762
713 754
704 743
697 731
656 722
670 709
648 699
645 690
625 680
615 665
600 653
590 642
569 629
554 618
545 604
541 593
545 582
532 573
549 565
548 561
549 555
546 549
541 545
533 544
549 544
524 543

11
554 541
534 540
536 538
540 537
546 537
548 539
537 538
525 535
477 526
435 517
408 506
396 493
376 478
350 459
338 436
315 414
295 389
283 366
261 347
255 329
229 311
213 292
179 274
193 257
169 240
149 223
120 209
121 193
118 175
88 158
73 142
58 126
43 110
28 95
14 81
2 65
0 51
0 39
0 30
0 20
0 13
0 8
0 4
0 1
0 0

12
High Pass Filter
Screenshots

High Pass Filter at High Resistance

13
High Pass Filter at Low Resistance

Data Collected
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

14
0
0

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

0
0

15
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

16
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
3
6
10
12
12
15
14
13
13
10
16
13
11
14
14
15
12
12
13

17
12
12
12
14
11
10
11
9
8
9
7
8
10
7
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

18
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

19
17
12
9
7
3
5
4
1
1
3
3
3
3
1
3
3
0
3
0
3
3
2
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

20
-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
0
0
0
0
0
0
0
0
0
0
0
0

21
2
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0

22
0
0
0
0
0
0
1
0
0
0
0
0
0
0
0
2
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

23
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
8
4
3
3
3
4
1
3
2
2
2
0
3
2
1
0
2
3
3
2
2
3

24
2
2
2
2
2
2
3
1
1
3
1
0
2
3
1
1
1
0
0
1
0
0
2
2
2
2
1
3
2
1
1
0
2
1
3
0
2
2
1
1
1
0
1
1
1
1
3
2

25
1
1
2
1
1
0
0
1
2
1
2
1
2
1
2
0
3
1
1
2
1
2
1
2
1
1
2
1
1
0
3
2
2
2
2
3
2
2
1
1
2
0
1
1
1
2
2
2

26
1
1
1
2
1
1
2
1
2
1
1
0
2
0
2
3
2
3
1
2
2
1
2
0
3
2
3
1
1
2
2
0
0
3
3
1
2
2
2
0
1
2
1
2
2
2
1
2

27
0
2
2
0
2
3
0
2
2
2
1
2
0
2
2
1
0
1
3
1
7. Observations
Smoothing Filter
From the serial plotter, the original output value was taken comparing it to the last value then getting
the average from the two value to generate the new output value making the output smooth. The
higher the number, the more readings that can be smoothed, but slows the output based on the input
value given.

High Pass Filter


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.
8. Conclusions
Traditional filters can be converted into digital filters using Arduino Uno. Arduino Uno is capable of
reading and processing analog inputs, thereby making them a capable replacement for traditional
analog filters. A smoothing filter smoothens the analog input, filtering out most noise. A high-pass filter,
on the other hand, only lets through a range of frequency.
9. Assessment (Rubric for Laboratory Performance):

28

S-ar putea să vă placă și