Remote measurement and control is widely used in places where there are a large number of devices and they are widely distributed. With the development of computer and network technology, the use of local area networks can well solve the problem of centralized management and decentralized control. However, when the distribution of the measurement and control objects is greater than tens of kilometers, the use of local area networks is expensive and time-consuming, so it is not feasible. The measurement and control system composed of existing telephone networks, modems and computers can basically realize remote measurement and control management functions in places where the communication rate and real-time requirements are not high, and it is low-cost and has a short preparation period for use.
2. System structure
This system is designed for monitoring unmanned telecommunication room environments. The system host computer uses a microcomputer as the main control room monitoring host, and the lower computers are multiple measurement and control terminals distributed in various rooms.
The lower computers distributed in each computer room monitor the computer room environment parameters in real time, collect and store data, and upload data regularly; when connected point to point, the current status can be queried in real time. In order to facilitate the management of the lower computer, the lower computer needs to have an online control function, and all the parameters of the lower computer can be modified and controlled through the PC upper computer software of the monitoring center. Multiple lower-level measurement and control platforms transmit data with the upper computer through PSTN. Data interaction and fault alarm between devices all require reliable data transmission. Therefore, the reliability of the lower computer hardware and the reliability of the data communication link layer are crucial. The frame structure of the data and the software and hardware of the Modem control interface need to be carefully designed. In order to alarm the monitoring parameters in a timely and effective manner, three alarm thresholds with different severity levels need to be set for each monitoring parameter. When a real-time monitoring parameter exceeds the alarm threshold, the lower computer automatically alarms the monitoring center, and can dial three different phone numbers in priority order to notify relevant personnel. A password mechanism is used in the communication data frame. Only when the password is correct, the lower computer responds to the control of the upper computer, ensuring the security of the system.
3. System hardware design
The hardware block diagram of the lower computer is shown in Figure 2. The Philips 32-bit microprocessor LPC2132 based on the ARM7TDMI core is used, which integrates 16K SRAM and has 128k bytes of embedded high-speed FLASH memory. Rich on-chip peripherals, very small packaging and extremely low power consumption, without external program memory and data memory, make it very suitable for miniaturized embedded fields. The amount of data collected by the system each time is small, and it is not appropriate to upload it to the upper computer once it is collected. For this reason, the power-off non-volatile EEPROM 24C256 is used to store the collected data. The analog signal is collected through the l0bit serial AID TLC 1543, and its 11 channels can be used to collect parameters such as power supply voltage, current, and room temperature of the equipment in the computer room. The switch signal is read directly from the GPIO (General purpose I/0) of the microcontroller, and the control signal is output to the 74HC595 through the SPI serial port and converted into a parallel control signal output. The key tone is obtained through the DTMF decoder MT8870 to obtain the key value for alarm phone confirmation.
The external modem is connected to the processor through the RS-232C port. LPC2132 has two serial ports with 16-byte transceiver FIFO. Among them, Uart2 adds a modem interface with RTS, CTS, DSR, DCD, DTR, RI standard RS-232C interface handshake signals. Modem and microcontroller need at least three signal lines: TXD, RXD and SGND to achieve two-way communication. Since there is no handshake signal, this connection can only guarantee the reliability of single byte transmission. For the transmission of large amounts of data, data loss may occur. Although software processing can be used, it will take up CPU time and reduce CPU efficiency. Therefore, Uart2 is connected to the modem through the 8-way level conversion chip MAX3238, so that it has a complete RS-232C control communication signal line, which ensures the reliability of large data transmission.
4. Data frame encoding method
The principle of data frame coding is to minimize the bit error rate during data transmission, taking into account other aspects such as transmission efficiency and encryption. The data frame structure of this system is shown in Figure 3.
Figure 3 Data frame structure
The first and second bytes (packet header) and the last byte (packet tail) of the data frame use specific start codes and end codes, such as AAH, 55H, B5H, etc., which can effectively suppress various messy information. The data receiver can put the received data into a FIFO buffer. When a valid packet header is received, it starts receiving a data frame. Otherwise, it is considered to be interference or error code and discarded without processing. After the data frame starts to be received, it is considered a valid data frame only if the end code can be received correctly according to the data length. Otherwise, it is discarded and starts again to wait for the start code. The start code is followed by one or more passwords, which can be determined according to actual needs to increase the confidentiality of data transmission. [page]
The transmission of data often has bytes set to 0 continuously. This zero level is very easy to be interfered with and turned into other data during the transmission process. Therefore, the data is encoded in the remainder 3 mode. Parity check is applied to each byte of the data frame, and the cumulative sum and XOR sum of all data bytes are calculated and placed in the data frame for verification by the receiver.
5. Modem control and AT command set
Currently, the common modems on the market all support the AT instruction set, that is, all command lines are composed of the prefix "AT", which is the abbreviation of Attention. Its basic format is: AT command [parameter] command [parameter] ... terminator. The terminator is a single character, and its value is stored in register S3. The default is the carriage return character. Multiple commands can be included in a command line, but the number of characters that cannot be accommodated in the command buffer of the modem is generally 40 characters. The modem will automatically detect the baud rate, word length, and parity check from the two characters of AT, so the modem does not need to set these parameters.
The working state of the modem can be divided into command state and online state. In the command state, AT commands are received and executed. When the communication link is established, the modem enters the online state. At this time, the modem no longer interprets the data sent to it, but directly sends it to the remote receiving system. In the online state, if the state conversion sequence "++++" is received, it will enter the online command state. For a detailed introduction to the AT command set, see.
6. System software design
The LPC2132 microprocessor can operate at a frequency of up to 60MHz, has a 3-stage pipeline, and most instructions can be completed in a single cycle. It has 128KB FLASH program memory and 16KB SRAM on the chip. Its performance and storage space make the application of embedded operating systems possible. Currently, large-scale commercial embedded operating systems on the market are very mature, but expensive. Using free software with open source code is a good choice. uClinux is powerful and stable, but the code and required RAM are too large. uC/OS-II is simple and practical, and the kernel can be trimmed to only about 3K. The software of this system is based on the uC/OS-II embedded operating system, which is an ideal choice.
uC/OS-II is a preemptive real-time multitasking operating system with fully open source code, which is portable, curable and customizable. Up to 64 tasks with different priorities can be executed simultaneously. The communication and synchronization between tasks are completed through semaphores, mailboxes or queues. Semaphores are used to protect specific shared resources or synchronize other tasks. Mailboxes and queues are both used to send messages between tasks, but the former can only send one message, while the latter can send multiple messages. uC/OS-II requires a system clock (Clock Tick) to implement time delay and timeout confirmation. The higher the clock beat, the higher the system time accuracy, but the greater the system overhead. For detailed introduction, see the literature.
Under the management of the uC/OS-II operating system, this system is divided into 4 tasks:
Task 1: Collect and store data regularly. According to the collection frequency set by the host computer, collect and store various monitoring parameters regularly.
Task 2: Data frame processing, interpreting the data received by the serial port. After receiving a data frame with correct verification, perform corresponding operations, such as processing the control information of the host computer, setting system parameters, sending semaphores to other tasks, and sending correctly received response frames.
Task 3: Alarm task, real-time monitoring of various parameters, immediately reporting to the host computer when an abnormality is found, and making a call to the alarm.
Task 4: Automatically upload data. When a certain amount of data is collected, it is automatically uploaded to the host computer.
In a multi-task system, a periodic task interrupted by a clock is executed once at a certain time, and is in a dormant state at other times. If it is at the highest priority among all tasks, the strict time validity of the task can be guaranteed. Task 1 is such a task, so it is placed at the highest priority. It runs once at a certain time, that is, collects and stores data once, and is in a dormant state at other times.
In the process of communicating with the host computer, Task 3 and Task 4 both need the data frame processing task to interpret the data sent by the host computer, so Task 2 is the second priority. When the serial port interrupt receives the data sent by the host computer, it is put into the FIFO queue and a signal is sent to Task 2. When Task 1 is not executed, Task 2 immediately becomes the current running task and processes the data received by the serial port. It is in a waiting state at other times.
Automatic data upload does not require high real-time performance, so it is placed at the lowest priority. The alarm task is placed at the third priority, which can ensure that when an abnormality occurs, the upper computer and relevant personnel can be notified in time.
In a multi-task system, the protection of shared resources must be considered. Only one task can occupy this resource at the same time. In this system, the serial port is a resource that all four tasks need to occupy to control the Modem or transmit data to the host computer. The I2C bus is used to read and write monitoring data in the EEPROM in Task 1 and Task 4. Therefore, two mutually exclusive semaphores are established to protect the serial port and the I2C bus. When a task needs to use the serial port or the I2C bus, it first applies for the semaphore of the corresponding shared resource. If the signal has been occupied by another task, the task has to be suspended until the signal is released by the current user.
Arranging multiple tasks in this way fully utilizes system resources and ensures the coordinated and efficient operation of all tasks in the entire system and the real-time performance of the system.
7. Summary
After actual operation test, the system runs stably and reliably. The adoption of fully open UC/OS-II embedded operating system and multi-task management improves development efficiency, shortens development cycle and improves system performance. When upgrading the system, functions can be expanded by adding other tasks to the operating system, and the program has good readability and maintainability. The embedded system based on ARM7 and uC/OS-11 has a simple and compact structure, low cost and strong real-time performance, and is particularly suitable for the development of small and medium-sized embedded systems.
Previous article:Design of CAN/PCI Intelligent Communication Card Based on ARM Controller LPC2294
Next article:Field Oriented Control of Brushless Motors Using an ARM7 Processor
Recommended ReadingLatest update time:2024-11-16 15:40
- Popular Resources
- Popular amplifiers
- Mission-oriented wireless communications for cooperative sensing in intelligent unmanned systems
- Practical Deep Neural Networks on Mobile Platforms: Principles, Architecture, and Optimization
- ARM Embedded System Principles and Applications (Wang Xiaofeng)
- ARM Cortex-M4+Wi-Fi MCU Application Guide (Embedded Technology and Application Series) (Guo Shujun)
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- Innolux's intelligent steer-by-wire solution makes cars smarter and safer
- 8051 MCU - Parity Check
- How to efficiently balance the sensitivity of tactile sensing interfaces
- What should I do if the servo motor shakes? What causes the servo motor to shake quickly?
- 【Brushless Motor】Analysis of three-phase BLDC motor and sharing of two popular development boards
- Midea Industrial Technology's subsidiaries Clou Electronics and Hekang New Energy jointly appeared at the Munich Battery Energy Storage Exhibition and Solar Energy Exhibition
- Guoxin Sichen | Application of ferroelectric memory PB85RS2MC in power battery management, with a capacity of 2M
- Analysis of common faults of frequency converter
- In a head-on competition with Qualcomm, what kind of cockpit products has Intel come up with?
- Dalian Rongke's all-vanadium liquid flow battery energy storage equipment industrialization project has entered the sprint stage before production
- Allegro MicroSystems Introduces Advanced Magnetic and Inductive Position Sensing Solutions at Electronica 2024
- Car key in the left hand, liveness detection radar in the right hand, UWB is imperative for cars!
- After a decade of rapid development, domestic CIS has entered the market
- Aegis Dagger Battery + Thor EM-i Super Hybrid, Geely New Energy has thrown out two "king bombs"
- A brief discussion on functional safety - fault, error, and failure
- In the smart car 2.0 cycle, these core industry chains are facing major opportunities!
- The United States and Japan are developing new batteries. CATL faces challenges? How should China's new energy battery industry respond?
- Murata launches high-precision 6-axis inertial sensor for automobiles
- Ford patents pre-charge alarm to help save costs and respond to emergencies
- New real-time microcontroller system from Texas Instruments enables smarter processing in automotive and industrial applications
- 【micropython】Bluetooth module has been added to ESP32
- 97% off e-coins (can join in group)
- LED Art: Halloween Badge
- How to continue working if you modify socket parameters during operation without restarting
- EEWORLD University - UCOS operating system foundation of the Internet of Things
- Smart module PIP keyboard to set real time clock
- Innovate, accelerate and connect across every band and protocol with the SimpleLink MCU platform
- Disassemble the original Keil artifact DSTREAM
- There is no one to teach me how to learn FPGA. Can I learn it just by watching tutorials?
- Brushed DC and brushless DC driver chips