Application of low-cost serial port expansion scheme in bank counter password keyboard equipment

Pick    Important : This article introduces the application of GM8123 to realize the expansion of multiple serial ports in the bank counter password keyboard device.

introduction

Development UART serial counter in the bank teller a PINpad device, and communication interfaces to standard keyboard and PC encryption chip module of three parts, will need to have three MCU standard UART serial port module and said three connection. Moreover, the UART baud rate of each module is usually different , and the design also needs to be flexible to meet the needs.

The master-slave role played by the MCU in the entire device will change according to the stage of operation. When the device is in standby mode, the host computer is the master and the MCU is the slave. The MCU receives the command from the host through one serial port, then starts the standard keyboard through the second serial port, and controls the corresponding sound and light prompts, and then waits for the key data (plain text of the user password) returned by the standard keyboard, and at the same time does the corresponding timeout processing . After receiving the key data, perform some basic rationality judgment processing, and then send the password plaintext to the encryption and decryption module through another serial port, and then receive the encrypted password ciphertext. Finally, upload the password cipher text through the serial port connected to the host computer, and then return to the waiting state. When operating on a standard keyboard and encryption and decryption module, the MCU acts as the master of communication. In the whole process, it can be regarded as a half-duplex communication method, making operation and control simpler and more reliable.

Picture 1   GM8123 functional block diagram

Figure 2 System design block diagram

Figure 3 State machine flowchart

Existing solutions

There are a variety of design methods for solutions that meet the above application requirements, including differences in cost, reliability, and indicators. According to the current serial device and design principle, there are the following design schemes.

Solution one is to use a multi-serial microcontroller. The price of single-chip microcomputer with dual serial ports is about 40 ~ 70 yuan, and the price of single-chip microcomputer with three serial ports is more expensive, which directly increases the cost of system design. At the same time, due to the different instructions of each microcontroller and the use of strange registers due to the expansion of the serial port function, the workload and difficulty of designers have increased.

The second scheme is to use an ordinary single-chip microcomputer to expand the 16C55X IC device that expands the serial port through the parallel port . The advantage of this kind of device is the high speed of serial port and quick response. But the disadvantage is the high cost of the device itself, the use of complex, multi-IO resources occupied by the microcontroller, cause some acoustic design for an external light control function 8255 will also be required to extend parallel extended resources, virtually added PCB area, and cost Design difficulty.

Solution three is the software to simulate the serial port function. The advantage is that the cost is low, but the reliability and serial port indicators cannot be controlled. The sampling of each BIT is 12 times in the hardware serial port work , and the software simulation can only be done up to 2 times, most of them are only 1 time, so the reliability of communication is difficult to guarantee. At the same time, the serial port simulated by the software is difficult to achieve a higher baud rate, so the application of communication is limited. Moreover, the difficulty of writing software, the large workload of the program, and the high requirements for R & D personnel also limit the promotion and application of this program.

Other solutions include the use of two to three ordinary single-chip microcomputers to achieve the required number of serial ports, and then to communicate with each other through a custom parallel port or simulated synchronous serial communication protocol.

New solutions for low-cost and flexible applications

It can be seen from the above schemes that the existing implementation schemes are difficult to achieve both costs and indicators. Chengdu Guoteng Microelectronics Co., Ltd. has introduced a brand-new serial port expansion chip GM812X series product to bring a new, low-cost and simple application serial port expansion solution to the above design.

The GM812X series serial port expansion chip can provide users with the simplest and high-performance serial port expansion solution, expanding a standard serial port into 3 or 5 standard serial ports. The serial chip's sub-serial port has a maximum baud rate of 38.4Kbps . The chip provides two working modes: single-channel working mode and multi-channel working mode, that is, you can specify a sub-serial port and a female serial port to work at the same baud rate, or you can let all the sub-serial ports be based on the female serial port The upper frequency division works simultaneously. Users can flexibly choose according to their needs. The working baud rate of the serial and sub-serial ports of the chip can be adjusted by software without modifying the external circuit and crystal frequency. The UART data format is selectable from 10 bits or 11 bits.

