care
Jotrin Electronics
Cart
arrow
Description Quantity Total (USD) Operation
loading
Shopping cart products
Shopping cart products : 0
Home > Programmable logic > Design of Intelligent Bus Coin Box Based on DS1991 and Single Chip Com

Design of Intelligent Bus Coin Box Based on DS1991 and Single Chip Computer

Published time: 2020-05-11 10:45:05

1 Introduction

In China, since the coin system was implemented in the public transport system to replace the conductor, the operation efficiency of the public transport company has been greatly improved. However, the theft of the money in the coin box by the driver and the use of fake coins by passengers to take the bus sometimes happened, which caused the company to suffer huge economic losses.

In addition to personal quality factors, the main reason is the poor safety performance and single function of the coin box. In response to this problem, an intelligent bus coin box is designed here: the system uses the AT89S52 microcontroller as the control core, and uses the Dallas information button DS1991 to form a code lock control circuit, and uses the DS1991 key to open the code lock of the coin box. Each partition has a 64-bit password and identification area, and the security performance is very high, which can avoid the occurrence of ticket theft due to poor security performance of the password lock. The data transmission between the information button DS1991 and the single-chip microcomputer adopts a single bus protocol. The data transmission only needs to briefly touch the data line of the DS1991 and the I / O port of the single-chip microcomputer. According to the different alloy materials used for real and fake coins, the system uses eddy current sensors to detect the true and false coins, which can effectively prevent passengers from using fake coins to take buses.

2. Composition principle

The working principle of the system: If the legally authorized DS1991 is used for short-term contact with the I / O port of the microcontroller, the microcontroller writes the memory data and clock data into the DS1991 key sub-storage area, and then the microcontroller unlocks the electronic code lock of the coin box. If unauthorized DS1991 or other single-bus devices are used, the single chip microcomputer refuses to open the electronic code lock of the coin box. When the system detects that there is a fake coin input, the fake coin rejection circuit is activated to make the fake coin flow out of the coin slot from the fake coin channel, and at the same time the buzzer sounds.

2.1 DS1991 interface circuit

This system uses the information button DS1991. Each DS1991 factory has a 64-bit registration code engraved in it. No two devices have the same registration code. The first 8 bits are the family code for 1-Wire products, the next 48 bits are the unique serial number for each device, and the last 8 bits are the CRC check code for the first 56 bits. It has a safe and reliable 1152-bit password-protected memory and 512-bit non-password-protected memory. The 1152-bit password-protected memory is divided into 3 partitions, each partition contains 384 bits, and each key sub-area has a 64-bit password and identification area. Password verification is required for read / write operations of the key sub-storage area. The 512-bit non-password protected memory is mainly used for copying encrypted data to ensure data integrity.

DS1991 is packaged in a stainless steel case with a diameter of 16 mm and a thickness of about 6 mm. It has a two-way communication function. Data transmission uses a single bus protocol. According to the single bus protocol, only one data line and ground line can be used to exchange information with the outside world. DS1991 is an open-drain single-bus device. The connection I / O of DS1991 must be bidirectional, and a 4.7 kΩ pull-up resistor must be connected to the I / O port. The transmission rate between the MCU and the DS1991 can reach 16.3 kb / s, so the information button between the DS1991 and the MCU only needs to briefly contact the DS1991 data line with the I / O port of the MCU (a light touch) carry out.

The information button DS1991 serves as a bridge for data transfer between the coin box system and the bus company's back office management system. The information button DS1991 exchanges information with the single-chip microcomputer. It must be initialized and ROM operated before reading and writing operations of the memory.

All transmission operations on the single bus start from the initialization process. The initialization process consists of the reset pulse sent by the single-chip microcomputer and the response pulse received by the single-chip microcomputer. If DS1991 is on the I / O line, the data line is pulled low during TPDL to generate a negative response pulse.

ROM function command: If the MCU detects a negative response pulse, it can issue 4 ROM function commands supported by DS1991. The system I / O line has only one information button. After initialization, it can skip the matching of 64-bit ROM series codes and directly perform memory read and write operations.

Memory read and write operations: Here we only analyze the operation of writing data into the key sub-storage area. First, the single-chip microcomputer sends a key sub-storage area command, sends the key sub-storage area number and data target address, and then receives the key sub-storage area identification code to verify the 64-bit identification code. If the 64-bit identification code is an unauthorized identification code, the system stores the identification code of the information button and the time of access to the system, and then the single-bus device is reset; if the 64-bit identification code is an identification code legally authorized by the bus company, the microcontroller The 64-bit password of the E2PROM memory is sent to the key sub-storage area of DS1991. If the 64-bit password sent by the microcontroller is different from the 64-bit password of the DS1991 key sub-storage area, the DS1991 key sub-storage area refuses to write data, and the single-chip P1.3 port refuses to output the unlocking voltage, so the coin box cannot be opened. Electronic password lock; if the 64-bit password sent by the MCU is the same as the 64-bit password of the DS1991 key sub-storage area, the MCU writes the memory data and clock data into the DS1991 key sub-storage area, and the single-chip P1.3 port outputs the unlock voltage To open the electronic code lock of the coin box.

Memory

