Design of dual DC motor control system based on DSP

Multi-motor control systems are widely used in actual production and life, such as lifting stages, robots, printing systems. This paper through serial communication between PC and DSP, dual DC motor control system consisting of PC as the host computer, DSP as the lower computer with synchronous PWM speed regulation, commutation and selection functions is designed. It sends digital control instructions with host computer serial debugger to lower computer, to instruct the motor to complete corresponding actions. The hardware and software design of the control system are given, and feasibility and validity of the control system are verified by experiments. The expected design goal is achieved.


Emulator Selection
The control system adopts Fourier electron XDS510V2 Emulator, which uses high-speed version USB2.0 interface supporting plug and play, with transmission speed up to 480MB/S; supports TI's C2000, C5000 full range of DSP and C6000 part model of DSP; adopts standard JTAG emulation interface, to avoid taking up user resources. The emulator is connected with the JTAG port on the DSP chip. The USB port of the emulator is connected with that on PC. By connecting PC and DSP with the simulator, on-line debugging of control system program can be done in CCS3.3 [6].

DSP Chip
The control system uses TMS320F2812 DSP as the main controller. TMS320F2812 is TI's 32-bit fixed-point DSP chip, which is currently one of the most cost-effective DSP chips. It not only has strong digital signal processing capabilities, but also has relatively complete event handling capabilities and embedded control capabilities [7]. DSP chip uses the advanced Harvard bus structure, in which the program and data are placed in different storage space to greatly improve DSP data processing rate [8]. CPU basic frequency is up to 150MHZ, the clock period is 6.67ns; the chip contains 18K RAM and 128K Flash. The chip also contains a wealth of peripheral resources, greatly reducing difficulty of hardware circuit design. In particular, two event manager modules EVA, EVB can produce 4 independent PWM waveforms and 6 pairs of 12 complementary PWM waveforms, which is very suitable for control of various types of motors [9]. Meanwhile, programming is compatible with C/C ++ language and assembly language.

Motor Driver
The motor driver is an important component that drives the motor to complete acceleration, deceleration, and braking, coasting plus positive and negative rotations. The system uses a dualchannel DC brushed motor driver which has a continuous output capacity of 12A current per channel, can drive DC motor of up to 290W electric power, has built-in overvoltage, undervoltage, overheat protection circuit to support full duty cycle input. In order to reduce and lower the impact of drive circuit on the entire control system and enhance security of the main control chip circuit, optocoupler isolation chip HCPL0630 is used for optical isolation of all the control signals input by DSP, and the optoelectronic device can significantly improve electromagnetic compatibility of the system; H bridge circuit consists of four N-channel enhanced AON6504 field effect tubes, drain source voltage of AON6504 field effect tube can reach 30V, gateup to 85A. DSP -driver connection is shown in Figure 2 The motor operation logic is shown in Table 1. Wherein, x can be 1 or 2, H is high level, L is low level, X means independence of level, and Z is high impedance state.

Communication Circuit Design
In order to realize instruction digitization of dual DC motor speed regulation, steering and selection control system, this paper establishes communication module of PC and lower computer. The serial communication port is an asynchronous serial communication interface with two signal lines [10]. The serial communication driven by MAX3232 chip conforming to RS-232 standard has two receiving and transmitting channels [11]. Serial communication interface circuit is shown in Figure 3, JP3 corresponding to SCIA serial communication interface is used for DC motor speed regulation and commutation; JP4 corresponding to SCIB serial communication interface is used to select the DC motor used.

Control System Software Design
Control system program includes initialization program, the main program, SCI serial communication program and motor control program. The initialization program is used to initialize the various function modules and global variables involved in the system. SCI serial communication program mainly consists of initialization function, receive interruption function of motor speed regulation and commutation data, receive interruption function of selection motor data. The motor control program mainly consists of motor PWM speed regulation program, motor steering adjustment program and selection motor program. The control system flow chart is shown in Figure 4. All the programs in the system are written in CCStudio v3.3 software, each module in CCS3.3 has its own fixed programming template, and each peripheral has its corresponding sub-function module. In programming, one only needs to modify or add corresponding code in the corresponding template.

