Control System Design of a DSP-based Real-time Leveling Platform

Since platform working in the sea is badly influenced by the wave, leveling control system is researched to control the leveling platform, so as to prevent the device which is fixed on the platform from being affected. TMS320F2812 chip is set as the control core, and serial communication module, gyroscope etc. are adopted to design real-time leveling control system. Gyroscopes are used to measure the angular speed of the carrier and the angle of the platform, filtering processing is done to the data collected by the gyroscopes and PID algorithm is adopted to calculate the real-time speed of motor ,in order to control the leveling platform. Tests are conducted to prove that the system can well control the leveling platform, in which the shake range of the platform is -12 +12 ), while the shake range of carrier is only about -0.5 +0.5 ).


Introduction
Leveling platform can effectively isolate the carrier movement, and ensures that the device fixed on the platform can work well without being affected by disturbs.Both in the military field and civilian field, is the real-time leveling platform popular [1] .The platform researched in my paper freely floats on the sea, and it will generate posture deflection under the continuous interference caused by the wave and currents.To provide that the device on the platform can work preciously, we need to insulate the environment disturbs.This paper designs a control program to control the leveling by using DSP, so that we can control the electrical machine to keep the platform stable [2] .

System Function and Project Design 2.1 System functional analysis
The control system of the leveling mechanism contains several functions, such as driving electrical machine, displaying angle status, communicating with sensors and PC, and storing data [3] .According to the system function that we need to realize, we break down the hardware circuit into several different parts and design the parts one by one.The different parts are shown as following: DSP minimum system, motion control module, status display module, communication module, SD card read/write module [4] .

Motion control module
The main job of motion control module is to send signal from TMS320F2812 chip to the servo controller, so as to drive the motor , control the steering , speed, position .And we can control the rolling and pitching motion of platform to reach the dynamic balance of platform and guarantee the stability.There are two event managers (EVA and EVB) in the TMS320F2812.Each event manager is made up of 2 general timer, 3 whole comparing unit , 3 capture unit and 1 orthogonal coded pulse circuit, which can generate four independent PWM waveform and 6pairs of complementary PWM waveform [5] .It is particularly suitable for motor control field.The control of position and speed of motor is realized by using pulse control mode, directly through the DSP to produce PWM wave to control the actuator.The DSP chip communicates with the servo motor actuator through 1 pulse transmit pin, 2 direction pins and 2 receiving feedback pulse pins, thus accomplishes the position and speed of motor control.

Status display module
Status display module is used to remind us of the error which appears in the working process, and it can display angles of deflection Angle and angles of the motor turns.To design the Status display module, we select a relatively common device named HS12864-12, which is one kind of HS12864-15 series produced by HanSheng limited company.The status display module is composed of liquid crystal display, control chip ST7920 and drive chip ST7921.There is word stock inside the device and it can programme, display characters and letters.This module uses standard data and provide control interface and the controller instructions for other devices.When we use it, we only need to write the required controller data into the module's built-in buffer so as to realize its basic function.

Communication module
There are two serial communication interface (SCIA and SCIB) inside TMS320F2812 chip that uses receiving, sending two-wire system [6] .Each SCI has a receiver and transmitter, and each receiver and transmitter which are double buffer are equipped with a 16 FIFO queue so that the SCI can complete half-duplex and full-duplex communication mode.SCI continuous monitors and checks the data received to ensure integrity of the data by checking timeout error and frames error.This paper uses MAX232 to design the RS232 serial communication interface made up of two serial communication interface designed SCIA and SCIB, so that we can realize the communication between DSP and sensors, PC

SD card read/write module
The internal storage space of TMS320F2812 is small, but our sensors will produce a large amount of data when the platform are leveling, including angle, speed and leveling status data.We need these data to analysis the effects of the algorithm, so we need to store the data in the process of research.Here, we choose widely used memory SD card which is a storage device based on semiconductor flash memory device and popular for its small size and large storage.
3 Principle diagram of system and circuit design

Principle diagram of system
Real-time leveling platform sets DSP chip TMS320F2812 as the core, and connects with angle sensor and speed angle through RS232 serial port.After receiving data from the sensors, we will filter the data and get the angle of leveling platform and swing angular velocity.After the data calculated by the DSP chip, we can get motor control signals, including motor rotation angle, direction and speed.The DSP chip will send two lines of the pulse signals which is boosted by the stepdown circuit into the two motor drivers respectively, to drive the motor.And the motor driver will send back the real-time state of motor to TMS320F2812 via step-down circuit.Then, the system gives the following instructions based on the feedback data.PC can be connected to the control system via the JTAG emulator, so as to debug program, download program and observe some data.It can also be connected to the motor driver through RS232 to set the start state of driver and monitoring motor state real-timely.SD card storage module can store sensors measured data, so as to facilitate our debugging for data analysis, and status display module can display the system state of leveling.The figure 1 is the principle diagram.

Step-up and Step-down Circuit
Since the pin voltage of TMS320F2812 is + 3.3 V, the pin voltage of actuator is + 5 V, so we need to design a voltage conversion interface circuit between the two, including step-up circuit while sending signals and stepdown circuit while receiving feedback signals.
The step-up circuit consists of NPN silicon triode, and the base current changes will affect the collector current .Even the base current changes very small, it will lead the collector current change a lot which fit a certain proportion relations.Based on the triode amplifier principle, the circuit can raise the 3.3V signal to 5.0V to drive the motor actuator.The circuit is shown in figure 2.2: PWM1 and PWM2 are the direction signals of rolling motor, and T1PWM is used to control the motor position and speed ;similarly, PWM7and PWM8 are the direction signals of pitching motor, and T3PWM is used to control motor position and speed.
Each motor sends back two-way feedback signal, and the signal was received into the DSP chip to calculate after its voltage was reduced by step-down circuit, to get the motor speed and position.Here , we designs the stepdown circuit for simplification and convenience by adopting resistive subdivision method.Resistive subdivision is often used in weak current that needs to reduce voltage.When determining the divider resistance , we need to follow the wanted current to make sure that the power of the divider resistance fits the maximum power of the circuit to prevent the resistance from burned.As shown in figure 2.3, the circuit reduce the 5V rotating transformer feedback signal to 3.3V.

