Low-cost serial port expansion solution applied in bank counter PIN pad device

Pick    To: This article introduces the application of GM8123 to realize the expansion of multiple serial ports in the bank counter PIN pad 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 baud rate of each module's UART is usually different , and the design needs to be flexible to meet the needs.

The master and slave of the MCU playing in the entire device will change according to the stage of operation. When the device is in standby mode, the upper computer is the master and the MCU is the slave. After receiving the master's command through a serial port, the MCU starts the standard keyboard through the second serial port, and controls the corresponding sound and light prompts, and then waits for the key data returned by the standard keyboard (the plaintext of the user password), and simultaneously performs corresponding timeout processing. . After receiving the button data, some basic rationality judgment processing is performed, and then the password clear text is sent to the encryption and decryption module through another serial port, and then the encrypted password ciphertext is received. Finally, the password ciphertext is uploaded through the serial port connected to the host computer, and then restored to the waiting state. When operating on a standard keyboard and encryption and decryption module, the MCU plays the main role of communication. Throughout the process, it can be seen as a half-duplex communication method that makes operation and control simpler and more reliable.

Figure 1   GM8123 functional block diagram

Figure 2 system design block diagram

Figure 3 state machine flow chart

Existing plan

There are several ways to design a solution that meets the above application requirements, and there are differences in cost, reliability, and metrics. According to the current serial device and design principle, the following design schemes are summarized.

The first solution is to use a multi-serial serial port. The price of the single serial port MCU is about 40~70 yuan, and the price of the three serial port MCU is more expensive, which directly increases the cost of the 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 the designer are increased.

The second solution is to use an ordinary single-chip microcomputer to extend the 16C55X IC device that expands the serial port through the parallel port . The advantages of this type of device are high serial port speed and fast response. But the shortcoming is that the device itself is costly, complicated to use, and omishes the IO resources of the single-chip microcomputer . As a result, some designs need to control the external sound and light function, and need to expand the 8255 to expand the parallel port resources, which in turn increases the PCB board area, cost and Design difficulty.

The third solution is the software analog serial port function. The advantage is low cost, but reliability and serial port indicators are beyond control. The sampling of each BIT in the hardware serial port work is 12 times, and the software simulation can only be done 2 times at most, most of which is only 1 time, so the reliability of communication is difficult to guarantee. At the same time, the serial port of the software simulation is difficult to achieve a high baud rate, so the application of communication is limited. Moreover, the difficulty of software writing, the large amount of program work, and the high requirements for R&D personnel also limit the promotion and application of this program.

Other solutions include the use of two or three ordinary microcontrollers to achieve the required number of serial ports, and then through the custom parallel port or analog synchronous serial communication protocol to achieve communication and other solutions.

New solution for flexible applications at low cost

It can be seen from the above scheme that the existing implementation scheme is difficult to achieve the same in terms of cost and indicators. A new way of serial expansion chip GM812X series introduced by Chengdu Guoteng Microelectronics Co., Ltd. brings a new, low-cost and simple application serial expansion solution for the above design.

GM812X series serial port expansion chip can provide users with the simplest and high performance serial port expansion solution, and expand a standard serial port into 3 or 5 standard serial ports. The serial port of this series of chips has a maximum baud rate of 38.4Kbps . The chip provides two working modes: single-channel working mode and multi-channel working mode, which means that one sub-serial port and the female serial port can be specified to work at the same baud rate, or all sub-serial ports can be based on the parent serial port baud rate. The upper crossover works at the same time. Users can choose according to their needs. The working baud rate of the chip's female serial port and sub-serial port can be adjusted by software without modifying the external circuit and crystal frequency. The UART data format is optional with 10 or 11 bits.

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

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

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

The operation and programming application of the chip is very simple. It can be seen from Figure 3 that the operation of the GM8123 is mainly the change of the serial port of the communication host and the setting of the baud rate, and the operation mode and programming are basically the same. Since the GM8123 works in single-channel mode, it can be regarded as transparent transmission between the female serial port and the sub-serial port, so it is not necessary to set the baud rate of the GM8123 .

The following is part of the sample code for specifying a sub-serial port and a C51 program modified from 9600 bps to 1200 bps during a wait state transition to receiving standard keyboard button data :

/ / 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)

{

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

/ / Initialize the settings

SCON = 0xC0;        / / Set as needed

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

       Working baud rate is 9600bps

TL1 = 0xFD;

PCON = 0x00;

TR1 = 1;        / / Start timer 1

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

       / / Set the sub-serial port three and the host computer communication

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

STADD1 = 1;

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

SRADD1 = 1;

............   / / Receive the relevant processing of the host computer data

/ / Switch to serial port and standard keyboard communication

TR1 = 0;

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

       Working baud rate is 1200bps

TL1 = 0xE8;

PCON = 0x00;

TR1 = 1 ;

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

STADD1 = 0;

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

SRADD1 = 0;

............   / / keyboard control and buttons

}

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 is only applied to the single channel mode of GM8123 , and has not yet played all the functions and flexibility of the chip. The chip has less external control, flexible application, and simple programming. It is suitable for most applications that require multiple serial port expansion. such as:

However, the application of this chip needs to pay attention to the fact that the GM812X series interface IC can not set the baud rate of each sub-serial port in multi-channel mode, and can not meet the application design of multi-serial port simultaneous data communication with different baud rates. In addition, the existing IC models of the GM812X series do not meet the low power requirements of handheld devices and have a maximum baud rate limit of 38.4Kbps .