So the balancing is an interesting feature of mechanical switches, and it may cause some problems when
we connect the mechanical switch, such as push buttons or light switches to digital circuits.
This lecture will define this phenomenon and you'll explain how to solve that.
A mechanical switch such as a slight switch and a push button that we have on the basis three more toggles,
two metal plates touch each other to create an electrical circuit.
However, this touching process does not happen instantly.
The metal plates touch each other several times before the final stable connection is made.
Although this bouncing phenomenon can last milliseconds, a high logic circuit can detect all the bouncing
values.
To cope with this issue, we should balance the switch.
There are several techniques to implement a switch demands.
Electrical solution, digital solution, software solution.
The goal is describing a digital circuit, then necklace that converts the switch bounces signal outward
into a pulse with clear edges, let's assume the circuit clock and the switch bounces signal.
One of the simple ideas is using a delay after detecting an edge on the switch out.
For this purpose, the circuit samples the switch output on the rising edge of the clock when an age
is detected, it stops sampling for a period of time and then starts sampling again.
If the sampling polls delay is greater than the bouncing period, then the circuit can generate the
desired output.
Note that there are more robust solutions for the Swiftie bounce or circuit.
However, a study, all of these solutions is not the goal of this course.
Kurita White Essentialists project with the name of the bouncer Dasch White Essentialists.
Choose the basis to bought as a target FPGA platform.
Create a new design, Sourcefire and the New Testament, Sourcefire.
Open the design, Sourcefire.
Let's define the delay under escort counter macro for defining a five millisecond delay.
Our demands are circuit has to states transfer and delay in the transfer of state, it connects the
input signal to the output.
The circuit keeps the output unchanged in the delay state and waits for bounces on the input to expire.
The design top function has two arguments, an input and an output.
Let's define two static variables, one for the circuit, the state and another for saving the delay
counter.
We also need another static variable to keep the previous value on the input signal to detect an edge
on the.
Please know that these are static variables will be synthesized into registers in hardware.
Now let's define the temporary variables corresponding to two estate and countless static variables.
As we won't change the content of the previous underscore S.W. static variable in our Suchiate statement,
we don't need a temporary variable for that.
We also need a temporary variable corresponding to the output signal.
Now, let's define our state machine between states.
For this purpose, we use a switch case statement.
When the circuit is in the transfer state, it goes to the delay state.
If the current and previous values on this stability input are different, which means there is an edge
on this subject, otherwise it stays in the transfer state and the instability input is connected to
the output.
Also next, kountouris delay underscore counter macro.
In the DeLay state, the circuit recommends the counter on each clock, and when the counter gets to
zero, the state machine goes to transfer state.
In the delay state, the output signal keeps its previous value.
Finally, we should update the static variables and function output signal.
Now, let's try the test code, simulating the code for five hundred thousand clock cycles is not comfortable.
Let's reduce a delay only for simulation purposes and define the delay.
Underscore counter macro again for only 500 clock cycles.
Please open the test page Sourcefire include the iList three, Mahadev five and the design top function
prototype.
Now let's define the main function.
As usual, we should define the status valuable that returns the design correctness a status we need
to variables representing the design, input and output arguments.
Now, let's call the design for 5000 times while to establish an input signal, Izell.
And use a for loop with 250 iterations to generate a synthetic bouncing on this.
Then keep the S.W. input stable on the high logic level, using a 5000 iteration for now, let's insert
the artificial bouncer's on the input switch again.
Finally, keep the input signal stable on the low logic level.
Let's do the simulation to find possible syntax on some hunting arrows.
Here, I haven't printed any signal values on the screen that is not so readable, but you can do so
if you are interested now perform the synthesis and artillery simulation after that.
Don't forget to dump all signal values for inspecting their signal waveforms.
Now, let's click on the waveform viewer I come all the way from viewer will be opened shot design and
put an end to the signals and inspect the output signal, which is a clear pulse, even though there
are lots of bounces on the.
How can we design a digital counter in the next lecture will cope with this question.
These are our takeaway messages.
Mechanical switches suffer from bouncing phenomena.
If we are going to use the output of a mechanical switch as an input to a digital circuit, we should
utilize it.
The balancing mechanism.
There are several developing mechanisms available categorized into hardware and software solutions.
As the sweet bouncing is a low level physical phenomenon, low level solutions are usually more efficient
than high level software based solutions.
Now, the quiz question, calculate the delay in the code in terms of millisecond when DeLay underscore
Kountouris 500 and 500000.