1
00:00:03,720 --> 00:00:04,030
Hello.

2
00:00:04,050 --> 00:00:05,340
Welcome back.

3
00:00:05,340 --> 00:00:12,870
So I said mention in the next two lessons we are going to see how we can use timers to count the occurrence

4
00:00:12,960 --> 00:00:13,850
of events.

5
00:00:13,890 --> 00:00:21,000
And we are also going to see how we can use timers to measure the time between two events occurring

6
00:00:21,570 --> 00:00:22,760
and to do that.

7
00:00:22,860 --> 00:00:26,050
I'm going to bring you over here to politics and dot com.

8
00:00:26,100 --> 00:00:32,190
This the official website for this cortex AMC which you watching were written a couple of articles on

9
00:00:32,190 --> 00:00:37,080
this Web site for this particular topic which I'll be treating today.

10
00:00:37,080 --> 00:00:45,900
So just type cortex and dot com hits enter you'd come to the cortex and page you just go to lessons

11
00:00:46,170 --> 00:00:48,830
and we've got the we've got free lessons.

12
00:00:48,840 --> 00:00:53,170
And part of those free lessons are the lessons that we are interested in.

13
00:00:53,340 --> 00:01:04,380
So to demonstrate how how time is used to current events we going to take a case study approach right.

14
00:01:04,410 --> 00:01:10,400
And we have a very nice example here when you come here you select count and event.

15
00:01:10,440 --> 00:01:15,090
There is this nice blog post that explains everything in detail.

16
00:01:15,090 --> 00:01:16,770
We will read this first.

17
00:01:16,830 --> 00:01:22,070
I'll explain how it works and then we go back to your vision and then write the code.

18
00:01:22,080 --> 00:01:25,470
Show us the title of this post it says.

19
00:01:25,860 --> 00:01:30,000
It says use in time is to count parents of an event.

20
00:01:30,000 --> 00:01:32,160
And I'll just do a bit of reading here.

21
00:01:32,190 --> 00:01:35,090
Taking you back to the old days in a classroom.

22
00:01:35,100 --> 00:01:42,390
So do part and media as we discussed in the lesson on creating delays using time as timers are usually

23
00:01:42,390 --> 00:01:49,110
used to perform three kinds of tasks creating delays counting events and measuring the time between

24
00:01:49,110 --> 00:01:52,240
events and the previous lessons.

25
00:01:52,240 --> 00:01:59,770
We looked at the basics of time as how to find a time interval value based on the frequency of your

26
00:01:59,770 --> 00:02:00,930
microcontroller.

27
00:02:01,060 --> 00:02:05,860
How to create delays in units of microseconds milliseconds and seconds.

28
00:02:05,860 --> 00:02:14,290
We also explained the meanings of the various time configuration modes such as 16 bids 32 bit up now

29
00:02:14,290 --> 00:02:21,190
counter etc. If you are not familiar with these topics please go back and watch the previous videos.

30
00:02:21,190 --> 00:02:29,500
That being said in this lesson we are going to talk about the second use case of time as that is counting

31
00:02:29,500 --> 00:02:30,460
events.

32
00:02:30,550 --> 00:02:36,200
Events are detected by signal or voltage level transitions.

33
00:02:36,280 --> 00:02:43,300
For example when a switch connected to a microcontroller as an input is pressed the microcontroller

34
00:02:43,330 --> 00:02:50,950
detects this press action because of the signal changes that occur are the pin as we can see in the

35
00:02:50,950 --> 00:02:52,030
diagram below.

36
00:02:52,030 --> 00:03:00,940
One leg of one leg of the pin is connected to DC 5 vote and the other leg is connected to the microcontroller

37
00:03:00,970 --> 00:03:01,960
pin.

38
00:03:01,960 --> 00:03:09,420
When we close the switch the microcontroller pin receives high signal which in this case is DC five

39
00:03:09,420 --> 00:03:10,150
votes.

40
00:03:10,180 --> 00:03:16,340
When the switch is open or is off the microcontroller is disconnected from the DC 5 board.

41
00:03:16,390 --> 00:03:18,850
Therefore it goes back to low.

42
00:03:18,880 --> 00:03:20,600
So this is the arm.

43
00:03:20,680 --> 00:03:27,760
This is basically how switches are detected and this is how events are also detected in microcontrollers

44
00:03:28,120 --> 00:03:30,700
and various computing applications.

