Along with enterprise size’s expansion and the Internet technology’s widespread popularization, the global each domain’s different enterprise was already right “lets the equipment networking” achieve the mutual recognition, but in the industrial control and the communication facility, more actually conforms to the RS232 standard serial port equipment. To be how many a serial port the data to retransmit to the network, realized equipment’s remote control, the data long-distance transmission then to become the question which urgently awaited to be solved. At the same time, considered the cost question, the former equipment is impossible to eliminate completely, therefore, this article proposed that one kind based on the TCP/IP multi-serial port transformation gateway, may fundamentally solve this difficult problem.
The multi-serial port transformation gateway possibly causes the serial port data stream to the ethernet data stream transmission into. It can connect many RS232 serial port equipment, and carries on the serial port data the choice and processing, turns into the ethernet data stream the RS232 connection’s data circulation, like this may carry on the network the data processing, realizes the serial data network. Uses this kind of plan, does not need to eliminate the original serial port equipment, many equipment may simultaneously enter the net, both may raise the equipment utilization rate, and saves the network expense, but may also simplify the wiring order of complexity in the existing network foundation. Uses serial port expansion chip GM8123 to be possible to realize the low cost, the high speed, the control simple multi-serial port plan.
1 system application plan< ?XML:NAMESPACE PREFIX = O />
In the business automation system, the upper formation business management level and the production monitoring level uses the ethernet and PC machine generally, but the lower level workshop scene many are the RS232 serial port observation equipment. This article proposed the multi-serial port transformation gateway, can facilitate realizes the high and low two communications.
May connect many serial port equipment is this system most major characteristic, avoided disposing the cost which for each equipment a gateway brought to be high, the network complex malpractice.
2 system structures
The TCP/IP agreement by the application layer, the UDP level, the IP level and the data link layer is composed. In order to realize the transparent transmission, increases the application advancement protocol layer - - serial port level. The serial port level constitutes by the serial port link level and the serial port network level. The gateway in the serial port level construction, simultaneously analyzes the RS232 data packet, and as TCP/IP network application layer data transmission. The multi-serial port gateway is composed of the TCP/IP protocol conversion module and the multi-serial port receiving and dispatching control module, structure as shown in Figure 1.
(1)TCP/lP protocol conversion module
It is a miniature ethernet turning on module, by micro controller (MCU), the network card connection chip, outside EEPROM 93C46, the piece 512 KBSRAM chip IS6lLV5128 as well as the auxiliary element constitutes. The micro controller control network card connection chip carries on the network service, realizes Address Resolution Protocol (ARP), Internet control text agreement (ICMP), the IP agreement, agreement and so on User Datagram Protocol (UDP) analyses and the wrapped gift. The ethernet transmission buffer’s serial port frame seal in the UDP package, and passes to the IP level; At the same time, receives the ethernet data frame and the upward layer upon layer bale breaking, the separation application layer data, then data analysis processing hands over by the multi-serial port transmission module completes, realizes the RS232 serial port class and the ethernet port class transparent transformation.
more than (2) serial port receiving and dispatching control module
Realizes many RS232 serial port data stream to receive/sends the control, including micro controller, parts and so on serial port expansion chip (GM8123), MAX232. The micro controller controls GM8123 to complete multi-serial port data receiving and dispatching, receives many serial port source data, after the seal, reads in the ethernet transmission buffer pack transmission; At the same time, receives the ethernet application layer the data, the analysis gives concurrently observes and controls the equipment. It did not care that the correspondence data the concrete significance, is only responsible to receive/the transmission, the seal/breaks a seal the serial port frame, provides the general connection.
more than 3 serial ports realize
3.1 realize the plan - - to use the serial port expansion chip
Has in 2 UART foundations in the micro controller, uses GM8123, the system can provide 2 groups (UARTO, UARTl) the altogether 4 serial ports (COM1, COM2, C0M3, COM4), uses two level of priority control UARTO and the UARTl interrupt request and the permission nesting. In the UARTO interrupt routine, which stature serial port through the inquiry way determination data pool is.
When two groups of serial ports simultaneously have the data request, first, the MCU interrupt mechanism judgment interrupt request’s priority, first responds to the priority high interrupt request. System to priority assignment: UART0 is 2, UARTl is 1, namely MCU first responds UART0 the interrupt request. When the UARTO 3 spigots simultaneously have the data request, through the polling mode, responds to each spigot, namely carries on the response from small to big according to the mirror slogan’s address. Thus, has formed 2 levels of interrupts and 4 serial port multi-serial ports realizes the plan.
more than 3.2 serial port expansion chip - - GM8123
GM8123 may expand a full-duplex’s standard serial port 3 standard serial ports, and can through the exterior pin control. Selects this chip is based on its own characteristic:
①Uses writes the control word the way to carry on the control to the chip, the control is simple;
②The data format 10 or 11 may elect;
③Has 3 sub-serial ports. And each sub-serial port baudrate adjustable (unification adjustment);
④Two kind of patterns (single channel pattern and multi-channel pattern) may through 1 pin control;
⑤Under the multichannel working pattern, each sub-serial port’s baudrate is equal to the female serial port baudrate 4 frequency divisions;
⑥When multichannel working pattern, receive address wire SRADD1~0 receives subchannel’s address to the MCU returns, after MCU receives the data which the female serial port sends, which sub-serial port can be sends according to the SRADDl~0 condition judgment data from, when transmission chooses the sub-serial port first by MCU again to the female serial port transmission data;
⑦Is compatible with the standard serial port correspondence form, TTL level output;
⑧Each sampling 16 times, enhances the data accuracy;
⑨The wide working voltage is 2.3~6.7 V.
⑩The entry address pin has 50~80 kΩ under pulls the resistance, other inputs
The pin has 50~80 kΩ on pulls the resistance (the OSCI exception).
3.3 various serial ports characteristics and applied analysis
In the system two group of serial port use’s resources are different, in speed between them existence difference. Serial port COMl, COM2 and COM3 expand micro controller’s UARTO through GM8123 to obtain, suit the transmission speed to be slow, the data quantity small equipment; COM4 is micro controller’s UARTl, is opposite in the first group of serial port can the very good adaptation transmission speed quick equipment.
The GM8123 work in the multi-channel pattern, each sub-serial port must establish the unification baudrate, is not suitable the situation which in various serial ports equipment work baudrate inconsistent, requests simultaneously to work, this is also this chip deficiency. In the practical application, COM1, COM2 and COM3 should connect the type, the speed same equipment. The COM4 baudrate may act according to the demand concrete disposition, like this, system’s 4 serial ports may form two kind of application plans from the speed: First, 4 serial port disposition same baudrate; Second, every l group disposes 1 baudrate value.
In summary, the system provided by 2 groups of 4 serial ports, two levels of priority controls, 2 kind of baudrate disposition plan constitution multi-serial ports has realized the method.
4 principles of work
4.1 unitizing
The system 4 serial port source’s data needs to take the ethernet frame a part, to provide the transparent connection and the discrimination data pool to the equipment, needs to formulate the unified frame form. Frame form as shown in Figure 2, the serial port number field uses for to differentiate the data pool; Frame, the frame tail takes a serial port frame the outset dividing line (to be possible from definition); The data part is comes from the serial port the primitive data stream. Similarly, the net mouth transmission data must have the consistent frame form, as shown in Figure 3. Obviously, the serial port frame is carries on the transmission as the UDP level agreement data.
4.2 system data flow to the analysis
Of does the multi-serial port transformation gateway, realize data conversion between many serial ports and a net mouth, how the key is many serial port data delivers in the network, the network data how to change to many serial ports. And, the serial port link level completes the serial port data receiving and dispatching function, the serial port network level takes the TCP/IP application layer a part, realizes the serial port frame seal. The transmission enters the agreement stack’s process, as shown in Figure 4, the receive is the agreement stack’s process (chart omitted), the difference lies to the data receives/sends processing.
Multi-serial ports to net mouth data conversion transmission: The serial port link level, receives from observes and controls equipment’s data, gives the serial port network level, this level completes the serial port data frame the seal and puts in ethernet’s transmission buffer. When the system stipulated the UDP pack time to when or already had 4 serial port data frame, hits the UDP package, and under the cascade delivers, until delivers the data the physical medium, completes a bit class the transmission.
For could a transmission as far as possible many data, the system make the strict definition to the data length: The serial port data frame’s data segment greatest length is 300 bytes; The net mouth transmission frame’s data segment permits 4 serial port data frame most much. At the same time, but must satisfy the concrete application to the timely request: Stipulates longest response time to each serial port. Time at the appointed time, no matter whether to have received: 300 bytes must carry on the seal to the serial port data, and releases people the ethernet transmission buffer; At the same time, to avoid the system, because the waiting ethernet transmission buffer serial port frame number achieves 4, but causes the serial port data not to be able the real-time transmission, requests to carry on an ethernet correspondence in certain time, but does not need to wait for that 4 serial port frames arrive in full only then pack the transmission.
Thus, the system to the data capacity and the time dual stipulations, can guarantee that the concrete application to the timely request, and could a transmission as far as possible many data, reduce, because in the time “spatial and so on” created the system timeliness bad possibility. 4 serial ports the function which completes in the serial port level are the same, only take COMl as the example, gives on the serial port level the data
The class, as shown in Figure 5.
Figure 6 explained the multi-serial port data frame waiting pack transmission process.
Flows the net mouth data to the multi-serial port’s data, is to the ethernet link level data frame upward cascade bale breaking process. As shown in Figure 7, will receive the ethernet frame, removes each level agreement to decompose the application layer data in turn, again take 0×24 and OxOa as the dividing line separation, according to the serial port number field’s value, the message routing to the corresponding equipment, completes the predetermined control.
Conclusion
This article introduced that based on the TCP/IP multi-serial port transformation gateway, used the GM8123 chip to increase the serial port number, suited requests to enter net serial port equipment many situations. With the aid in this multi-serial port gateway, may facilitate realizes the serial port equipment and the monitoring level transparent data communication, realizes equipment’s network control and the information distributional management, must be able the widespread application in based on ethernet’s distributional observation network.