Check out how to create a piggy bank coin counter with a GreenPAK™ IC
Below we described steps needed to understand how the solution has been programmed to create a coin counter. However, if you just want to get the result of programming, download GreenPAKâ¢ software
to view the already completed GreenPAK Design File
. Plug the GreenPAK Development Kit
to your computer and hit the program to design the solution.
This project will describe how to create a piggy bank coin counter with a GreenPAK. This piggy bank counter will utilize three primary components:
GreenPAK SLG46531V: The GreenPAK serves as the interpreter between the sensors and display values. It is also the IC responsible for reducing the power consumption of the whole circuit, by implementing PWM to drive the second component.
The CD4026: The CD4026 is a dedicated IC for driving the 7-segment LED displays. It is quite similar to the CD4033, which can also be used to drive the displays used in this project. However, it is recommended to use the CD4026 as its Display Enable IN pin will allow us to reduce the power consumption by implementing a PWM.
The DC05: The DC05 is the 7-segment LED display we are going to use. There are several models of display that vary in size and color. Choose the one that appeals most to your taste.
The system uses four 7-segment LED displays (DC05), each of which can display a number between 0 and 9. Using four displays, we can achieve a range from 0 to 9999, which is a high enough balance for a typical piggy bank. Figure 1 shows the Pinout of the DC05.
Every DC05 requires a driver to store and display the value. The CD4026 and CD4033 are excellent options to choose from, and with a range from 5 to 20 volts of operation, we can use them even for big billboards. Both drivers will move through the sequence from 0 to 9 with each pulse sent to CLOCK (Pin 1 in Figure 2).
In this project we will use the CD4026, because of the possibilities it offers for saving power. Figure 2 shows the Pinout of the CD4026.
Every time the CD4026 receives a pulse on its âCLOCKâ input, it increments its internal counter. When the counter value is 9 and the CD4026 is clocked an additional time, it outputs a pulse on âCARRY OUTâ and rolls over to 0. This way you can implement a counter from 0-9999 by connecting the âCARRY OUTâ signals to the next CD4026 in the array. Our job is to translate the coin values into pulses for the first CD4026, and it will do the rest. Figure 3 shows the basic concept with two sets of CD4026 and DC05.
The GreenPAK is responsible for recognizing the kind of coin and assigning the correct number of pulses to each one. For this project, we will use coins valued at 1, 2, 5 and 10 MXN. However, all techniques discussed here can be applied to any currency that uses coins. Now, we have to devise a way to distinguish between different coins. There are several methods to do this, including utilizing the metal composition of the coin and the diameter of the coin. This project will use the latter method.
Table 1 shows all the diameters of the MXN coins used in this project, as well as the diameter of US coins for comparison.
There are several ways to determine the diameter of a coin. For example, we could use a plate with coin-sized holes like in Figure 4. Using an optic sensor, we could signal every time a coin passes through a hole, and send the corresponding value in pulses. This solution is bigger and bulkier than the one weâll use for this project, but it may be easier to build for a hobbyist.
Our solution will use a mechanism taken out of a broken toy, shown in Figure 5. It would be a relatively simple task to build a replica using wood.
Coins can be inserted in the slot at the left edge of the mechanism in Figure 5. This slot will be forced down by a certain distance based on the diameter of the coin. The metallic piece circled in yellow will be used to signal the size of the coin, and the spring will push the slot back into the starting position. This sensor will activate multiple readings each time a coin is inserted; for example, when a 10 MXN coin is inserted, the sensor will briefly touch the values of 1, 2, and 5. We must take this into account in the next part of the design.
GreenPAK Design Implementation
The system works in the following way:
1. The sensor is in the starting position.
2. A coin is inserted
3. The sensor moves from the smallest diameter to the correct one, based on the diameter of the coin.
4. The spring returns the senor to the initial position.
For example, A 10 MXN coin will displace the sensor from the starting position into the 1 MXN position, then the 2 MXN position, then the 5 MXN position, until finally arriving at the 10 MXN position before returning to the initial position.
To handle this problem, weâll implement a one way ASM inside the GreenPAK, shown in Figure 6.
Once the sensor is in the starting position, the state of the ASM determines how many pulses the system is going to send.
For the system to send the pulses, three conditions must be met:
1. The system must be in a valid state (1 MXN, 2 MXN, 5 MXN, or 10 MXN).
2. The sensor must be in the starting position.
3. There must be a pulse to be sent.
Counting the pulses is a difficult task, because the counter will output a HIGH when the value is reached, and it will also send a HIGH when the counter is reset. If the counter is not reset, then the output will remain HIGH.
The solution is rather simple, but difficult to find: count to the coin value plus one, and reset the main oscillator with the rising edge of the sensor returning to the starting position. This will create a first pulse that will make the counter of the current state count up to the coin value. Then, add an OR gate to the output into the CLK input (along with the signal from the oscillator) to achieve a reset of the system.
Figure 7 depicts this technique.
After counting to the coin value, the system sends a reset signal back to the ASM to return to INIT. A close look at the ASM is provided in Figure 8.
RESET_10_MXN uses a slightly different system than described above, using an extra state to restart the whole ASM, as there is a limited amount of connections each state can have. The RESET_10_MXN was achieved by going to the RESET state, which was the only state where the ASMâs OUT5 was LOW. This successfully returns to the INIT state without any problems.
CNT2, CNT3, CNT 4, and CNT5 share the same parameters, except the value of the counter shown in Figure 9.
As the CD4026 uses the rising edge of the signal to advance its sequence, this system counts the rising edges values. A low frequency was selected for debugging purposes. Using higher frequencies would be useful and can be done without major problems.
In order to implement this project in any other currency, simply adjust the counter to the value of the coin plus one.
Using other sensors would make this system far simpler, but production costs would be higher than solving these issues through programming.
The complete project setup is shown in Figure 10.
Diameters were adjusted to work with different coins, and the denomination can be changed by altering the using the .gp5 file.
Thanks to GreenPAK product line, it is easy and affordable to develop a system like this piggy bank. The project could be further enhanced by using a PWM signal to drive the CD4026 Display Enable IN. You could also use the GreenPAK to generate a wake/sleep function to lower the systemâs power consumption. This simple system could be used to control a variety of coinaccepting systems, like vending machines, arcade machines, or coin lockers.