Logical Circuit Responsible For Controlling The
Logical Circuit Responsible For Controlling The
DIGITAL ELECTRONICS I
Page 1
Adam López Jesus
Autonomous University of Mexico City
Nothing human is foreign to me
INTRODUCTION:
A vending machine is a machine that provides snacks, drinks, candies, and other items.
products to consumers. It involves selling without the presence of a sales assistant to collect the payment.
articles. Periodically, an employee replenishes the product and collects the money in the form of coins or,
less frequently, bills; sometimes you can also pay with a prepaid card, credit card or
mobile phone
The possibilities of vending machines are vast. They usually sell soft drinks, coffee,
food, snacks, etc. But there are also models designed to sell newspapers, books, stamps of
post, public transport tickets, alcoholic beverages, tobacco cigarettes.
A vending machine in English is known as a 'vending machine'. Therefore, the word 'vending' is
frequently used to refer to the vending machine sector.
Coffee vending machines are characterized by the excellent profit margins that are achieved by
product. These types of machines come in fully automatic or semi-automatic, depending on the
customer needs. In them, American or decaf coffee can be sold, as well as gourmet coffee.
like cappuccino, espresso, mochaccino, french vanilla, amaretto, chocolate, etc.
The case we are dealing with is much simpler, as our vending machine only dispenses two types of drinks,
coffee and milk.
As an initial prototype, the machine will only accept $1.00 and $2.00 coins. The system allows to display the
remaining amount that needs to be deposited to cover the cost of the drink.
Design considerations
The logic circuit must indicate that a drink can be selected as long as it has been
covered the amount of seven pesos.
It is not possible to deposit two coins at the same time.
3. For this prototype, consider that if $1.00 is missing to cover the amount, it can be introduced.
two-dollar coin, which will cover the amount, but the machine must be able to give change.
change.
Page 2
Adame López Jesús
Autonomous University of Mexico City
Nothing human is alien to me
4. The coin insertion will be emulated using two momentary push buttons.
that will be operated by the user.
DEVELOPMENT:
We will begin the project by determining the system's needs and developing a plan that
satisfy these needs. Based on the description made in the previous section (considerations of
design), several subsystems are needed, which are: Coin counter for inserted coins, comparator and
show results.
Note: Only two displays were actually used, since if we use the display in which it is shown the
price of the drinks to show the amount that needs to be entered, the cost of the
circuit without compromising its functionality.
Counter Results:
coins Comparator: The first display shows the
introduced Cost of beverages vs price of the drinks and in the
Coins the second display shows the
introduced change.
Coin counter: This stage of the circuit will be responsible for counting the number of
coins of one and two pesos that are being introduced.
Comparator: It will be at this stage of the circuit where it will be decided whether the number of coins
introduced is enough to cover the amount of the drink, or if it has been exceeded.
Results: It is used to display at every moment what is happening with the system.
it will show how many coins are missing to cover the amount of the drink,
LOGICAL DESIGN:
To organize the logical circuit design of the vending machine's wallet, each module
identified in the needs will be designed and tested independently, once tested and
Page 3
Adam López Jesus
Autonomous University of Mexico City
Nothing human is foreign to me
Once functioning, they will be combined to form the complete circuit. In the following lines
we will design each module.
For the anti-bounce circuit, it was decided to use a NE556 IC that contains two in the same package.
NE555, one for each button. Each of the NE555 is used in multivibrator configuration.
monostable.
The monostable is a multivibrator circuit that performs a sequential function consisting of when
receive an external excitation, changes state and remains in it for a period that follows
determined by a time constant. After that period of time has elapsed, the output of
monostable returns to its original state. Therefore, it has a stable state (hence its name) and a state
almost stable.
To avoid bounces, the push button will be connected to the trigger pin of the 555, which will send a pulse in
high that will take enough time for the push button signal to stabilize, in this way it
they will prevent button bouncing. If the button press takes longer than the set time of
The 555 timer will keep its output in a 'high' state until the button is released.
NE555
Trigger pin
I decide to set the capacitor value at 100 µF, and the time at 0.5 seconds, substituting those values into the formula.
By rearranging for 'R', it is obtained that the resistance value is 4.545 kΩ, but since there is no value
A commercial one of 4.545 kΩ is used, one of 4.7 kΩ.
Page 4
Jesus Adam López
Autonomous University of the City of Mexico
Nothing human is foreign to me
Once the problem of the bounces is resolved, we continue with the one and two peso counters respectively.
For the one-bit counter, it was decided to use a C.I. 74LS161N, which is a 4-bit synchronous counter.
The circuit is shown in the following figure.
The $1.00 counter is very simple, as it only connects the "push button" to the clock pin of the 74LS161.
Thus, each time the button is pressed, the counter will advance one step, which will result in the output of said
count the number of times the $1.00 button has been pressed, its output is pins 11 to 14, with the LBS being the
pin 11 and the MBS pin 14.
The output of the counter is connected to a 74LS83 IC, which is a 4-bit full adder, later on it
it will explain its operation.
For the $2.00 coin counter, it was decided to design a counter that counts by twos, as shown below.
steps for the design.
The first step is to create the state diagram, which shows all the states of our counter.
Table of states
Zero
1 1
Ocho Dos
1 1
Seis Cuatro
1
Page 5
Adam López Jesus
Autonomous University of Mexico City
Nothing human is alien to me
STATE Q3 Q2 Q1 Q0
Zero 0 0 0 0
Two 0 0 1 0
Four 0 1 0 0
Six 0 1 1 0
Eight 1 0 0 0
Truth table
0 0 0 0 0 0 1 0 0 x 0 x 1 x 0 x
0 0 1 0 0 1 0 0 0 x 1 x x 1 0 x
0 1 0 0 0 1 1 0 0 x x 0 1 x 0 x
0 1 1 0 1 0 0 0 1 x x 1 x 1 0 x
1 0 0 0 0 0 0 0 x 1 0 x 0 x 0 x
J3=3Q2 J2=1 J 1= 1 J 0= 0
Q1 Q1 Q1
Q3 Q0 Q1 Q3 Q3 Q0
Q2 00 01 11 10 Q3 Q Q0
Q2 00 01 11 10 Q2 00 01 11 10
Q2 00 01 11 10
0
00 0 x x 0 0 x x 1 00 1 x x x 00 0 x x 0
00
01 0 x x 1 x x x x 01 1 x x x 01 0 x x 0
01
11 x x x x x x x x 11 x x x x 11 x x x x
11
10 x x x x 0 x x x 10 x x x x 10 0 x x x
10
Page 6
Adam Lopez Jesus
Autonomous University of Mexico City
Nothing human is alien to me
Circuit diagram
The output of the $2.00 counter is formed by the 'Q' of each of the Flip-Flops. This output is
introduce to the input 'B' of the 74LS83 adder mentioned earlier in the $1.00 counter.
Each time the $2.00 button is pressed, the counter will advance one state, which will give you its
output the amount of money that has been introduced in $2.00 coins.
To know how much money has been entered in total, a C.I. 74LS83 is used, which is an adder.
4-bit asynchronous complete has two 4-bit inputs each and a 4-bit output as well.
It will be more than sufficient for our purposes.
At input 'A' of the adder, the output of a weight counter is connected, and input 'B' is connected to
the output of the two-peso counter. In this way, the total amount of money will be available at the output of the adder.
introduced to the machine.
STAGE 2: COMPARATOR
At this stage, the amount of money inserted is compared to the price of the drinks. This stage is very
simple since for this purpose the C.I. 74LS85 has been used, which is a 4-bit comparator, which
It consists of two inputs, each of 4 bits and three outputs of one bit each.
correspond to the status of the entries, as they inform us when an entry is greater than, less than or equal to
the other one. Having the information about the operation of the comparator (obtained from the sheet of
specifications of it) we are already in a position to use it, therefore it is connected to its input 'A'
a fixed number, that is, the seven pesos that either of the two drinks costs, and in the other entry
connect the output of the adder, in this way the comparator will inform us if we have already deposited the amount
Page 7
Adame López Jesús
Autonomous University of Mexico City
Nothing human is alien to me
of money needed, if we have already exceeded or if on the contrary we have not yet deposited enough. For this
It has three output pins, pins 5, 6, and 7, which are 'A>B', 'A=B', and 'A<B' respectively.
What we are interested in knowing is at what moment input 'B' is greater than or equal to input 'A'.
or in other words, at what moment have we deposited 7 pesos or more.
Here ends the task of our comparison stage, the next stage will take care of using the
two signals that are being sent, both the one indicating that the seven weights have been completed, as well as the
which indicates that more than 7 pesos have already been deposited.
In the final stage of the design of our circuit, we will take care of showing on a couple of displays what
is happening with our machine. For this stage, the front of the machine was designed, which
show below.
To inform the customer the price of the drinks, the amount of money that is missing to deposit, and the change.
which will be given, two displays were used, one marked with the name 'deposit' and the other with the name
change
DISPLAY 'DEPOSITE'
The 'deposit' display will show the price of the drinks, until the moment the customer starts to
deposit coins, at that moment the display will change and inform you how much money you need to deposit
to cover the amount of the drink, which will be updated each time you deposit a new coin. Once
the cost of the drink has been covered, this display will show the price of seven pesos again for
wait for the next customer.
Page 8
Adam López Jesus
Autonomous University of Mexico City
Nothing human is alien to me.
To achieve the operation described in the previous paragraph, a C.I. 74LS83 was used, which is a
full adder, we already used one of these to add the coins of one and two pesos, only that in this
On occasion, it will be used as a subtractor; it should be recalled that an adder can be used as a subtractor.
only one of the addends needs to be complemented to two. The circuit is shown below.
in charge of that task, immediately after there will be an explanation of it.
Stage Three
Used adder
as a restorer
Adder of the
stage 1
Counter of
coins
introduced.
Stage One
As can be observed in the previous figure, the output of stage 1 'Coin Counter'
it is complemented to one with some inverters, and in turn complemented to two in the adder (subtractor),
to complement the two of a number that is in one's complement, it is only necessary to remember that it suffices
add one to it, which is done in the adder (subtractor) by setting the carry (pin 13) to logical "one" of
In this way, the adder becomes a subtractor, since the input 'B' is complemented to two.
Page 9
Adam López Jesus
Autonomous University of Mexico City
Nothing human is alien to me
All of the above is to ensure that the display 'Deposit' decreases the number it shows on
your screen depending on the amount of money that is deposited in the machine's piggy bank.
A fixed number, which is a seven, is placed at input 'A' of the mentioned subtractor, since the cost
any of the two drinks costs seven pesos. Thus, the display starts at 7, and as it is adjusted
depositing coins will decrease the number shown, as the seven at entry 'A' will be
subtracting the amount of money entered into the piggy bank, which is complemented to 2 at the entrance
B
But we are not finished yet, as the output of the subtractor is a number in BCD, and to display it we must
encode it to 7 segments, which we do with a 74LS47 IC since the display used is common anode
common.
And to know when to stop subtracting, the output from stage 2 "comparator" is used, which tells us
Inform when the fee has been completed or if more has already been deposited than the cost of the drink.
In either case, a reset signal will be sent to the counters of stage one, which will
input "B" of the subtractor in stage two will be zero, therefore, zero will be subtracted from seven, and on the display
"Deposite" will again display a seven.
CHANGE
The display 'change' will show the change that the machine will dispense, due to the restrictions on the
coins it accepts, the machine will only be able to give zero or one peso in change, therefore the display 'change'
it will only show zero or one.
To know if change needs to be given, the carry output of the subtractor (pin 14) is used, which sends a
signal of a logical "one" when there is a carry, in our case there is a carry every time the input "B"
is greater than the input 'A', that is, the amount of money entered is greater than seven pesos
how much do the drinks cost.
This carry signal is used to form a 'one' at the input of a 74LS47 IC, in order to achieve
to form the 'one' with the signal sent by the carrier, the only thing that was done was to connect the output of the carrier
with the LSB of the input of the 74LS47 and the other three bits sent to ground.
In either case, a visible signal must be sent to inform the client that they can choose.
your drink, for which a LED will be turned on.
The solution seems simple, it would only require using a two-input OR gate, in one
from its inputs, the carry signal of the subtractor would be connected, and in the other, the signal from the comparator of the
stage 2, so it seems that it is resolved.
The problem for both the LED and the change displayed on the 'change' screen is that when
the counters are reset so that the display 'deposit' shows $7.00 again, the carry signal of the
the restorer resets to 'zero' logically, or in its case when the amount of money inserted was exact, the signal
Page 10
Adam López Jesus
Autonomous University of Mexico City
Nothing human is alien to me
that the comparator of stage 2 indicates that the amount of the drink has also been covered
return to "zero" logic.
To fix that issue and ensure that the change continues to be displayed and that the LED remains on even though the
The signal that activated them returns to 'zero' will use a J-K Flip-Flop with asynchronous preset and reset, one for
each signal, the C.I. 74LS112 contains two Flip-Flops with these characteristics, which provides us with
Perfect, since we need one for the carry signal of the subtractor and another for the signal of the comparator.
from stage 2, and taking advantage of the fact that the output of the Flip-Flops remains at 'one' indefinitely
it will be used to reset the counters of stage one, thus it will stop accepting coins while the signal of
Selecting drink is in 'one', but since the counter resets are activated with a 'zero',
we will have to pass that signal through an inverter to ensure that it always receives a 'one' and when
the signal is activated with a 'zero'.
With this we finish the logical circuit that will control the wallet of the coffee vending machine.
CONCLUSIONS
Many changes were made to the original circuit, as although in the simulation a certain circuit
it can work perfectly, when wired it doesn't work "as well" as in the simulation, for example,
With the circuit that would send the signal indicating that the 7 pesos have been deposited, 3 circuits were made.
Different, first, it was tried with gates, a 3-input NAND was placed at the output of the subtractor.
to obtain a high output when its first three bits were zero, that is, when the number
of coins entered equal to seven pesos, and to detect when it had already been exceeded, the it was used.
outgoing transfer of said rater. But it did not work, since it was already causing problems in the simulation, since the
State transition is not clean, but rather some outputs that should not be activated turn on for seconds.
activate, and since the output sends a flip flip, it was enough for some fractions to be activated
second for the flip flop to detect it and keep the output high, therefore it was discarded, then
to avoid the problems of transitions, it was decided to use a comparator, with which the simulation
it was working perfectly, but when doing the wiring and conducting some tests, the same error was found with
the transitions, since if payments were made with two consecutive 2 peso coins, the LED would light up
indicating that it was already possible to select the drink and there was even a change weight! well, that about
There was a change; it wasn't so bad, since it informed me which exit was falsely turning on, and
it was, of course, the output of the comparator indicating that input 'B' was greater than input 'A'
remember that at entry 'A' a seven was formed and at entry 'B' the sum of coins was connected
introduced), to solve it, we reverted to the previous solution, since in that solution the signal that
the failure was the one that indicated that 7 pesos had been introduced exactly, but the one that indicated that there was
Change worked very well, so it was decided to use one and one, to take what worked well from
each of them, for which, the comparator used the signal that indicates that 7 pesos were introduced
exactly, and the signal that indicates there is a change was taken from the carrying of the subtractor.
Another problem was the buttons, as with the bouncing, the counters were activated more times than
the button had been pressed, then, if I pressed the weight button once, it really appeared as if
I would have pressed it four, five or more times, so an anti-bounce circuit was added, first it
he tried the simplest one, a capacitor, but it didn’t work quite well since it still didn’t filter everything
Page 11
Adame López Jesus
Autonomous University of Mexico City
Nothing human is alien to me
rebounds, later, searching on the internet it was found that a resistor should be added to the capacitor, but
even so, some rebounds were missed, so searching more on the internet, a circuit was found with a
monostable multivibrator, but they were also skipped, so it was decided to change the buttons, for
some that didn't have so much displacement (because the first ones had to move a lot from the
rest until the point where the plates made contact) and thus the problem was solved, this last circuit.
it was the one that was implemented, although I suppose that since the buttons had already been changed it would have worked
any of the previous anti-bounce circuits.
Page 12
Adam López Jesus
Autonomous University of Mexico City
Nothing human is alien to me
BIBLIOGRAPHY
2. M. Morris Mano. "Fundamentals of Logic Design and Computers", Ed. Pearson Education
3. Website:http://en.wikipedia.org/wiki/Vending_machine
4. Web page:http://www.ervending.com/cafe.htm
5. Website:http://en.wikipedia.org/wiki/Vending
6. Web page:http://es.wikipedia.org/wiki/Monoestable
Page 13
Adam López Jesus