FPGA BASED COIN RECOGNITION SYSTEM
A TECHNICAL REPORT
                     Submitted by
                    PORKODI M
             EC8611-TECHNICAL SEMINAR
                      (Reg 2017)
             BACHELOR OF ENGINEERING
                          in
    ELECTRONICS AND COMMUNICATION ENGINEERING
    KNOWLEDGE INSTITUTE OF TECHNOLOGY,SALEM
          ANNA UNIVERSITY::CHENNAI 600 025
                     MAY 2020
                          i
             ANNA UNIVERSITY :: CHENNAI 600 025
                         BONAFIDE CERTIFICATE
Certified that this project report “FPGA BASED COIN RECOGNITION SYSTEM”
is the bonafide work of “ PORKODI M” who has carried out the technical seminar
under supervision of Mr.K.Rajesh, Assistant professor, Department of Electronics and
Communication Engineering.
                                       Dr.N.SANTHIYAKUMARI,
                                        HEAD OF THE DEPARTMET,
                                        DEPARTMENT OF ECE,
                                        KNOWLEDGE INSTITUTE OF TECHNOLOGY,
                                        KAKAPALAYAM,SALEM-637 504.
                                         ii
              TABLE OF CONTENTS
CHAPTER NO.           TITLE            PAGE NO.
     1.        ABSTRACT                  1
     2.        INTRODUCTION              1
     3.        RELATED WORK              2
     4.        METHODOLOGY               3
     5.        FPGA                      6
     6.        OV7670                    7
     7.        RESULT AND DISCUSSION     7
     8.        CONCLUSION                10
     9.        REFERENCES                11
                        iii
1. ABSTRACT
       Coins are most widely used in regular day to day existence at different places
like in banks, markets, general stores, weight machines, vending machines, and hundis
in temples. People used to count the coins manually before the arrival of coin
recognizing and counting systems. It takes a lot of time and may lead to errors. So, it is
necessary to develop automatic coin recognition and counting systems. These systems
are already available in other countries. Unlike other countries, it is difficult to detect
coins in India due to variability in the coin features for same denomination. In this
paper, an FPGA (Field Programmable Gate Array) based coin processing is done along
with recognition and counting. OV7670 camera is interfaced with Basys 3 FPGA. A
HDL code is developed for interfacing camera. The advantage of FPGA is that it
provides high processing performance, flexibility and low development cost. Due to
reconfigurable feature of FPGA, high resolution cameras like 2MP, 5MP can be
interfaced to detect the objects with high resolution.
Index Terms: Coin, FPGA, Image processing, Verilog HDL.
2. INTRODUCTION
       Different denominations of Indian coins currently existing are ₹ 1, ₹ 2, ₹ 5, and ₹
10. Humans have the capability to detect and identify different coins irrespective of their
shape, orientation and size. But humans cannot count huge amount of coins manually
which takes a lot of time and also many errors. So, there is a need to design a system
which will automate this process. There are different systems available for the
recognition of coins like Mechanical Systems, Electromagnetic Systems and Image
processing Systems. In mechanical systems, recognition of coins is done on the basis of
physical parameters like radius, weight, thickness, etc. But this type of systems cannot
differentiate between original and fake coins as only physical properties are considered.
Also it cannot detect different materials of coins. So, this system is efficient.
                                              1
       In electromagnetic systems, coins are differentiated based on the different
materials used. Here the coins are allowed to pass through an oscillating coil at certain
frequency range so that different materials provide different changes in their amplitudes
and frequencies. Along with these changes, parameters like radius, weight, thickness,
etc are also used to differentiate the coins. So, this method is better than mechanical
system.
      In image processing systems, the image of the coin is taken and different
algorithms are applied on it to detect the unique features of the coins that are required
for the recognition. Image processing is the best method to recognize coins. There are
also methods to recognize coin based on the character on it.Generally MATLAB is the
tool used for the image processing. But MATLAB needs a dedicated computer for the
simulation. This problem can be solved by using the hardware design which is portable.
Hardware design can be implemented using various technologies like Application
Specific Integrated Circuits (ASIC), Digital Signal Processor (DSP), Application
Specific Standard Products (ASSP) and Field Programmable Gate Arrays (FPGA). Out
of these technologies, FPGAs is the best solution as they offer better performance, less
time consuming, reconfigurable, flexibility and low development costs.
3. RELATED WORK
    Suchika malik, Parveen Bajaj, Mukhwinder Kaur proposed a method which uses
unequally spaced Fourier Transform algorithm to detect the presence of coin and neural
network, rotation invariance is used for the recognition of coins. The performance of the
method is measured based on the parameters like signal to noise ratio, mean square
error. There is a need to improve the accuracy and speed of the system.
    Keyur D. Joshi, Vedang D. Chauhan, and Brian W. Surgenor proposed a method to
