Design of Intelligent Surveillance System Based on Wireless Video Transmission and PID Multiplexed Control Strategy

A kind of wireless video transmission intelligence surveillance system is developed to perform work normally done by human being in hazardous environment, narrow space, as well as chemical and toxic places. This system consists of two main parts: a host computer with monitoring software and a mobile intelligent vehicle. The host computer software can provide real-time display of video, temperature, humidity, light intensity and other environmental information collected by the intelligent vehicle, and can control the movement direction, movement speed of the intelligent vehicle as well as the camera platform angle with control buttons. The vehicle can collect images and sensor data, and transmit them to the host computer via wireless fidelity(WIFI). The speed of intelligent vehicle is regulated by joint control of position type proportion integration differentiation(PID) and bang-bang control strategy. The video is captured by universal serial bus(USB) interface camera, and transmitted to the host computer by WIFI for real-time display. The testing results show that the system can not only display clear video images, but also accurately display the dynamic data of sensors, at the same time, the host computer can reliably control the multi directional movement, grabbing obstacles and changing camera platform angle of the intelligent vehicle.


INTRODUCTION
Intelligent surveillance vehicle, which integrates embedded technology, sensor technology, electronics appliances, route planning, artificial intelligence, automatic control and other technologies, belongs to the category of robot.It has found wide applications in automatic driving, anti-terrorism, nuclear power plant maintenance, unknown area detection and unmanned engineering product transportation.In narrow space, toxic area or hazardous area, the intelligent surveillance vehicle can replace human being to perform dangerous work.It can take close-up photos and send them to surveillance video [1,2].The operator, in the meantime, only needs to control the movement of the intelligent vehicle via PC, mobile, tablet computer or other portable equipments.For example, the intelligent vehicle can get on top of the suspended ceiling, and the operator, using the host computer, can control the intelligent vehicle to arrive at the location to be inspected, and can control remotely on the host computer screen.The sensors can also send environmental data like temperature and humidity, so as to help find the failure location faster.
The wireless mobile robot developed by IAN FAKYILD-IZ can capture static images in the environment [3].This system uses Logitech Company's mobile robot as a chassis, *Address correspondence to this author at the School of Computer and Information Engineering, Luoyang Institute of Science and Technology, Luoyang, Henan, 471023, China; Tel: +86-379-65928128; Fax: +86-379-65928000; E-mail: 65929101@163.comand is equipped with Logitech Pro 4000 network camera.The camera, with a resolution of 640×480 can transmit image information at 15 frames per second in QCIF format.In China, though the researches on wireless image transmission technology started late, they have been developing rapidly in recent years, and some fruitful achievements have been attained.Using GPRS module as terminal for wireless data transmission, the camera is capable of transmitting video at a speed of 5 frames per second.When the image is of 128×96 pixels, the transmission is smooth, but when the image is increased to 320×240 pixels, there will be some delay in transmission [4][5][6][7].
This paper designs a low-cost and highly stable system capable of video transmission, environmental temperature and humidity monitoring, as well as speed control of intelligent vehicle.This system adopts WIFI with strong antiinterference ability to transmit data.Closed loop PID and Bang-Bang composite algorithm are used to precisely control the vehicle speed.As the system needs a wireless network to achieve duplex communication between the host computer software and intelligent vehicle, a communication protocol has to be defined.The data to be transmitted include video images, sensor data, intelligent vehicle control data, and intelligent vehicle auxiliary system related data (lighting, obstacle avoidance, protection).All the hardware circuits designed with printed circuit board in order to improve the reliability and stability of the whole system.

OVERALL DESIGN OF THE SYSTEM
The movement of the intelligent vehicle is controlled through the host computer software, and the video and sen-sor data from the intelligent vehicle can be displayed on the host computer.The system consists of main control module, sensor module, power module, motor drive module, camera module (including camera platform) and host computer software.
The main controller, through receiving the control instructions from the host computer, realizes the control on the movement of the intelligent vehicle.The video images captured by the universal USB interface camera are transmitted through the USB interface to the WIFI module, which then transmits them to the host computer for display.The core processor of the sensor module is STC89C52, which acquires the sensor data and calculates the final results.The calculation results are then transmitted to the main processor STM32F103ZET6, which then sends the data to the host computer software for display.The motor drive module includes full bridge circuit which consists of two BTS7960.One PWM pulse is used to control the motor speed, and one common IO is used to control the normal/reverse movement.The overall system block diagram is shown in Fig. (1).
With the advent of the Android system, intelligent mobile phone and tablet computer are becoming more and more popular.And the intelligent machine has been developed from single core to dual core and now quad core, each with higher calculation speed.All these intelligent machines are equipped with WIFI device, so using them as the control terminals for the proposed system will make the operation more convenient and simple.

