Design of Wireless Terminal Based on STM32 MCU and EM310
“In the monitoring monitoring and data acquisition system (SCADA) system, the real-time and accuracy of the collected data has a great influence on the system. A suitable communication network can effectively improve the benefits of the SCADA system. The GPRS wireless terminal designed in this paper is used in the SCADA system. In addition to meeting the real-time and accuracy of data, it also has the advantages of low construction cost, simple structure, large transmission capacity, and remote control.
“
0 Preface
In the monitoring monitoring and data acquisition system (SCADA) system, the real-time and accuracy of the collected data has a great influence on the system. A suitable communication network can effectively improve the benefits of the SCADA system. The GPRS wireless terminal designed in this paper is used in the SCADA system. In addition to meeting the real-time and accuracy of data, it also has the advantages of low construction cost, simple structure, large transmission capacity, and remote control.
1 Introduction to Terminal
1.1 Terminal structure
The wireless terminal is composed of the EM310GSM module and the STM32F103 single-chip microcomputer, with the STM32F103 single-chip microcomputer as the core. The STM32F103 single-chip microcomputer has rich communication interfaces for connecting EM310 and field instruments; there are also rich I/O resources, which can expand the larger capacity of RAM. On the one hand, it stores the instruction set, which is used to interpret the command and make corresponding actions; on the other hand, it is used to temporarily store the data collected by the monitoring point. The terminal uses GPRS technology to communicate with the control center. .Large transmission capacity, high-speed transmission, etc. Figure 1 is the structure diagram of the wireless terminal and monitoring point instrument.
1.2 Application of terminal in SCADA system
The main task of wireless terminal in SCADA system is to pass GPRS network
And the Internet network to realize the data transmission and reception between the monitoring point and the control center, its structure is shown in Figure 2.
1.2 Hardware Design
The main functions of the terminal are: data sending and receiving, instruction interpretation and control monitoring point meter. To meet the above functions, the circuit is mainly divided into several parts: EM310 module circuit. External expansion RAM circuit. Instrument serial port circuit.
(1) The EM310 module has certain requirements for the speed and capacity of the wireless module to transmit data in the SCADA system. In addition, in some systems, the operating temperature of the terminal is required to be higher. Compared with the Siemens MC55, the EM310 has a large low temperature range and can It is applied to some occasions with high temperature requirements; compared with GTM900B, it is smaller in size and stronger in function. EM310 has built-in protocol search, and can send 2K bytes at a time, which can meet the requirements of most SCA-DA systems; it has MUX function, can Realize the transmission of large amounts of data.
The role of the EM310 module is to receive data from the serial port of the STM32 microcontroller and send and receive wireless data to the STM32 microcontroller through the serial port. When connecting to the GPRS network, the SIM card needs to be verified, and the current status is displayed through the LPG pin. Therefore, The EM310 module circuit mainly includes the serial port part, the SIM card connection part and the LPG indicator light connection part, as well as the startup and reset parts.
As shown in Figure 3, SIM_CLK.SIM_VCC.SIMJO.SIM_RST are the clock, power, data and reset lines of the SIM card respectively; LPG is used to connect the network status indicator; RST is the reset pin, active low, this pin is in Connect a 100nF capacitor in parallel near the 50PINB2B connector to GND for electrostatic discharge protection; TERM-ON is the switch pin, pull the TERM-ON pin down for 50ms to turn on the machine, and then pull the TERMJ3N pin down for 50ms, It can be turned off. VDD-IO is the power supply pin of I/O port, the relationship between VDD-IO voltage U and /DTR./RTS./TXD plus series resistance R is calculated by the formula: R=3.5 * U-11.3K.
(2) External RAM expansion
The extended RAM is used to store the instruction set and temporarily store the instrument detection data. When the terminal receives the data packet, the single-chip microcomputer will find the corresponding program segment in the RAM according to the received data packet, and run the program segment. That is to do the actions required by the control center, such as reading the parameters of the instrument, setting the parameters of the instrument, reading the monitoring data, etc.
The read and write speed of RAM largely determines the response speed of the terminal after receiving the data packet. Therefore, the terminal selects high-speed static RAM IS61LV25616, adopts ISSI’s high-performance CMOS technology, uses highly reliable technology and innovative circuit design technology, and has Features of high performance and low power consumption.
The IS61LV25616 has a standby mode, which reduces power dissipation at the CMOS input level, and the RAM can be in standby mode when the terminal does not receive commands and does not need to send data; the chip can also be well implemented by enabling the connection of the interface Memory expansion; data access includes high-byte access and low-byte access.
(3) Instrument serial port
The instrument serial port is used for the connection between the monitoring point instrument and the single-chip microcomputer. The instrument serial port circuit selects the form of RS232 to TTL level, as shown in Figure 4, 1.4.6 of DB9 is short-circuited, and the RS232 level is sent and received through the transceiver SP3223EA. In SP3223EA, a polar capacitor is connected between C1+ and C11 as the pump capacitor of the voltage multiplier, and a polar capacitor between C2+ and C21 is connected as a reverse charge pump capacitor. TXfN is the TTL/CMOS driver input, and TxOUT is the RS-232 driver. Output, RxlN is RS-232 receiver input, RxOUT is TTL/CMOS receiver output.
SP3223EA realizes the conversion from TTL level to RS232 level by multiplying and reversing.
2 Software design and debugging
The software design needs to realize the initialization of EM310 through serial communication, the setting of parameters, and the sending and receiving of data.
2.1 Program flow chart
The serial port connected to the single-chip microcomputer and the EM310 is serial port 1, and the serial port of the instrument is serial port 2. In the main program, first define some global variables, and then initialize, including the initialization of the system and peripheral clocks. The initialization of peripherals and general lP ports. Serial port Initialization. The timer is initialized, and finally enters the loop to check whether there is data received or whether the instrument serial port needs to send data. If data is received, it will enter the subroutine of receiving data, and if it needs to send data, it will enter the subroutine of sending data. Program flow The figure is shown in Figure 5.
2.2 Debugging process and results
The serial port debugging tool is used here to simulate the monitoring point instrument, which can transmit data to the GPRS wireless data terminal, and then send it to the control center by the EM310, or read the received data from the EM310; use the TestGPRS software to simulate the control center software. It can Display The data sent from the serial port debugging tool can also be sent to the serial port debugging tool through the network.
(1) EM310 initialization
The initialization of EM310 includes signal detection, SIM card detection, mode selection, registration gateway, user name and password. When the signal strength is sufficient and the SlM card is connected correctly, the registration can be performed. First, select the mode to determine whether to allow the module to input The output data is compressed and converted; then register the gateway, user name and password; and finally wait for the allocation of lP. The initialization sequence is: ①Check the signal strength; ②Check whether the SIM card is connected correctly; ③Select the mode; ④Register the gateway; ⑤Register the user name and password.
(2) Set command and send and receive test
The setting command is mainly the protocol type. The setting of IP and port number. The IP and port number must be consistent with the lP. port number of the data center, and then data can be sent and received through AT commands. The methods of setting and sending and receiving data are as follows:
Send: AT%IPOPEN=”TCP” “210.32.34.65”, 8001
Returns: CONNECT
Send: AT%IPSEND=”31323334354142” Send data 12345AB
Returns: %IPSEND:1,15
OK
Use TestGPRS software to send AB1234 to port 8001, and then it will display in the serial port test tool: %IPDATA:1,1,6
Send: AT%IPDR
Returns: %IPDR: 1,1,6, “414231323334”
OK
3 Conclusion
This solution can be applied to general SCADA systems and has the characteristics of simple structure, strong expansibility, low construction cost, fast transmission speed, and fast connection. Prove the feasibility of the scheme. The rich I/O resources and communication interface resources of the STM32 microcontroller can meet the needs of various SCADA system terminals and facilitate the secondary development of users.
The Links: AA084SC01 G213QAN01.0