classify and count the currency coins with high speed and accuracy using Machine
Level Inspection (MVI). A camera based system is used for the on-line classification of
                                           2
moving coins. As the coins are moving on the conveyor, speed of the target i.e. number
of coins per min is calculated. Next the presence of coin is detected and recognized.
Current system counts only 30 coins per min with the efficiency of 89%. It can be
further improved to count 1000 coins per min with the efficiency of 99.9%. Rathod
Prahaladsinh Kanubha, Y.J.Parmar proposed an easy method to recognize the coin and
separate based on the features of the image. In this paper, the RGB image is converted
to black & white image and area of each region is identified and recognized.
Recognition time is very low but it recognizes particular coins only and fake coins are
also detected which gives wrong result. Accuracy can be further improved to detect
more number of coins.
    Vanderlei Bonato, Eduardo Marques, and George A. Constantinides proposed
parallel hardware architecture for the detection of features in an image using the scale
invariant feature algorithm. It takes the input from the CMOS image sensor and output
is obtained from the FPGA.
     Alareqi Mohammed, Elgouri Rachid, Hlou Laamari and Neha.P.Raut1,
Prof.A.V.Gokhale2 presented the concept of using Xilinx System Generator for
hardware software co-simulation in the image processing applications.
4. METHODOLOGY
     In this paper, recognition of coins is done for two types of input images. In the first
type, image coefficients are stored in the block memory of FPGA using MATLAB and
other is image captured from camera.
     The pre defined image of the coin is directly given as input in general image
recognition. The simulations are done in MATLAB, Xilinx Vivado and also on FPGA
using ChipScope Pro logic analyzer.
     Two approaches are used for the recognition of coins in MATLAB. One method is
area based and the other method is correlation.
                                            3
4.1. Area based Recognition
   Most of the coins have different physical parameters like radius, area, shape, etc. By
taking this advantage, area of the coins in the image is calculated and recognized.
Steps followed in matlab are
    Read an RGB coin image.
   Convert that coin image to gray image.
   Convert gray scale image to binary image by setting a threshold value.
   Use image filling to reduce the noise so that we get circular regions in the places of
coin.
  Find area, centroid of each circular region in the binary image.
  Based on the area of coins, recognize them.
4.2. Unique feature based recognition
   Each coin consists of a unique feature, those features are identified and stored as the
data set. When a coin is given as input, it is compared with the images in the data set
using correlation.
Steps followed are
    Read the RGB coin image.
    Convert that coin image to gray image.
    Read images from the data set one by one and compared it with the input image
using correlation.
                                            4
            Images
                                   MATLAB                Hex files
          Compare with                                 Load the values
          the values in the       Get the input        in FPGA block
          Block memory            image                RAM
            Identify the           Display on 7
             value                 segment LED
                                   on FPGA
                   Fig. 1 Block Diagram for FPGA Implementation
     The block diagram for this type of recognition is shown in the fig. 1. MATLAB
tool is     used to convert the coin images into their coefficients. These coefficients
generated are loaded in the block memory of FPGA. When the input image is given, the
coefficients of the input image are compared with the coefficients of the images in the
block memory and if the value matches then the corresponding coin value is displayed
on 7-segment LED on FPGA.
      In the previous methods, the image is converted to hex file using MATLAB and
those files are given as input to the Xilinx. In this method, the image is captured from
OV7670 camera as shown in fig. 2. The data from the camera to FPGA is observed
using ChipScope pro logic analyzer. The unique hex data values obtained for the each
coin are stored in the block memory of FPGA. When the coin is placed in front of
camera and, real-time hex values are obtained. If those values matches with the stored
data in block memory of FPGA then based on the resulting currency value, LEDs are
made to glow on FPGA.
                                                  5
      OV7670
                                                                    Xilinx vivado
    OV7670_controlle
                                                                      Synthesis
    r
                                         FPGA
    OV7670_capture
                                                                     Simulation
     Frame_buffer
                                                                    Implementation
                                      VGA Monitor
                                      VGA Controller
          Coin
                                        HSYNC
                                        VSYNC
                 Fig. 2 Block Diagram of Camera based Recognition
5. FPGA
    It consists of configurable logic blocks and programmable interconnects so that it