It can be seen from the analysis: only use DS1991 with legal authorization (DS1991's identification code is legal, the 64-bit password in the DS1991 key sub-storage area and the password in the coin box E2PROM memory) to contact the I / O port can open the coin box The electronic combination lock; DS1991 not only has the function of opening the electronic combination lock, but also has the data collection function. DS991 collects all the bus data including the legal opening record and illegal trial opening record of the coin box. The company's background management system reads the data obtained by DS1991, and combines the bus information with the statistical analysis of the bus coin box opening situation, and can be used as an important basis for bus management.

The distribution of information buttons DS1991 generally adopts multi-level distribution, and each level of information buttons DS1991 has different unlocking authority. The highest level is the head office level, which can open all the bus coin locks of the company. The highest level DS1991 has the highest authority and should be kept and used very safely. The lower level is the vehicle level, and only one bus coin lock door can be opened. The middle-level information button flexibly assigns the unlock permission of the information button DS1991 according to the management mode of the head office.

2.2 Coin processing circuit

The coin detection uses an eddy current sensor to obtain the detection signal. The working principle is: when a high-frequency sinusoidal signal is applied to the coil, the tested coin is placed in the magnetic field. When the changing magnetic field generated by the coil passes through the coin surface, eddy current will be generated on the coin surface . The eddy current will produce a reversely changing magnetic field, thereby weakening the magnetic field generated by the original coil, resulting in a change in the inductance of the coil. In this system, when the true and false coins pass through the coil L1, the alloy materials of the two coins are different, and the eddy currents generated on the coin surface are different, so that the inductance of the coil L1 changes differently. The coil is used as an inductance to connect to the capacitor three-point oscillation circuit. The frequency of the sinusoidal signal output by the oscillation circuit is not the same, so you only need to measure the output sinusoidal frequency of the capacitor three-point oscillation circuit to accurately identify the true and false coins. Before the system works, it is necessary to learn in advance: the oscillation frequency of all real coins in the oscillation circuit is stored in the E2PROM memory of the single-chip computer in advance. In the actual identification process, due to errors caused by various reasons, the frequency of the single-chip counting and the frequency of the kind of coins stored in the memory have a certain error. For this, you can set an allowable error range, so that the system can effectively identify the true and false coins.

When the passenger puts the coin, the coin passes through the photocoupler, the coin blocks the light beam, generates a falling edge through the conversion circuit, and sends it to the P3.2 port of the single-chip AT89S52, INTO generates an interrupt, and the system performs coin identification. The sine signal output from the capacitor three-point oscillation circuit is converted into a square wave signal by the Schmitt trigger circuit, and then sent to the T1 counter in the P3.4 port of the single-chip microcomputer for counting. If the frequency counted by the counter is within the allowable error range of a frequency stored in the memory, the coin detected is considered to be a real coin; if the frequency counted by the counter is not within the allowable error range of any frequency stored in the memory, it is considered The coins detected are fake coins. At this time, the single chip microcomputer starts the fake coin rejection circuit, P1.4 port outputs a high potential, the coin switching solenoid is energized, and the coin channel is switched, so that the fake coin flows out of the coin box from the fake coin channel, and at the same time, the P1.5 port outputs a high potential and a buzzer Speak. In order to prevent coins from blocking the coin channel, this system is equipped with a circuit board. When the coin channel is blocked, the driver turns on the punching switch, the P1.6 port outputs a high potential, and the energized motor performs the punching operation on the coin channel, thereby making the coin channel smooth.

2.3 Real-time clock circuit

The real-time clock chip of this system adopts DS1302. DS1302 is a trickle charge clock chip launched by DAL-LAS, which contains a real-time clock / calendar and 31 B static RAM, and communicates with the single-chip microcomputer through a simple serial interface. The real-time clock / calendar circuit provides seconds, minutes, hours, days, months, and years of information. The number of days per month and days in leap years can be adjusted automatically. The communication between DS1302 and MCU adopts synchronous serial mode. Three I / Os are needed between DS1302 and MCU: connect the reset pin RES of DS1302, serial data I / O and serial clock SCLK respectively. DS1302 provides an accurate clock for the system. When there is an information button in contact with the I / O port, the system will automatically record the time of access to the system to provide a basis for future queries.

2.4 E2PROM memory

This system uses E2PROM memory AT24C32, which is a 32 kb serial CMOS E2PROM, which contains 4096 bytes internally and supports the I2C bus data transfer protocol. Two I / O ports are needed between AT24C32 and single chip: one is connected to serial clock SCL, the other is connected to serial data / address SDA. The E2PROM memory mainly stores the oscillation frequency of real coins of various denominations in the oscillation circuit and the password, identification code of the information button, and the time of access to the system.

3. Conclusion

This article has three advantages for designing a smart bus coin box:

(1) High safety performance. Only the legally authorized DS1991 can be used to open the electronic code lock of the coin box. Each partition has a 64-bit password and identification code, and the security performance is very high, which can avoid the occurrence of ticket theft due to the poor security performance of the coin lock of the coin box.

(2) Improve the operating efficiency of the bus company. The use of eddy current sensors to detect the authenticity of coins can effectively prevent passengers from using fake coins to take buses.

(3) Easy to use. DS191 is small in size and easy to carry. The information transmission between DS1991 and the single-chip microcomputer can be completed with a touch.

After the electronic code lock of the smart bus coin box is opened, and then the mechanical lock of the smart bus coin box is opened, the door lock of the coin box can be opened. In the bus system, the staff who unlocked twice are different, again ensuring the security of the ticket in the coin box. The technology of using electronic buttons to open electronic code locks is applied to bus coin lockers, which largely solves the problem of stolen tickets for bus companies for a long time.

Tag: DS1991
 

Cart

Account Center

jotrin03

Live Chat

sales@jotrin.com