Serial Communication Program Design
The serial communication program is used to receive the data sent by PC through serial port debugger and assign the received data to the corresponding global variable to realize speed regulation, commutation and selection of dual DC motor [12]. The system uses interrupt way to achieve data acceptance. When the data sent by host computer through the serial debugger reaches SCIRXDX pin, SCI starts to detect the start bit of the data and moves the data bit by bit into RXSHF register. When the RXSHF register receives a complete data and sends the data to receive data buffer SCIRXBUF, flag bit RXRDY is set, and generates a request interrupt to receive data. If the corresponding interrupt enable bit is enabled, it will generate SCI receive interruption. Serial communication initialization function makes corresponding configuration of SCIA, SCIB, so that it can achieve communication and data acceptance between PC and DSP. SCIA serial port is used for motor speed regulation and commutation data acceptance, while SCIB serial port is used for selection motor data acceptance. SCIB communication data format is set to baud rate of 19200, data bit of 8, no polarity check and stop bit of 1; SCIB communication format is set to baud rate of 9600, data bit of 8, no polarity check and stop bit of 1. When configuring serial debugger parameters, they must be exactly the same as the corresponding SCI module settings. Speed regulation and commutation data receive interruption function receives the data sent by the host computer serial debugger through com2 serial port, and stores the received data in the array Scia_VarRx[i]. Scia_VarRx[0] to Scia_VarRx [3] data in the array are used for motor speed regulation, while Scia_VarRx [4] and Scia_VarRx [5] data are for motor commutation. Hence, the data sent by speed regulation and commutation serial port debugger each time is 6-bit decimal number. The first four digits of the array are combined and assigned to compare registers of the timers T1, T2 through intermediate variable CMPW_PWM. The last two digits of the array are combined and assigned to compare control register ACTR of EVA through intermediate variable PWM_DIRECT. Selection motor data interrupt function receives the 2-bit hexadecimal data sent by host computer serial port debugger through com3 serial port, stores the data in SCIRXBUF, and assigns it to compare control register ACTRB of EVB through intermediate variable choose.

Motor Control Program Design
The motor control program includes motor PWM speed regulation program, motor steering adjustment program and selection motor program. The system regulates motor speed by changing armature voltage at both ends of DC motor, that is, it regulates speed by changing DSP output PWM waveform duty cycle. This method can achieve inorganic speed regulation of motor and belongs to constant torque speed regulation. The motor commutation changes motor control logic input through forced level of PWM1, PWM2 output pin level, to achieve motor commutation. Selection motor is achieved by selecting conduction motor drive signal with PWM7, PWM8 output pin level. The motor speed regulation program mainly configures the timer T1 and T2, and sets T1 and T2 to continuous up / down counting mode in the initialize EV function. T1PWM and T2PWM output polarity are set to active low; In this system, PWM waveform frequency is set to 18KHz to reduce current noise during motor driver operation; To change the value of TxCMPR in real time (i.e., to change duty cycle of PWM waveform), TxCMPR heavy load condition is set to load immediately. In order to achieve simultaneous change of two PWM waveform duty cycles, values of compare register T1CMPR, T2CMPR are determined by the value of variable CMPR_PWM. The motor commutation program is to configure output polarity of DSP output pins PWM1 and PWM2, of which, PWM1 and PWM2 are PWM function pins. PWM1, PWM2 output polarity is achieved by changing the value of comparison behavior control register ACTRA. Selection motor program makes appropriate configuration of timer T3, sets PWM7, PWM8 to PWM function pin, and output polarity is decided by the value of compare control register ACTRB.

System Testing
According to the above design, hardware connection diagram of the control system is built as shown in Figure 5. The system provides that data sent by motor speed regulation and commutation serial port debugger is 6-bit decimal number, while data sent by selection motor serial debugger is 2-bit hexadecimal number. The selection motor control word and motor running status are shown in Table 2.      First, "0F" is sent by selection motor data transmission window as shown in Fig.7, and the selected motor is M1, M2. After SCIB data receive interruption receives "0F", the global variable value related to the selection motor is shown in Figure. 6. Then, "051203" is sent by motor speed regulation and commutation data transmission window shown in Figure. 8. At this time, the two DC motors are in positive rotation and the rotation speed is 1/2 of that under rated voltage. After SCIA data receive interruption receives "051203", the global variable values of motor speed regulation and commutation are shown in Figure. 9. The PWM waveform output by T1PWM, T2PWM pin on DSP development board that is measured by oscilloscope is shown in Figure. 10, in which, yellow waveform is T1PWM wave, blue waveform is T2PWM wave. It can be seen from the figure that PWM wave duty cycle is 49.27%. And voltages at both ends of M1, M2 motor measured by multimeter are12.47V, 12.49V respectively at this time.

Concluding Remarks
A dual DC motor control system with functions of dual DC motor speed regulation, steering and selection was constructed using TMS320F2812 DSP development board and motor driver, which not only simplifies the system structure, but also achieves digital control of the motor with host computer