DESIGN OF INTELLIGENT VEHICLE CONTROL SYSTEM
The intelligent vehicle is jointly controlled by the main controller STM32F03ZET6 and the auxiliary controller STC89C52.The block diagram of the whole hardware system is shown in Fig. (2).Fig. (2) shows the connection between the MCU and each module, the STM32F103VET6 main control chip serves as the core of the whole system, which controls each module, and thus helps the whole system fulfill its functions.As a variety of sensors are used in the system, and the data from the sensors need to be detected on a real-time manner, the frequency of the controller shall be super high.Moreover, the control over the DC gear motor shall be realized through the driving chip BTS7960, and the maximum output current is up to 43A, so the control chip needs at least 4 PWM output.For these reasons, STM32 is chosen as the main control chip, and the less costly STC89C52 is chosen as the controller for the sensors.

DESIGN OF INTELLIGENT VEHICLE CONTROL SOFTWARE
The design of intelligent vehicle software mainly includes sensor module software, main controller software and host computer software.The three modules, which communicate with each other using self-defined protocols, jointly carry out all functions of the whole system.
When the system is on power, the main controller and sensor modules will start to work at the same time, and the main controller will first initialize three timers.One timer can interrupt for every 1ms to generate basic clock.The oth-er two timers can generate PWM pulses of 50HZ, which will be used to control the servo motor and DC motor.Then enter the system's main loop, and the system protection program will be run first, which will check whether or not the system is at normal condition, and whether there is any obstacle within the safety range.If any obstacle poses a threat to the intelligent vehicle, the obstacle avoidance protection will be activated.At the same time, the sensor module will start to read sensor data and store the calculation results in the buffer cache.Upon the request of the main controller, a frame of sensor data will be sent to the main controller, which, after receiving and processing the data from the sensor module, will send the sensor data to the host computer software for display.The basic work scheme of the main controller is shown in Fig. (3).

Design of Host Computer Software Interface
The host computer software is an essential part of the system, which is designed to fulfill many functions, including intelligent vehicle movement control, camera platform angle control, display of video images, sensor image display, etc. [8][9][10].The host computer software interface is shown in Fig. (4).

Host Computer Software's Control on Intelligent Vehicle Movement
The host computer software controls the direction and speed of intelligent vehicle.

Direction Control
To control the direction of intelligent vehicle is to control the steering motor.The host computer software sends the angle value of the steering motor via WIFI to the lower computer, which then makes the steering motor rotate at such angel, thus the movement direction of the intelligent motor can be controlled.
Communication protocol between host computer software and lower computer is developed to distinguish the instructions sent from host computer software to lower computer about intelligent vehicle direction control from those about camera platform control and intelligent vehicle speed control.When sending the control instructions on direction, the host computer first sends the beginning of the frame 0x44, which signals that this frame is for the control on intelligent vehicle direction.Then the second byte of data is sent; if it is 0x44, it means the intelligent vehicle will go forward or go backward or stop.Whether it is to go forward, go backward or to stop is determined by the data in the third byte: 0x31 means go forward, 0x32 means go backward, and 0x32 means stop.If the second byte is 0x4c, it means the intelligent vehicle will go left, which includes left front, left and left rear.If it is left front, the angle can be adjusted, and the angle will be 10 degrees greater for each click on the button.If it is left, the intelligent vehicle will turn left at a fixed angle of 45 degrees.Left rear is the opposite of left front, and only the vehicle will move toward left rear.After the second frame of data is received, the third byte of data will determine left front, left or left rear.If the second byte data received is 0x52, it means the intelligent vehicle will go right front, right or right rears, which are opposite to turning left, and the third byte will decide right front, right or right rear.With the above described instruction protocol on direction control, the host computer software can control the intelligent vehicle direction with push buttons.

Control on Intelligent Vehicle Speed
Both the host computer software and the lower computer can regulate the speed of the intelligent vehicle.The host computer can send the set value of the intelligent vehicle speed to the lower computer, for example, if the speed value sent to the lower computer by the host computer software is 200, it means the intelligent vehicle will travel at 2m/s.After receiving the set speed value, the lower computer will send the set value to PID regulator, which will control the motor control PWM duty ratio, thus control the DC motor speed and the intelligent vehicle speed.
The frame data from host computer software to lower computer begins with 0x50 and ends with 0x00, which means this frame data is instruction on the intelligent vehicle speed.The frame length is 3 bytes, and the second byte is the set speed value.The host computer software has 5 set speed values, namely, 0m/s, 1m/s, 2m/s, 3m/s and 4m/s.In addition, the scroll bar on the left can also be used to set other speed values.

