The Design of Paper Counting Device Based On STM32

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

The Design of Paper Counting Device Based on STM32

Wanping Li*, Jundong Xie


Wuhan Technology And Business University, Wuhan, Hubei, 430066.
*[email protected]; phone 17740677140

ABSTRACT

This paper introduces a paper counting device. The system consists of STM32 core board, FDC2214 module, OLED
display module, buzzer module, key module, and two parallel plates. Two copper clad plates with a side length of 50mm
square are used as capacitance plates, and the paper to be measured is placed in the middle, and the capacitance value
between the two plates is collected by FDC2214 and the collected data is transmitted to the MCU controller through the
IIC serial bus. The controller through the algorithm converted to the corresponding number of paper values displayed in
the OLED display. The system sets self-calibration mode according to adjust the size of capacitance.
Keywords: STM32F103RCT6, FDC2214, capacitor plate, OLED display

1. THE SELECTION OF SYSTEM DESIGN


1.1 The argument and selection of the microcontroller
Scheme 1: The system adopts MSP430 single-chip microcomputer. The MSP430 series is a 16-bit ultra-low-power
hybrid signal processor with a simple instruction set. But the development is complex, and the download is too slow,
which is not conducive to the program debugging[1].
Scheme 2: The system uses the STM32F103 processor. STM32 series runs fast, clock frequency up to 72MHz, 11 timers
and rich IO ports, and built-in three 12-bit A / D converters, two 12-bit D / A converters, its advanced timer can produce
PWM waves with dead zone complementary, cost-effective[2].
Since the STM32F103 processor runs faster, costs less, and its resources meet a the design requirements, scheme 2 is
selected for this design.
1.2 The Selection of Sensor module
Scheme 1:The sensor module adopts ultrasonic sensor. Ultrasonic sensor common reflection type and radiation type,
ultrasonic radiation type sensor is often used for paper thickness detection, generally includes an ultrasonic emission
probe, an ultrasonic reception probe, the size of the paper thickness affects the strength of the ultrasonic wave to receive
the probe, in the circuit design need to add ultrasonic generation circuit and the received ultrasonic signal processing
circuit, increase the cost of the design hardware circuit.
Scheme 2: The sensor module adopts FDC2214 capacitive sensor. The FDC2214 is a capacitive noise-resistant and EMI,
high-resolution, high-speed, multi-channel capacitance digital converter series[3]. With a resolution of up to 28 bits, the
FDC2214 has a sampling rate of up to 13.3ksps, enabling applications using fast-moving targets. And using a small
shape size without lead (WQFN16) packaging, the IIC external interface simplifies the connection with the
microcontroller, each piece contains 4-channel capacitance detection, and the measurement accuracy is high.
In terms of the conversion accuracy and the frequency response, the system uses the FDC2214 module to realize the
paper number measurement.

2. THEORETICAL ANALYSIS AND CALCULATION


The detection module is the sensor of capacitive sensor technology. The two plates of the parallel plate capacitor is the
capacitance at vacuum. The power of a plate is known by the definition of the capacitor C=Q / U.

5th International Conference on Computer Information Science and Application Technology


(CISAT 2022), edited by Fuming Zhao, Proc. of SPIE Vol. 12451, 1245111
© 2022 SPIE · 0277-786X · doi: 10.1117/12.2656762

Proc. of SPIE Vol. 12451 1245111-1


Q=C*U (1)
Voltage of the plate:
U = Ed = 4πkdQ / S (2)

Then:

S
C=
4πkd (3)
The capacitor between the same medium, the dielectric in the electric field E0, will produce the polarized charge, the
electric field formed with the original field opposite direction, makes the actual field strength E relatively small, we
define the ratio of the actual field strength E into the dielectric as the relative dielectric constant of the dielectric.
E0
ε=
E (4)
The voltage between the two plates when the plates are filled with the same medium.
E0 4πkσd Q
U = Ed = d= = 4πk d
ε ε εS (5)
Then:
εS
C= .
4πkd (6)

