Assignment 3 Tania, 102183029
Assignment 3 Tania, 102183029
Exercise 1 – To construct a circuit which will record and display the length of time taken by the
throwing arm on the Mangonel to pass between the sensors mounted on the chassis. Implement
the real hardware on the breadboard, at the input side of the Arduino. Demonstrate the hardware
and software by attaching to a real Mangonel.
Hardware Required
CD4027, CD4081, CD4543
Arduino Uno
Seven Segment Display
Single core connecting wires
Digital Trainer Kit
Tinkercad Software tool (https://www.tinkercad.com/)
Theory
The circuit is required to:
Accept the individual inputs from the two sensors on the Mangonel,
Combine the two signals into one,
Convert the two short pulses into one long pulse,
Deliver this pulse to the relevant input on the Arduino Board,
Required signal:
The signal required for the Arduino program is shown in figure 2:
Figure 2: Required signal for Arduino.
Of the devices above, the best choices for combining our two signals into one are the AND or
NAND gates as either will preserve the signal from each individual sensor whilst also combining
the two signals into one. It is important to note that NAND is simply inverted AND, similarly, if
we invert NAND, we get AND again.
Figure 5 shows how the logic signals from the inputs are each maintained but combined into one
signal. The next task is to convert the two small pulses into one long pulse.
Looking at the AND output signal, it could be argued that we already have a long pulse from this
step alone – however, the long pulse between the two short pulses given by the AND logic is not
an accurate measurement of the transit time of the arm because the pulse length is shortened by
the width of the second pulse. We need to generate a single long pulse as shown in figure 6
which extends from either the rising or falling edge of the first pulse, to the corresponding edge
of the second pulse.
This can be achieved by using the two shorter pulses in the output of the AND gate to “toggle”
or “clock” the output of a latching logic device. For this purpose, we are going to use a J-K flip-
flop.
Figure 7: J-K flipflop and function table.
The J -K flip- flop is the most versatile of the basic flip -flops. It has two inputs, traditionally
labelled J and K. If J and K are different then the output Q takes the value of J at the next clock
edge. If J and K are both low then no change occurs. If J and K both are high at the clock edge
then the output will toggle from one state to the other.
This toggle application means that we can use the two signal pulses from the output of the AND
gate to cause the output of the flip-flop to change state, hence allowing us to create one long
pulse between the corresponding edges of the two shorter pulses. The device also has set and
reset functions which will be useful for clearing the output states when we want to start a new
timing run. Figure 7 shows the function table of the J-K flip-flop.
The output of out J-K flip-flop then goes to the appropriate input of the Arduino and from there
the program in the Arduino will measure the length of the pulse and output the appropriate
values to the various registers on the display. Hence, our circuit should wind up looking
something like this:
Figure 8: Circuit Schematic
Explain Figures 9 succinctly, in fewer than 50 words per stage, each of the five stages involved
in measuring the swing time of the Mangonel arm.
Figure 9: Stages 1 to 5
Schematic Diagram
Reflection:
Assignment Tasks:
1. Obtain the required signal for Arduino shown in figure 2 using at least two different logic
gates (explain using waveforms).
2. Using Tinkercad, design the following sensor based micro-projects to:
With the help of first task, we can determine the angular velocity of mangonel arm.
Using logic gates like AND, NAND or XOR, we can bring out the desired output
signal with the help of which we can determine the time take by the arm to move
from one location to another. Using this time, we can determine the angular
velocity of the arm and hence can design the mangonel with concerned precision.
Although, without the sensors discussed in the second task, measuring the angular
velocity will not be possible.
Using different sensors, we can fulfil different purposes. Using an IR sensor such
as PIR sensor we can determine movement. Thus, the output signal sent by this
signal can serve as the input signal of mangonel signals with the help of which we
can make the concerned output signal as shown in first task, and measure the time.
Similarly, ultrasonic sensors can also be used to measure distances. Thus, with the
help of these sensors we can understand and detect the motion of the mangonel