Hello.
Welcome back.
So I said mention in the next two lessons we are going to see how we can use timers to count the occurrence
of events.
And we are also going to see how we can use timers to measure the time between two events occurring
and to do that.
I'm going to bring you over here to politics and dot com.
This the official website for this cortex AMC which you watching were written a couple of articles on
this Web site for this particular topic which I'll be treating today.
So just type cortex and dot com hits enter you'd come to the cortex and page you just go to lessons
and we've got the we've got free lessons.
And part of those free lessons are the lessons that we are interested in.
So to demonstrate how how time is used to current events we going to take a case study approach right.
And we have a very nice example here when you come here you select count and event.
There is this nice blog post that explains everything in detail.
We will read this first.
I'll explain how it works and then we go back to your vision and then write the code.
Show us the title of this post it says.
It says use in time is to count parents of an event.
And I'll just do a bit of reading here.
Taking you back to the old days in a classroom.
So do part and media as we discussed in the lesson on creating delays using time as timers are usually
used to perform three kinds of tasks creating delays counting events and measuring the time between
events and the previous lessons.
We looked at the basics of time as how to find a time interval value based on the frequency of your
microcontroller.
How to create delays in units of microseconds milliseconds and seconds.
We also explained the meanings of the various time configuration modes such as 16 bids 32 bit up now
counter etc. If you are not familiar with these topics please go back and watch the previous videos.
That being said in this lesson we are going to talk about the second use case of time as that is counting
events.
Events are detected by signal or voltage level transitions.
For example when a switch connected to a microcontroller as an input is pressed the microcontroller
detects this press action because of the signal changes that occur are the pin as we can see in the
diagram below.
One leg of one leg of the pin is connected to DC 5 vote and the other leg is connected to the microcontroller
pin.
When we close the switch the microcontroller pin receives high signal which in this case is DC five
votes.
When the switch is open or is off the microcontroller is disconnected from the DC 5 board.
Therefore it goes back to low.
So this is the arm.
This is basically how switches are detected and this is how events are also detected in microcontrollers
and various computing applications.
Now let's look at the difference or less elaborates on rise in age and fallen edge because these are
the two main characteristics used in decision making.
The transition of the signal from low to high gives us the rights and age and the transition of a signal
from high to low gives us the fallen edge.
Besides we move from DC 0 vote to DC 5 vote by rising and move from DC 5 votes to DC 0 vote by.
Hence the name rise in age fallen age.
It is quite important to grasp this concept because this is how we really can't.
The occurrence of events and also calculate the duration of a particular event.
In this lesson we used a switch as an example because it is the most basic inputs component.
However the principle works the same way for all other components such as sensors and external logic
gate.
We connect to our microcontrollers.
Let's look at a use case.
Let's say we have design in a system that counts the number of people passing through airport security.
We can design a simple low cost people's counter.
If you meet with a single laser light and a light dependent resistor and a microcontroller Of course
all we need to do is decide on where we want the cross line to be Place.
Place the laser light on one end and the light dependent resistor connected to our microcontroller.
On the other hand depicted here we have the laser light emitting this red laser light and then we have
the oh the are the light dependent resistor here connected to the microcontroller.
So in this very simple example when you turn on the laser light make sure it is pointing exactly on
the head of the light dependent resistor.
Remember the light dependent to resist that it's a light sensor.
Changes resistance based on the amount of light shown on its head because we are not interested in calculating
the amount of light.
We simply said the microcontroller pin of our LTE R as a digital input pin.
Now it's basically becomes the switch we discussed earlier when the path of light between the laser
lights and the LDA are is broken which will happen when people cross.
When people walk across the laser light the voltage at a microcontroller inputs being changes and this
change happens in the form of rising edge or falling edge depending on how you connect the LTE are whether
to G and D or to DC fivefold.
We can count the number of these changes to determine the number of people who have crossed the line.
So this an excellent example on a very demonstrative way of using time is to count the occurrence of
an event and we have this little note here it says what this system is not entirely foolproof.
For instance when two people walk side by side it will be difficult to count them both.
How ever we hope it provides sufficient explanation on how counting works.
So basically you can come back to this article and take a look at it.
And if you have further questions just live in India and the question is sections below and in the next
lesson we will take a look at how to set up our time off for and events and then after that we go to
you vision to write the actual code.
So see you in the next lesson.