3. THE ENSEMBLE DESIGN OF THE SYSTEM


3.1 Overview of system function
Paper count display device system through the copper plate as the induction area induction different thickness of
different capacitor changes, and then use the FDC2214 chip to the induced capacitance changes into digital signal, input
to the STM32F103 development board, and then the STM32F103 chip through the internal program processing into
paper quantity output signal displayed in OLED display, so as to realize the accurate judgment of different paper, and
realize the calibration function through the external keys.
3.2 System overall block diagram design
The system adopts STM32F103 as the control core, FDC2214 detects the paper thickness, communicates data with the
SCM through the IIC serial port, and displays the paper and thickness through the OLED display. The system design
button module realizes the interaction, start measurement, self-calibration mode selection, and designs the buzzer alarm
circuit for sound prompt.The system is composed of STM32F103 microcontroller module, FDC2214 module, paper
detection capacitance board module and buzzer module. The overall block diagram is shown in Figure 1.

Figure 1.Overall block diagram

Proc. of SPIE Vol. 12451 1245111-2


4. SYSTEM HARDWARE CIRCUIT DESIGN
4.1 Single-chip microcomputer minimum system
STM32F103 is an enhanced microprocessor with Cortex-M3 kernel and a working frequency of up to 72MHZ. Its
operating voltage is 2.0-3.6v, with a storage capacity of 16KB ~ 1MB Flash, and rich serial port resources such as SPI,
IIC and USB. It has two built-in 12-bit A / D converts, convertible analog voltage range of 0-3.6v, and has a rich I / O
port.Its minimum system includes crystal vibration, reset, power supply, BOOT mode selection, etc.
4.2 System power circuit
The system adopts ME6212 series linear voltage regulator for power supply design. ME6212 series has the
characteristics of high ripple suppression ratio, low noise, corresponding fast and low pressure difference. The lowest
input voltage is 2.0v and the highest is 6.0v. The series is compatible with smaller ceramic capacitances and no longer
requires 0.1UF bypass points, and the CE pins of the chip enable output off function, once off to below 1uA.
4.3 FDC2214 module
The system uses capacitive sensor FDC2214 for paper thickness measurement, the device belongs to capacitive
noise-resistant and EMI, high resolution, high speed, multi-channel capacitance digital converter series[4]. The sensor
each piece contains 4 channels of capacitance detection, power supply voltage of 2.7-3.6v, resolution up to 28 bits, and
FDC2214 sampling rate up to 13.3ksps, and high measurement accuracy, easy to achieve the use of fast moving targets.
The design uses a small shape size without lead (WQFN16) packaging, and the IIC external interface simplifies the
connection mode with the microcontroller.
FDC capacitor digital converter, its basic principle is through the construction of LC resonance circuit, oscillation circuit
oscillation frequency and capacitor C has a function relationship.The sensor outputs a digital amount proportional to the
oscillation frequency that is converted to an equivalent capacitance.
4.4 Displays module
The system used organic light-emitting diode, also known as electromechanical laser display, OLED display compared
with LCD display, OLED in brightness, power consumption, reaction speed and refresh rate, are more advantages. In the
system, OLED display performs data display, and OLED display adopts serial communication mode IIC on the hardware
interface, and fixed the number of paper on the screen through the library function OLED_ShowString.
4.5 Key module
In order to enable the system to interact, the system designs a key input module. Due to the few input signals needed in
the system, independent keys are used in the design. In the design, the four corner switch independent button circuit is
adopted, and each four corner switch button has a single I / O line, and the working state of each IO port does not affect
each other. Such keyboard scanning method adopts port direct scanning. The disadvantage is that when multiple buttons
are pressed at the same time, it will only have the corresponding priority IO, the advantage is that the circuit design is
simple, effectively improve the utilization of IO port in the microchip system, and the programming is extremely easy.
The system uses IO ports to realize self-calibration and entry test selection keys in the system.
4.6 The buzzer module
Because the output voltage of the IO port of the system is only 3.3v, it cannot directly drive the external buzzer. The
system adopts 9012 triode drive, triggered by high and low levels and an active buzzer. The advantage is that the
program control is convenient, and the STM32F103 IO port can output the buzzer with high and low levels.