Status display circuit
Display used in this system adopts the 2-wire serial connection mode, for the aim of reminding us of the operation error and displaying the deflection angle detected by angle sensor and the deflection angle of motor.The connection between display module circuit and DSP chip is shown in figure 2.4.DSP sends data through the SID (serial data input port) to HS12864-12.When serial synchronous clock SCLK is rising , the display module will read the data from SID port.For the mode chosen in the paper is serial mode ,PSB pin should be connected to high level.And VL pin can connect a slide rheostat to adjust the contrast of the screen, which is shown in figure 4. Because this article choose the serial mode, so the PSB directly lead to high level, pick up the VL pin a slide rheostat to adjust the contrast of the screen.Among them, the motion control program can be divided into motor drive module, leveling algorithm and position feedback module.The concrete block diagram is shown in figure 5.

The program design of motion control
Motion control program is mainly used for driving motor, receiving and dealing with feedback data and finishing the leveling algorithm.The motor driver module and position feedback module form the motor position servo control.

Motor driver module program
DSP2812 event manager module is a typical extension function module, especially suitable for motion control and motor control field [7] .Event manager module mainly includes the general timer, comparison PWM unit circuit, the capture unit and orthogonal coded pulse (QEP) circuit.When the motor drive is controlled by PWM pulse the only thing we need to do is to configurate the event manager EVA and EVB.Each general contains four counting modes, including timer continuous incremental, continuous increment / decrement, directional increment / decrement and stop / keep.This article selects the continuous increment / decrement count mode to produce square wave pulse signal, and configurates duty ratio to create the PWM wave that we need.Figure 6 is the program flow char to produce PWM pulse.

Position feedback module program
Feedback data is received into the control system through the orthogonal coded pulse circuit of the event manager.Two feedback signals of each motor are respectively received into the QEP circuit through the two pins of the event manage [8] .After resolving by the decoder of the circuit, we can get the number of motor feedback pulse by using which we can calculate and get the current position, speed of the motor.When QEP circuit is working, the timer works in directional increase/decrease count mode, and the setup program flow chart (figure7) is shown as follows.

Leveling module program
Leveling process mainly includes the speed tracking and position compensation module, and PID algorithm module.In which , the speed tracking program can drive the motor running at the same speed with the swaying platform while in the opposite direction, so as to realize the coarse leveling motion.And the position compensation program can improve the leveling accuracy and reduce the dynamic error [9] .PID algorithm ensures that the motor can respond real-timely and change the motion situation quickly according to the swaying speed of the system.
1) In the speed tracking program, we can calculate the speed PID value after filtering processing the sampling speed, and then we can get the motor speed according to the transfer relationship.According to the motor speed required, we calculate to get the setting value of the event manager cycle register, and then update the cycle register values to control signals of the motor speed.Among them, the motor speed and cycle register values satisfy the following relations: In the relationship, V is the motor speed, NPR is the pulse number required while the motor rotates for a round, CMPRx is the setting value of cycle register, and SYSCLKOUT is the system clock frequency.
The principle of position compensation program is similar as speed tacking program, which converts angle error to the speed of motor.The two program flow is shown in figure 8. 2) PID algorithm is the core of the whole motor driver.It realizes the ability that the motor can change the speed according to the tested real-time data.After filtering processing, the data measured by sensor is calculated by PID algorithm.The percentage deviation is calculated first, and if the ratio deviation is greater than the set value, we conduct the integral and differential calculation.

Test results
When doing the stable tracking test to test the two degree of freedom control performance of the platform, we need to make the platform fixed on the swing platform rotate around its shaft for a degree to simulate rocking movement caused by incident wave of any angle, because our swing device can only provide a degree of freedom.Figure 9 and 10 are the figures of the angle tracking of platform.Figure 9 represents the angle tracking of roll axis while figure 10 represents the angle tracking of pitch axis.Figure 11 and 12 stand for the figures of angle tracking of the device fixed on the platform.Figure11 represents the angle tracking of roll axis while figure 12 represents the angle tracking of pitch axis.
From the figures, we can find that the shake range of the platform is (-12 +12 ), while the shake range of device is only about (-0.5 +0.5 ).The leveling platform can well isolate the shock of the wave.

Conclusion
The control system of a leveling system is designed in this paper to realize the self-leveling of the platform.Both the design of hardware circuit and the software programming are conducted in the event that the TMS320F2812 chip is set as the core, and the test of leveling ability is done finally.The test proves that the control system can well control the leveling platform to perform self-leveling, and insure that the device fixed on the platform can work steadily.The research result provides a general solution for the real-time leveling platform whose swing period is irregular or swing angle is irregular.

Figure 1 .
Figure 1.Real-time leveling control system composition diagram

Figure 5 .
Figure 5. Main body of control system

Figure 6 .
Figure 6.Flow chart of PWM pulse generating set

Figure 8 .
Figure 8. Flow charts of speed tracking module and position compensation module

Figure 9 .Figure 10 .Figure 11 .
Figure 9. Angle tracking of roll axis of the platform