GM8123 can expand a standard serial port into 3 standard serial ports, GM8125 can expand 5 standard serial ports. This article selects GM8123 as the IC for serial port expansion . Figure 1 is a functional block diagram of GM8123 .

In this design, GM8123 can meet the design needs. For example, the single-chip computer uses the most commonly used and cheap AT89C52 , connects the serial port of the GM8123 to the serial port of the single-chip computer, and then connects the standard keyboard interface, the serial port of the encryption and decryption module and the serial port of the host computer to the three extended serial ports of the GM8123 . Figure 2 is a block diagram of the system design of the program.

Assume that the communication baud rate of the host computer and the encryption and decryption module is 9600bps , and the communication baud rate of the standard keyboard is 1200bps . Figure 3 is a flow chart of the state machine related to communication in the simple single-chip programming.

The operation and programming application of this chip are very simple. It can be seen from Figure 3 that the operation of GM8123 is mainly the modification of the communication serial port and the setting of the baud rate, and the operation mode and programming are basically the same. Since GM8123 works in single-channel mode, it can be regarded as a transparent transmission process between the mother serial port and the sub serial port, so there is no need to set the baud rate of GM8123 .

The following is part of the sample code of the C51 program that specifies the sub-serial port and changes from 9600bps to 1200bps during the transition to receiving standard keyboard key data in the waiting state :

// GM8123 address control line statement

sbit SRADD0 = P3 ^ 4;      // GM8123 address line SRADD0 control

sbit SRADD1 = P3 ^ 5;    // GM8123 address line SRADD1 control

sbit STADD0 = P3 ^ 6;      // GM8123 address line STADD0 control

sbit STADD1 = P3 ^ 7;    // GM8123 address line STADD1 control

void main (void)

{

............

// Initial settings

SCON = 0xC0;        // Set as required

TH1 = 0xFD;        // Load the initial value of timer 1 and set the MCU

       Working baud rate is 9600bps

TL1 = 0xFD;

PCON = 0x00;

TR1 = 1;        // Start timer 1

............

       // Set up the sub-serial port to communicate with the host computer

STADD0 = 1;        // Select sub-serial port 3 to send

STADD1 = 1;

SRADD0 = 1;        // Select sub-serial port 3 to receive

SRADD1 = 1;

............   // Relevant processing of receiving data from the host computer

// Switch to communicate with serial port one and standard keyboard

TR1 = 0;

TH1 = 0xE8; // Load the initial value of timer 1 and set the MCU

       Working baud rate is 1200bps

TL1 = 0xE8;

PCON = 0x00;

TR1 = 1 ;

STADD0 = 1;        // Select sub-serial port 1 to send

STADD1 = 0;

SRADD0 = 1;        // Select sub-serial port 3 to send

SRADD1 = 0;

............   // Keyboard control and keys

}

Conclusion

As can be seen from the foregoing, a very simple and flexible, less work procedures, three serial control easily achieved by the application of GM8123. And the above design only applies to the single channel mode of GM8123 , and has not yet exerted all the functions and flexibility of the chip. The chip has few external controls, flexible application, and simple programming and use. It is suitable for most applications that require multi-serial port expansion. such as:

However, it should be noted that the application of this chip is that the GM812X series interface IC can not set the different baud rate of each sub-serial port in multi-channel mode, and it cannot meet the application design of multi-serial port for data communication with different baud rates at the same time. In addition, the existing IC models of the GM812X series cannot meet the low power consumption requirements of handheld devices and have a maximum baud rate limit of 38.4Kbps .

Electric Fence

Electric Fence,Wireless Electric Fence,Best Electric Dog Fence,Wireless Fence For Small Dogs

Elite-tek Electronics Ltd , https://www.aetertek.ca