Host Computer Software's Control on Camera Platform
The camera platform is used to regulate the angle of the camera.And control on the camera platform includes horizontal direction control and vertical direction control.
The host computer's control frame on camera platform is three bytes frame, where the first and the second byte are both 0x53, which means the control frame is camera platform control data.
The direction of the camera platform is controlled by 9 buttons.If the "camera up" button is pushed, the host computer software will send camera platform control data frame to lower computer.The first two bytes of the data frame are both 0x53, and the third byte is 0x31.Upon receiving the data frame, the lower computer will control the vertical steering motor of the platform.For each click on the "camera up" button, the vertical steering motor will raise the camera for 10 degrees, the more clicks, the bigger angle.For "camera left", "camera right" and "camera down", push the corresponding button, the host computer software will send control data to lower computer accordingly, and the control method is same as "camera up".The four buttons with "upper left", "bottom left", "upper right", "bottom right", are respectively for the direction of upper left (45 degrees on horizontal direction and 45 degrees on vertical direction), bottom left, upper right and bottom right.These four buttons cannot adjust the camera angle continuously; click on one of these four buttons will turn the camera to the direction immediately.To make the steering motor move continuously, use "camera up", "camera down", "camera left" and "camera right".

Sensor Data Display on Host Computer's Software
The sensors of this system include temperature sensor, humidity sensor and lighting sensor, so the host computer software need to display temperature, humidity and lighting data.On the upper right of the host computer software, there are 3 TEXBOX, which can give dynamic display of temperature, humidity and lighting data.
The lower computer gathers data via sensor module, and then the main controller reads the sensor data from the sensor module and transmits them to WIFI module via serial port.The sensor data is transmitted to host computer software by the WIFI module.The transmission of sensor data and video data is via the same data flow.The transmission of sensor data to host computer is divided into two steps.The first step is to send four bytes of data which means that the length of data to be sent next is only three bytes, namely, temperature, humidity and lighting, so the value of the first four bytes is 3.After receiving the first four four-byte data, the host computer will read three data of three byte length continuously from the data flow, and display them in corresponding area, thus achieving the display of sensor data.The sensor data do not need to be separated, because the sensor data is integrated data.Analysis shows that the sensor data will not overflow, so three-byte data can meet the requirements of this system.If accurate sensor data is needed, we only need to change the data length of the first four bytes.

Video Image Display on Host Computer's Software
There is no extra processing on the video data, and the video data is transmitted directly from the camera module to the WIFI module, and then sent to host computer software by the WIFI module.The transmission of video data is divided into two steps.First, four bytes of data will be sent, indicating the length of the following data to be sent.Then the host computer software will read data of the same length from the data flow, and display on the host computer software.The volume of the first four bytes is much larger than sensor data, because the volume of video data is very large, so the host computer can distinguish sensor data and video data.Some important codes of the host computer are as follows.

CONTROL STRATEGY DESIGN
The system adopts the relatively mature PID control algorithm to control the intelligent vehicle speed.The speed control system is a complete closed loop control system, which can make the intelligent vehicle to travel at a set speed.

Combination of PID Control and Bang-Bang Control
The intelligent vehicle has great inertia when just started and in emergency brake, so it will be difficult if only simple PID is used in the design of the system, and the parameters are not likely to be adjusted to a satisfactory value [11][12][13][14][15]. Therefore, the system combines PID control algorithm and Bang-Bang algorithm.When just started and in emergency brake, the controller will use Bang-Bang algorithm, after started and when the speed is within a certain range, PID regulator will be used to stabilize the vehicle speed at a set value.The schematic diagram of the speed control algorithm is shown in Fig. (5).
In Fig. (5), R(t) is the set speed for the intelligent vehicle, e(t) is the difference between the set speed and the real speed.The feedback in the diagram is the real speed measured by the encoder.The difference e(t) is then sent to the proportional, integral and differential link by the controller, the final output is u(t), and the object to be controlled is DC motor, u(t) is the PWM pulse duty ratio sent to DC motor.

