At present, a large number of devices in the industrial field do not have Ethernet interfaces, but these devices provide RS-232 serial ports or RS-422 / 485 serial ports. RS-232 can only provide close-range data transmission, and the speed is not high. Although RS-422 / 485 can provide long-distance data transmission, it is independent of the Internet and is not convenient for network management. The Ethernet has a fast transmission speed and a long transmission distance, and can provide monitoring and data access services for any networked computer. In order to enable traditional serial devices to access the Internet easily and quickly, the author built an embedded system (serial port server) with ARM7 processor LM8962 and serial port expansion chip SC28L198 as the core, and completed the conversion between Ethernet data and serial port data. . On the one hand, LM8962 packs the serial data sent from SC28L198 into an Ethernet data frame and sends it to the host through its own Ethernet controller; on the other hand, LM8962 unpacks the received Ethernet data, separating the data and the corresponding Serial port device number, and then sent to the serial device through the corresponding channel of SC28L198. The author simplifies the design of complex hardware circuits and can implement a low-cost, high-speed single-chip multi-serial port expansion solution. With this solution, the serial port device can be virtualized as a COM interface of the computer, and users do not need to consider the complexity of data transmission for remote operation of the serial port device.
1 Serial server hardware structure
The system selects the ARM chip LM8962 produced by TI as the main control MCU and the chip SC28L198 produced by Phillips as the 8-channel UART controller.
The main function of the system is to complete the conversion between TCP / IP protocol and serial communication protocol.
The main controller LM8962 is a 32-bit microprocessor based on ARMCortex-M3MCU core developed by LuminaryMicro. The maximum frequency supported by this processor is 50MHz, with embedded Flash and SRAM, motion control PWM and other internal modules. The LM8962 integrates an Ethernet controller, which combines the Bosch controller LAN technology and 10/100 Ethernet media access control (MAC) and physical (PHY) layers, simplifying the hardware circuit design of the system's Ethernet connection. The microcontroller uses the Thumb2 instruction set that is compatible with ARM Thumb to reduce the storage capacity requirements, and to achieve the purpose of reducing costs. The hardware structure of the system is shown in Figure 1.
Figure 1 hardware structure diagram
The UART device SC28L198 provides 8 independent full-duplex asynchronous channels. Each UART communicates with the host through a synchronous bus interface. The receiver and transmitter of each channel have a 16-character FIFO, which minimizes the receiver timeout. Using user-defined Xon / Xoff characters can achieve automatic in-band flow control, which can be performed in wake-up mode Address recognition. SC28L198 also includes the following functional modules:
Timing module, including a universal baud rate generator that can generate 22 industry standard baud rates and two 16-bit counters used to generate non-standard baud rates; I / O port control module and state change detector Module; interrupt arbitration system that can arbitrate 24 interrupts. In order to reduce software overhead, the interrupt arbitration system included in the device reports the UART interrupt status by directly accessing or modifying the interrupt vector. The interrupt context reported includes the channel number, device interrupt type (receiver COS, etc.), the fill point of the transmitter or receiver FIFO.
2 Serial port expansion circuit
Figure 2 depicts a block diagram of the circuit connection of a serial networking server with 8 channels. The hardware of the serial server consists of two main chips and other peripheral circuits. Among the pins of SC28L198, CEN, W_RN, IACKN, DACKN, IRQN, and SCLK pins control the data transmission between the external and internal data buses of the host and SC28L198. Pins A7 to A0 are the address buses connected to ARM by SC28L198 D7 ~ D0 are the data buses for SC28L198 and ARM to transfer data.
Figure 2 Circuit connection block diagram
The baud rate generator works under the oscillator or external X1 / CCLK clock input, and can generate 22 common data communication baud rates in the range of 50.0 to 230.4k. The external crystal frequencies commonly used are 3.6864MHz and 7.3728MHz, and the baud rate generated at the operating frequency of 7.3728MHz is twice that generated at 3.6864MHz. Each receiver and transmitter can work at different baud rates, and different baud rates will be generated by writing different selection codes to the baud rate selection register.
SC28L198's system clock (SCLK) can be used as the basic time reference for the host interface and other internal circuits. To ensure proper operation of the internal controller, the SCLK frequency provided must be greater than twice the X1 crystal clock or any external 1X data clock input. Since the LM8962 chip itself does not provide a clock signal output pin, if a square wave signal with a frequency above 7.3728MHz is generated by a timer interrupt, the LM8962 will frequently process interrupt programs, affecting the efficiency of program execution. When SC28L198 works at 50MHz frequency, the PWM hardware module in it can generate up to 25MHz output without any interruption, so LM8962 will be free from frequent query and processing interruption.
In this system, it is necessary to use RS-232 transceiver or RS-422 / 485 transceiver and its peripheral circuits according to different applications. The RS-232 transceiver can be used for short-distance full-duplex communication, and the RS-422 / 485 transceiver can be used for long-distance data transmission. Because the whole system works under 3.3V voltage, in order to match TTL level and RS-232 level or RS-422 / 485 level, this circuit uses MAX3232 chip or MAX3485 chip.
The integrated Ethernet controller inside the LM8962 contains a complete MAC module and PHY interface device, which simplifies the hardware circuit design. The Ethernet controller fully supports the 10BASE-T and 100BASE-TX standards and complies with the IEEE802.3 protocol. The whole system needs only one isolation transformer to connect to Ethernet, and no external Ethernet control chip is needed, which simplifies the hardware design. The isolation transformer can isolate the module ground and the digital ground, thus ensuring that the SC28L198 can keep away from the complex signals of the outside world.
3 Software design
In this system, users can operate the serial server by configuring and querying the serial server and sending and receiving data on the computer (client) via Ethernet. On the client, 8 channels of SC28L198 are virtualized into 8 COM interfaces. Operating these virtual COM interfaces is like operating a physical COM interface on a computer, so users do not need to know that data is being transmitted via Ethernet. In fact, when users operate these COM interfaces, the generated commands and data will be packaged into a frame of data and sent to the processor LM8962, and then the LM8962 will send the data to the device through the corresponding channel of SC28L198. The serial port server uses the ARM processor LM8962 as the core device of the embedded device, and runs the μC / OS-II operating system on it to open, close, and manage the corresponding processes of the eight serial channels. Therefore, 8 serial channels can simultaneously send and receive data without affecting each other.
3.1μC / OSï¼II
μC / OS-II is a free and open source real-time operating system designed specifically for embedded systems. It includes task planning, task management, time management, memory management, communication between tasks, and other basic functions. In this system, μC / OS-II is used to realize the following functions:
(1) Establish a message queue to store serial channel messages and UDP messages; (2) Control SC28L198 to send and receive serial data; (3) Create a task to manage UDP communication and send and receive data via Ethernet; (4) Create a task To manage the communication between the serial channel transceiver task and the UDP communication task.
3.2TCP / IP module
The TCP / IP protocol has a layered structure, which enables the packing and unpacking of Ethernet data frames. UDP provides an unreliable data transmission service at the TCP / IP transport layer, but the UDP protocol is relatively simple and can provide real-time and fast data transmission more than the TCP protocol. During normal operation, the TCP / IP program module can obtain serial communication data from the data queue and package the data into a UDP packet, then send the UDP packet to the IP layer, and finally form a frame of data. The frame data will be sent to the computer via Ethernet. At the same time, the program module also unpacks the data received from the Ethernet, and sends the serial channel number and serial data to the SC28L198. Table 1 describes the format of sending and receiving a frame of data.
Table 1 Data transmission format
Interchangeable Power Adapter: Simplifying Your Power Needs
As a leading manufacturer of ac power adapter, we understand the importance of providing efficient and versatile power solutions for our customers. In today's fast-paced world, having an interchangeable plug power adapter is essential.
1. Travel-Friendly:
For frequent travelers, carrying multiple chargers for different countries can be inconvenient and space-consuming. Multi plug power adapter is the perfect solution for those on the go.With EU US UK AU 4 plug detachable, you can travel to USA Europe UK Australia and charge more convenient.
2. Safety and Efficiency:
Safety is a top priority when it comes to switching power supply. Our changeable power adapter is built with advanced safety features, including over-voltage protection, short-circuit protection, and over-current protection, to safeguard both the adapter and the connected devices. With safety and efficiency in mind, our interchangeable power adapters offer peace of mind to users.
In conclusion, interchangeable power adapters offer a convenient and versatile charging solution for users. Their ability to work in various countries, travel-friendly design,emphasis on safety and efficiency make them an ideal choice for individuals seeking a simplified charging experience. As a trusted switching power supply manufacturer, we are committed to providing high-quality interchangeable ac adapter that meet the evolving needs of our customers. Choose our ac to dc power adapter and enjoy the convenience they bring to your charging routine.
Interchangeable Power Adapter, multi plug power adapter, interchangeable plug power adapter, detachable power adapter
Guangdong Mingxin Power Technologies Co.,Ltd. , https://www.mxpowersupply.com