can be used for different applications based on the given specification. There are
different types of FPGA development boards available like Basys, Nexys, Zedboard,
etc. In this paper Basys3 board is used. Basys3 is a ready-to-use development platform
which is based on the Artix-7 FPGA from Xilinx. Basys3 FPGA utilizes Xilinx Vivado
FPGA Design Tools which is not possible with Basys2. In Basys3 board, there are about
33,280 Logic Cells in 5200 slices, Block RAM is of 1,800 Kbits, DSP Slices of 90 and
internal clock is 450 MHz+.
                                            6
                           Table I Features of Basys3
                Pmod connectors                      3
                Switches                             16
                Buttons                              5
                User LED                             16
                7-seg display                       4-digit
                VGA                                 12 bit
                USB                              HID(KB/Mouse/Mass
                                                 Storage) Electrical Power
                Logic level                        3.3v
                Physical                         Width 2.8 in Length 4.8 in
6. OV7670
      It is a small size, single chip and low voltage CMOS based image sensor which
can be used in FPGA, Arduino, ARM, DSP, etc. This module requires 3.3V power and
external clock source to power up. It uses SCCB (Serial Camera Control Bus) for the
processing. The resolution of camera module is 640×480 VGA, pixel size is 3.6μm x
3.6μm and the output format is 8 bit i.e. 4:2:2 RGB data.
7. RESULTS&DISCUSSIONS
     Fig. 3 to fig. 7 represents the recognition of coin in MATLAB. Variation in area for
different coins is taken as a parameter to recognize coins in fig. 3 and in fig. 4 to fig. 7,
coins are differentiated on the basis of unique feature present in each coin.
                                             7
Fig. 3 Area Based Recognition            Fig. 4 One Rupee Coin Recognition
 Fig. 5 Two Rupee Coin Recognition        Fig. 6 Five Rupee Coin Recognition
                                     8
                           Fig. 7 Ten Rupee Coin Recognition
    The image is obtained here by interfacing Basys 3 board to the camera OV7670.
Fig. 8 shows the interfacing of Basys 3 board to the OV7670 camera. When the coin is
place in front of camera, image will be displayed on the monitor is shown in figures 9
to 11.
  Fig. 8 Interfacing OV7670 with Basys3               Fig. 9 Two Rupee Coin Processed by Basys3
                                                9
Fig. 10 Five Rupee Coin Processed by Basys3        Fig. 11 Ten rupee Coin Processed by Basys3
8. CONCLUSION
         The hardware based coin recognition system is proposed and implemented on
FPGA using Verilog HDL. Software simulations are done in MATLAB tool. In real
time, coin is recognized by interfacing OV7670 camera with Basys3 FPGA board and
real-time hex values of the coin which is captured from camera are obtained using Chip
Scope Pro logic analyzer. When the coin is placed in front of camera and if the resulted
pixel values matches with the stored data in block memory of FPGA then outputs are
displayed on LEDs. The disadvantage with the static mode is that the block memory of
the Basys3 board is low, only some images can be stored and identified. When camera
is interfaced, variations in light intensity, position, distance of the camera may lead to
errors. Further research can be done to improve the speed and accuracy of the system by
interfacing high resolution cameras, using high end FPGAs and also using deep
learning.
                                              10
9. REFERENCES
1.   U. Tajane, M. Patil, S. Shahane, A. Dhulekar, Dr. S. T. Gandhe, Dr. G. M. Phade,
“Deep Learning Based Indian Currency Coin Recognition”, 2018 International
Conference On Advances in Communication and Computing Technology (ICACCT).
2.   Xingyu Pan, Laure Tougne, “Topology-Based Character Recognition Method for
Coin Date Detection”, International Journal of Computer and Information Engineering,
Vol. 10, No. 10.
3. Suchika malik, Parveen Bajaj, Mukhwinder Kaur, “ Coin Recognition System using
Artificial Neural Network on Static Image Dataset”,         International Journal of
Engineering Science and Computing, April 2017, Vol. 7, Issue No.4.
4.    Keyur D. Joshi, Vedang D. Chauhan, and Brian W. Surgenor, “Real Time
Recognition and Counting of Indian Currency Coins using Machine Vision: A
preliminary Analysis”, Proceedings of The Canadian Society for Mechanical
Engineering International Congress 2016.
5.   Rathod Prahaladsinh Kanubha, Y.J.Parmar, ”Develop an Efficient Algorithm to
Recognize, Separate and Count Indian Coin From Image using MATLAB”,
International Journal of Innovative Research in Computer and Communication
Engineering, Vol. 3, Issue 4, April 2015.
6.     Dhanabal.R, Sarat kumar Sahoo, Bharathi V, “FPGA BASED IMAGE
PROCESSING UNIT USAGE IN COIN DETECTION AND COUNTING”, 2015
International Conference on Circuit, Power and Computing Technologies [ICCPCT].
                                            11