The Testing Results and Analysis
The system directly adopts Bang-Bang control algorithm, and the intelligent vehicle speed control waveform is shown in Fig. (6).
In Fig. (6), the blue curve is the difference between the intelligent vehicle set speed and real speed, e.g., the input difference e(t) of the controller, the red curve is the real speed of the intelligent vehicle, the green curve is the controller output.As is shown in Fig. (6), when there is step signal from the controlled value, Bang-Bang controller will give control signal immediately, and the controlled value will respond quickly.Then the system gives stable control signal, and the system enters next stable condition.It can be seen from Fig. (6), Bang-Bang control alone cannot avoid stable condition error, and therefore, this algorithm cannot be used alone even though it is fast in responding and stable.
In order to keep Bang-Bang algorithm's advantage of fast responding and stability, and at the same time resolve its problem of stable condition error, this system combines Bang-Bang control with PID controller.When just started and in emergency brake, the controller will use Bang-Bang algorithm, after started and when the speed is within a certain range, PID regulator will be used to stabilize the vehicle speed at a set value, and keep it that way until the set speed changes.In this way, the system responds faster and is more stable, and it can also eliminate stable condition error.
First, reset integral and differential coefficient, and retain only the proportional coefficient.Let the system work only under the proportional control, increase the proportional coefficient slowly until fluctuation occurs in the system, and see (Fig. 7).
In Fig. (7), the blue curve is the difference between the intelligent vehicle set speed and the real speed, e.g., the input difference e(t) of the PI controller, the red curve is the real speed of the intelligent vehicle, and the green curve is the P controller output.As is shown in Fig. (7), when there is step signal from the controlled value, difference will occur immediately.P controller will send control signal under the proportional impact.Under the regulation by P controller, the controller value will fluctuate slightly, but since the proportional cannot eliminate stable condition error, there is still stable condition error after the system is stabilized.
Record the current proportional coefficient, and reduce to two thirds of its value, engage integral item and keep the    Then adjust the proportional coefficient properly, and stabilize the system to the largest extent.At this time the regulation is slow for the lagged system, and the system needs some time to stabilize (See Fig. 8).
In Fig. (8), the blue curve is the difference between the intelligent vehicle set speed and the real speed, e.g., the input difference e(t) of the PI controller, the red curve is the real speed of the intelligent vehicle, and the green curve is the PI controller output.Compared with the waveform of only proportional regulation, the PI controller with integral control can reduce the stable condition error, but it also brings phase lag.With integral control, the fluctuation is reduced, in order to eliminate the phase lag caused by integral control, differential control in introduced.
As too big a differential coefficient or a too small one can cause fluctuation in the system, the regulation of differential coefficient shall be done slowly.Increase the coefficient slowly, until the response is fast and without big fluctuation.Last, slightly adjust each coefficient and achieve a satisfactory result.The final result is shown in Fig. (9).
In Fig. (9), the blue curve is the difference between the intelligent vehicle set speed and the real speed, e.g., the input difference e(t) of the PID controller, the red curve is the real speed of the intelligent vehicle, and the yellow curve is the set speed for the intelligent vehicle.It can be seen from Fig.
(9) that when step signal occurs in the controlled value, due to proportional impact, PID controller will send control signal immediately.Compared with the waveform in Fig. (8) of only PI regulation, the phase angle is smaller because of the differential impact, which can reduce the lagging of PI regulation to some extent, and the system stability also increases.But it can be seen from the (Fig. 9) that stable condition er- ror still exists in the system.In order to eliminate the error, the integral item has to be changed.The integral item can be used to eliminate stable condition error.

CONCLUSION
Based on computer control, wireless video transmission and sensor detection, this paper developed an intelligent surveillance system, which uses embedded processor as the core, and is featured by low cost wireless video transmission and PID multiplexed control.This system can ensure a high transmission speed, and can transmit large amount of video data to host computer software for display.Moreover, according to the complex external environment, with the data transmission protocol defined, the system adopts WIFI for data transmission, which increases the system's anti interference ability.A simple communication protocol was developed after study on different protocols, which enables the host computer to identify video image data and sensor data.The system constantly adjusts proportion, integral and differential coefficient according to laws, and finds a set of most suitable control parameters, thus to achieve the effective control by PID closed loop system.

Fig. ( 7 )
Fig. (7).Waveform of Fluctuation in Proportional Control.differentialvalue at 0. Increase integral coefficient slowly until long cycle and small amplitude fluctuations occurs.Then adjust the proportional coefficient properly, and stabilize the system to the largest extent.At this time the regulation is slow for the lagged system, and the system needs some time to stabilize (See Fig.8).