5. CIRCUIT PROGRAM DESIGN


5.1 Programming ideas
(1) It is important to check whether the core module is intact, the STM32F103 is connected to the OLED display through
the IIC communication link, and the software PCtoLCE2002 implements the word library, and then the OLED can
display specific images in a designated place by making the code.
(2) The soft functions should accord to the requirements of the topic, such as the "measurement of paper number" to

Proc. of SPIE Vol. 12451 1245111-3


achieve and "self-calibration function of paper", etc., this function can be scanned through the button, such as a button
press, will trigger the corresponding program, so as to achieve the effect of switching between various functions.
(3)The unified function design adopts the idea of modular design. In this design, The author used the I / O port in
STM32F103 to control the button and buzzer module, and also realized the IIC protocol communication with OLED and
FDC2214 through the specific pin multiplexing function, and we also want to define the corresponding function module,
initialize the corresponding pin and apply the special function of the module to complete the required operation[5]. For
example, STM32F103 is connected to the SCK and SDA pins of OLED display through PB8 and PB9. In order to
complete IIC communication, the corresponding pin should be initialized, the communication between the two parties
should be realized through specific time series, and the corresponding image is the OLED function module.
(4) The median filter function of the system design improves the sampling accuracy. To realize the accurate measurement
of A4 paper number, through the timer interrupt service function sampling a large number of data, according to the
method of median out a relatively stable number, this method for the number of paper to measure the corresponding
value[6], through the above process measured more sets of data, for each data of the same number of paper capacitor
average and then write into the main function. In order to determine the specific number of paper[7], the median filtering
algorithm is used to average a value and its two adjacent data as the measurement capacitance value interval of the
number of paper[8]. If a capacitance value is measured in this interval, the number of paper is this value.For the number
of paper with a small relative interval of capacitance value, the collected data is interpreted with the corresponding
function by matlab application, and the number of paper is predicted.
5.2 Main program flow chart design
This design uses a 32-bit MCU STM32F103 as the master control for system control and display and key adjustment.
The STM32F103 has main frequencies of up to 72MHz, multiple PWM channels and ADC channels. The flow chart of
the software is shown in Figure 2 below.

Figure 2.Program Flow Diagram


The main function first initializes the required function module to realize the initialization of the peripherals. Then scan
the button to determine the program direction, perform self-calibration and measurement respectively, enter the
corresponding program function, and finally be presented on the OLED display.
5.3 Self-calibrated subprogram
Because each measurement repeatedly on paper operation, after measuring paper is not very good fit or not good
alignment, and found that test paper may exist pulp materials, rough procedures and chemical differences[9], which will
lead to the dielectric constant of capacitance is different, eventually affect the accuracy of the measurement[10]. The
self-calibration function is set in the system to use 2,4 and 8 sheets of paper before testing different types of paper, and
calibration parameter A is introduced in the calculation formula of parallel plate capacitor to eliminate errors in the
detection of different types of paper.

Proc. of SPIE Vol. 12451 1245111-4


6. SYSTEM TEST
6.1 Test instruments and test methods
(1)Test preparation. It is necessary to prepare the multimeter, electric flipping iron, oscilloscope and other equipment
required for the test. The next thing is checking the hardware circuit of the system to ensure the correct connection of the
power supply.
(2)Test of the same type of paper.The first thing is connectting the hardware according to the system design.It is need
to put the paper between the two copper plates and press it,then, observe the range and error of the data.and then
constantly change the number and position of the paper, and measure the data several times to take the average.
(3) Self-calibration function test.The author should test A4 paper of different specifications, and record the test results,
compare with the results of (2) test results, adjust and record the position when the paper is putting into the two copper
plate modules according to the test results, and improve the position of the paper feeding device to fix the paper.
6.2 Test process and result analysis
In the test, the conventional 70g specification A5 paper was used. The number of paper intake gradually increased from 1
to 10. Four sets of data were measured for each paper intake. The obtained measurement data are shown in Table 1.
Table 1 tests the different paper data sheets(unit:Hz)