45
00:03:30,700 --> 00:03:37,720
Now let's look at the difference or less elaborates on rise in age and fallen edge because these are

46
00:03:37,720 --> 00:03:43,180
the two main characteristics used in decision making.

47
00:03:43,180 --> 00:03:49,630
The transition of the signal from low to high gives us the rights and age and the transition of a signal

48
00:03:49,630 --> 00:03:51,880
from high to low gives us the fallen edge.

49
00:03:52,330 --> 00:04:02,890
Besides we move from DC 0 vote to DC 5 vote by rising and move from DC 5 votes to DC 0 vote by.

50
00:04:03,220 --> 00:04:06,000
Hence the name rise in age fallen age.

51
00:04:06,040 --> 00:04:11,470
It is quite important to grasp this concept because this is how we really can't.

52
00:04:11,470 --> 00:04:18,070
The occurrence of events and also calculate the duration of a particular event.

53
00:04:18,400 --> 00:04:24,430
In this lesson we used a switch as an example because it is the most basic inputs component.

54
00:04:24,430 --> 00:04:31,390
However the principle works the same way for all other components such as sensors and external logic

55
00:04:31,390 --> 00:04:31,910
gate.

56
00:04:31,930 --> 00:04:34,230
We connect to our microcontrollers.

57
00:04:34,660 --> 00:04:37,840
Let's look at a use case.

58
00:04:38,080 --> 00:04:43,930
Let's say we have design in a system that counts the number of people passing through airport security.

59
00:04:44,350 --> 00:04:48,490
We can design a simple low cost people's counter.

60
00:04:48,520 --> 00:04:55,180
If you meet with a single laser light and a light dependent resistor and a microcontroller Of course

61
00:04:55,780 --> 00:05:01,400
all we need to do is decide on where we want the cross line to be Place.

62
00:05:01,420 --> 00:05:08,560
Place the laser light on one end and the light dependent resistor connected to our microcontroller.

63
00:05:08,560 --> 00:05:15,670
On the other hand depicted here we have the laser light emitting this red laser light and then we have

64
00:05:15,670 --> 00:05:20,500
the oh the are the light dependent resistor here connected to the microcontroller.

65
00:05:20,500 --> 00:05:27,460
So in this very simple example when you turn on the laser light make sure it is pointing exactly on

66
00:05:27,460 --> 00:05:29,970
the head of the light dependent resistor.

67
00:05:30,070 --> 00:05:34,680
Remember the light dependent to resist that it's a light sensor.

68
00:05:34,870 --> 00:05:42,340
Changes resistance based on the amount of light shown on its head because we are not interested in calculating

69
00:05:42,340 --> 00:05:43,180
the amount of light.

70
00:05:43,180 --> 00:05:49,450
We simply said the microcontroller pin of our LTE R as a digital input pin.

71
00:05:49,450 --> 00:05:55,480
Now it's basically becomes the switch we discussed earlier when the path of light between the laser

72
00:05:55,480 --> 00:06:00,530
lights and the LDA are is broken which will happen when people cross.

73
00:06:00,790 --> 00:06:07,090
When people walk across the laser light the voltage at a microcontroller inputs being changes and this

74
00:06:07,090 --> 00:06:16,360
change happens in the form of rising edge or falling edge depending on how you connect the LTE are whether

75
00:06:16,360 --> 00:06:19,040
to G and D or to DC fivefold.

76
00:06:19,150 --> 00:06:26,230
We can count the number of these changes to determine the number of people who have crossed the line.

77
00:06:26,350 --> 00:06:34,390
So this an excellent example on a very demonstrative way of using time is to count the occurrence of

78
00:06:34,390 --> 00:06:40,660
an event and we have this little note here it says what this system is not entirely foolproof.

79
00:06:40,660 --> 00:06:45,580
For instance when two people walk side by side it will be difficult to count them both.

80
00:06:45,580 --> 00:06:52,960
How ever we hope it provides sufficient explanation on how counting works.

81
00:06:52,960 --> 00:06:57,520
So basically you can come back to this article and take a look at it.

82
00:06:57,700 --> 00:07:06,730
And if you have further questions just live in India and the question is sections below and in the next

83
00:07:06,880 --> 00:07:14,920
lesson we will take a look at how to set up our time off for and events and then after that we go to

84
00:07:14,920 --> 00:07:17,650
you vision to write the actual code.

85
00:07:17,680 --> 00:07:19,810
So see you in the next lesson.
