“In a large-scale industrial control system, the start and stop of equipment at all levels have a certain impact on the operating conditions of the entire system. The collection of switching signals of these devices and the recording of the action sequence are also particularly important. Therefore, it is necessary to design a switch signal acquisition card to collect these signals in order to provide a basis for the detection and analysis and query of equipment operating status and production accidents.
In a large-scale industrial control system, the start and stop of equipment at all levels have a certain impact on the operating conditions of the entire system. The collection of switching signals of these devices and the recording of the action sequence are also particularly important. Therefore, it is necessary to design a switch signal acquisition card to collect these signals in order to provide a basis for the detection and analysis and query of equipment operating status and production accidents.
The 16-channel switch signal acquisition card introduced in this article uses Philips LPC2131 ARM microcontroller as its core. With a 0.5ms sampling period, it can collect 16 switching input signals, and measure the transition waveform and occurrence time of the switching in real time. Upload the data to the upper computer historical database with a resolution of 1ms. At the same time, the historical data can be inquired in an all-round way through the cooperation with the upper computer software to analyze the operation of the system.
The measurement card has a UART communication interface, which is connected to the controller. After the collected data is sent to the controller for processing, then sent to the workstation to Display the status, and at the same time record the time and status of the event, and store the recorded data in the workstation history database.
Signal acquisition card
The acquisition card uses 16-channel LED lights on the main panel of the card to indicate the signal status of the channel. At the same time, it is isolated between the channel and the channel, and between the channel and the bottom board, and realizes the electromagnetic shielding from the scene. To ensure that the measured signal is not interfered. The specifications of the acquisition card module are shown in Table 1.
At the same time, the acquisition card uses the UART communication interface, and the communication physical layer uses the CAN bus driver chip TJA1040 to network with the controller and send the collected data to the controller.
Acquisition card hardware design
The hardware circuit of the channel switch signal acquisition card is composed of five parts: signal acquisition circuit, single-chip microcomputer system, communication interface circuit, external pins, and man-machine interface. The schematic diagram of the hardware circuit structure is shown in Figure 1.
Figure 1 Hardware structure diagram of switch measurement card
Switch signal acquisition circuit
The switch quantity signal acquisition circuit is to realize the collection of various switch quantity signals on site and send it into the processing chip. In the actual design, the Philips LPC2131 ARM microcontroller is used.
The measurement principle of the signal acquisition circuit is: the on-site 16-channel switching signal is connected to the card measurement terminal. Due to the fluctuation and interference of the on-site signal, in order to ensure the stable and reliable operation of the system, prevent various on-site and power interference from affecting the system. Affected, the channel uses a photoelectric coupler to isolate the inside of the card from the field input signal, so as to achieve accurate signal measurement. In the actual design, a PS2701 photoelectric coupler is used, and the block diagram of the card measurement path is shown in Figure 2.
Figure 2 Switch signal acquisition circuit
Later, considering the simplicity of signal inversion, the photocoupler was changed to PS2705, which realized the function of signal inversion, so the actual measurement circuit was further simplified as Figure 3.
Figure 3 Simplified switching signal acquisition circuit
The signal after the isolation and conversion of the photocoupler is connected to the data bus of the processing chip through the bidirectional bus driver, and the data is sent to the processing chip LPC2131 for processing.
Single Chip Microcomputer System
The processing chip is Philips LPC2131, which is based on a 32-bit ARM7TDMI-STM CPU microcontroller that supports real-time simulation and embedded tracking, and has a 32kB embedded high-speed Flash memory. The 128-bit wide memory interface and unique acceleration structure enable 32-bit code to run at the maximum clock rate. At the same time, LPC2131 has strict control over the code size, and the 16-bit Thumb mode can be used to reduce the code size by more than 30%, while the performance loss is very small. LPC2131’s smaller package and extremely low power consumption make it ideal for use in small systems, such as access control and POS machines. The wide-range serial communication interface and the on-chip 8kB SRAM make LPC2131 very suitable for communication gateways, protocol converters, soft modems, voice discrimination and low-end imaging, providing them with huge buffer space and powerful processing functions. Multiple 32-bit timers, 1 or 2 10-bit 8-channel ADCs, 10-bit DAC, PWM channels, 47 GPIOs and up to 9 edge or level-triggered external interrupts make it particularly suitable for industrial control systems.
The single chip microcomputer system takes LPC2131 as the core, with 8K flash memory on-chip, so there is no need to expand the external ROM; to realize the recall of the historical data of the switch value, the relevant information must be easy to store and not easy to lose, which can be effective after the system loses power Save data. The measured data information includes the year, month, day, hour, minute, second, millisecond when the switch occurred, and the switch state of each channel at that time.
Figure 4 Block diagram of the single-chip system circuit
At the same time, due to the influence of various interferences and other factors in the operation of the system, it often causes the program to run out after an infinite loop. A simple hardware WATCHDOG circuit is also used in the system.
Communication interface circuit
In order to enable the measurement card to effectively send the collected data to the controller, the card is designed with a UART circuit. Through the serial port, the card can complete related tasks such as data transmission, parameter adjustment and clock calibration according to the operation commands of the host computer.
The card uses the TJA1090 communication chip, which is designed for serial communication mode, and the output terminal is also connected with a voltage regulator protection circuit. The interface circuit is shown in Figure 5.
Figure 5 Communication interface circuit
Card module specifications and external circuit pins
The card is connected to the card base board through a dedicated pin to transmit the collected signal. The external circuit pins of the card are shown in Figure 6.
The card uses serial communication to communicate with the controller, and then uploads the measured signal to the upper computer, which is displayed on the upper computer’s configuration screen. The man-machine interface is friendly. The data can be used for system configuration, historical data query and other operations, and can be realized at the same time Process control SOE query, through its supporting SOE software, can achieve functions such as jitter removal, peak clipping, valley clipping, etc., and realize SOE accident recall and query, and its accuracy can reach 1ms.
Capture card software design
The card software design adopts a functional module structure. All software includes main program, interrupt service subroutine, etc. The main program is used to patrol and execute the commands sent by the host computer. The interrupt service subroutine is divided into the overflow interrupt subroutine and the serial port interrupt subroutine. The former is used for the collection of the switching value jump signal, and the latter is used for receiving the data sent by the upper computer.
After the card is electrified, enter the main program. Firstly, judge whether the card is a power-on reset. If it is not a power-on reset, it will directly enter the patrol detection stage after the crash recovery process; if it is a power-on reset, the card self-check and initialization will be performed first, including setting the stack pointer and clearing. Memory, set the time constant, etc., and then allow interruption, enter the normal touring processing program, can realize the function of parameter setting, switching value jump time, status collection and so on. If it is detected in the main program that the received data flag defined in the program is set, it indicates that the microcontroller has received the data sent by the host computer, and the process of receiving data is completed by the serial port interrupt subroutine. According to the data from the host computer, the measuring card will respond accordingly, or send back data or parameter settings.
Interrupt service routine
The signal collection service subroutine mainly completes the collection of the switching signal of the action, which is realized by the overflow interrupt, which is interrupted every 0.5ms.
The communication service subroutine mainly refers to the receiving subroutine of the upper computer data, which is realized by the serial port interrupt. Most of the data sent back to the host computer is the switch value record information, and the amount of data is relatively large, which is mainly completed in the main program. At the same time, you can set the size of the baud rate during communication, which can be achieved in the card parameter settings.
At present, the card has been put into use in the desulfurization monitoring system for the #10 and #11 units of Nantong Tianshenggang Power Plant in Jiangsu Province. All performance indicators have reached the original design requirements, are reliable in operation and in good condition, and can be widely used in the industrial process of chemical, metallurgy, electric power and other industries to realize the functions of switching value collection, accident recall and other functions.