Error analysis: (1) some electromagnetic waves in the test environment, which will cause small interference to the
capacitance value collected by the sensor; (2) the thickness varies with the temperature and humidity of the air; (3) the
inconsistent compression during the feeding results in errors in the measured data.
When different amounts of paper are placed, The capacitance value changes, and the LC oscillation circuit will get the
oscillation signal of different frequencies. The MUC detects the frequency of the oscillation signal, thus realizing the
detection of the number of paper. Each different number of paper sensors will pass back a different value, the program
will give the determined number of paper through the range of each value, according to the data analysis measured above,
the system can basically measure the paper within the range of 0-22, and it is accurate and reliable.

7. CONCLUSIONS
The system has the characteristics of simple circuit and stable performance. Compared with the traditional paper counter,
it has the advantages of high accuracy, good stability and low price. In the future, the system also needs to further
improve the structure of the device, to reduce the error caused by the operation, and to optimize the program design to
correct the error caused by the environmental temperature and humidity, so as to be better applied to the paper, printing
and other control systems.

Proc. of SPIE Vol. 12451 1245111-5


ACKNOWLEDGEMENTS

(The paper supported by the Special Fund of Advantageous and Characteristic disciplines (Group) of Hubei Province.
The paper supported by the Scientific Research Plan Project of Hubei Provincial Department of Education in
2021.B2021312)

REFERENCES

[1] Yuping Jiang, Wenzao Shi, Yuan Situ, Ge Gao. Design of Scintillation Counter Circuit Based on STM32
Counting[J]. 2021 2nd International Conference on Electronics, Communications and Information Technology
(CECIT 2021).
[2] Binfang Cao, Jianqi Li, Chengfa Liu, Lingjie Qin. Defect detection of nickel plated punched steel strip based on
improved least square method [J]. Optik-International Journal for Light and Electron Optics, 2020.
[3] Jian Huang. Salt Water Concentration Measuring Instrument Based On fdc2214[J]. Journal of Physics:
Conference SeriesVolume 1533, Issue 2. 2020.
[4] Huang D, Wang S. Gesture recognition system based on FDC2214[J]. Wireless Internet Technology, 2019.
[5] Gao L,Jiang F, Wang S.Paper counting display device based on STM32F103 single chip computer[C]// IOP
Conference Series: Materials Science and Engineering. IOP Publishing, 2020.
[6] Chen J, Lu Q , Liang Q. Design and Implementation of Paper Counting Algorithm Based on Gabor Filter[C]// the
International Symposium. 2018.
[7] Chen Jiqiu, Lu Qirong, Liang Qianming. Design and Implementation of Paper Counting Algorithm Based on
Gabor Filter[J]. Big Data and Artificial Intelligence2018. PP 281-285.
[8] Qu Jingkun, Xu Jinxiang. Image Salt and Pepper Noise Adaptive Based on Fuzzy Median Filtering. Proceedings
of Spie--The International Society For Optical Engineering, Volume 11519, 2020.
[9] A. Rückerl, S.Huppmann, R.Zeisel et al. Monolithic integrable capacitive humidity sensing method for material
characterization of dielectric thin films[J]. Microelectronics Reliability, 2014, 54(9-10).
[10] Li H. Design of Paper Counting Display Device Based on STC89C52 Single Chip Microcomputer[J]. China
Computer & Communication, 2019.

Proc. of SPIE Vol. 12451 1245111-6

You might also like