基於 FPGA 的步進馬達驅動器設計 FPGA-based Stepping Motor Drive System Design 賴秋庚廖家宏戴勝淵林宏軒蔡守亮 Chiu-Keng Lai Chia-Hung Liao Sheng-Yuan Dai Hung-Hsuan Lin Chou-Liang ai 國立勤益科技大學電機工程系 Department of Electrical Engineering National Chin-Yi University of Technology Taichung, Taiwan Tel:+886-4-23924505 ext 7207 Fax:+886-4-23924419 E-mail:chiukl@ncut.edu.tw Abstract This work focused on the development of a stepping motor drive system for motion control, and the controller is realized by Field Programmable Gate Array (FPGA). The motion trajectory generated by CAD/CAM system is segmented to be processed by DDA according to the possible acceleration and deceleration rate of the motor drive system. And the stepping motor current regulation can be realized by the pre-programmed velocity profile. The designed system is verified on a 3-axis drive system, and experimental results show that the designed system has got the desired performance. Keywords: FPGA, Stepping Motor Drive, Motion Control. 摘要本研究提出一利用 FPGA 當控制器的步進馬達驅動器系統, 結合 CAD/CAM 系統與人機介面的轉檔程式設計, 將運動控制軌跡依據系統所能獲取的最大加減速進行切割, 並利用 DDA 進行差值控制 馬達驅動器的電流控制則依據規劃的馬達速度進行調變 所設計的驅動系統可以最少的元件以及成本完成所需的系統功能 關鍵字 :FPGA 步進馬達驅動器 運動控制 I. Introduction Motor drive system plays an important role in a high performance motion system. To conduct closed-loop servo control, the motor drive system generally builds in three loops from inner to outer: current loop, velocity loop and position loop, and they correspond to the three control modes: torque mode, velocity mode and position mode. Usually, in CNC system, the current and the velocity loop s computations are completed by a servo drive system; meanwhile, the position loop s computation is completed by CNC motion controller. Thus, in applications, the most common choice of motor drive system nowadays is the position mode. However, for a high response control being considered, the torque control mode can be adopted to speed up the response due to a diminished velocity loop. In CNC motion control, the capability of multiprocessing is important. Due to the sequential processing data flow on commercially available Digital Signal Processors (DSPs) and microprocessors, the increase in sampling rate and the number of output port for high-speed control can impose severe restrictions on the processor performance. Therefore, other alternatives for signal processing must be considered in order to achieve on-line multiprocessing operation. The open structure and high density of Field Programmable Gate Array (FPGA) have made it recently become an alternative solution to the above-mentioned problems. An FPGA provides the advantages over a general purpose processor for its reconfigurable and open structure, its applications go beyond the simple implementation of digital logics, and can be used for implementations of specific architectures in order to speed up some algorithms such as the interpolation and pulse width modulation (PWM). For hardware implementation, it has become more popular for designers to construct high-performance digital signal processing with parallel functions, and provide solutions that may be often 10 times to 100 times faster than can be accomplished with PC or DSP [1]. Therefore, many researches about FPGA-based implementation were thus proposed. For example, the system developed by [2] runs a current control algorithm with a Xilinx FPGA to increase the bandwidth of the current loop control. Tzou and Kuo [3] perform the vector and velocity controls of a Permanent-Magnet AC servo motor by using FPGA. Cho, Le and Jeon [4] present the design and implementation of a multiple-axis motion control chip using an FPGA, and applied it to a multiple-axis motion control system. However, for our proposed system, we focused on not only the multi-axis multiprocessing but also the integration of motion control and motor drive system. It is a successful and especial usage to the application of FPGA on CNC motion control system. We designed the drive system which has simultaneously considered both the motor drive and motion controller. For motor drive systems, ball screw and incremental encoder for rotation type motor, or directly linear motor with optical scale, are used to reach the requirement of high precision positioning. However, to reduce the cost and still retain a reasonably accurate positioning result, the stepping motor drive is an alternative instead of the servo motor with encoder because of the ability of open loop control. To attain the velocity/acceleration/deceleration control with stepping motor drive system, one has the prior knowledge about velocity and acceleration,
(1) T and (2) T where T is the processing period. Thus, for the developed system, the maximum acceleration and deceleration are considered previously, and then the controller of drive system accepts the pulse command made by desired acceleration/deceleration shape, and responds to the motion request. The developed system thus has the character of direct acceleration/deceleration control to improve the motion performance. II. Integrated design of motion controller and motor drive system Usually, the motion controller is a set which is made from one company, and the motor drive system is from another supply. The provider must be requested to offer suitable drive to make the motion fulfill the desired performance. However, a standard motor drive system is equipped with the desired control elements such as encoder, resolver, photo scale, and so on, for position/velocity loop, and hall sensor for current feedback. The two equipments are thus combined to make the motion system and motor drive work properly. For most of the motion system, position mode of driver is set, and two-phase pulse commands are generated to make the motor motion follow the desired path. For our system, however, it has the benefit to reach a fast response than the position control structure because the system is completely controlled by the FPGA system; i.e., including the inner current loop and outer velocity control loop are executed by the FPGA-based controller. The proposed system is finally applied to the caving machine shown in Fig. 1 which is driven by stepping motors and ball screws. practical PCB board for motion controller realized by FPGA and USB is shown in Fig. 3. The original route is generated by CAD/CAM system in the format of G code. Human Machine Interface (HMI) converts the original G code into binary format with velocity/acceleration consideration, and stores the resulting code to the USB flash memory. Motion controller, which is mainly constructed by DDA algorithm, accepts the velocity/acceleration commands from USB bus and sends processed pulse signals to the motor drive system to move the platform. Fig. 4 displays the HMI, it is programmed by Borland C++ builder. Fig. 2. The structure of the proposed motion control system. Fig. 3. The FPGA-based motion control board. Fig. 1. The outline of caving machine. The proposed overall system includes the following parts: G code generation and conversion, USB flash memory for route store, FPGA-based motion controller, keypad for data and functions selection input, LCD monitor for message and control parameters display, stepping motor drive system and 3-axis moving platform. Furthermore, the developed functions in FPGA include the following components: DDA interpolators, velocity/acceleration controllers, PWM control for motor drives. In Fig. 2, the structure of motion hardware system is shown, and the Fig. 4. Human machine interface for code processing.
Fig. 5. The block diagram of FPGA-based motion controller. (rpm) initializes the data transformation procedure, and motion data was sent from USB and accepted by motion controller. After that, the command interpreter in motion controller decodes the command code and decides what action should be taken. As Fig. 5 shows, each of the axes is constructed by 16 bits DDA functionality. Initially, the HMI processed the G code route off line, and segmented them under the consideration of trapezoidal velocity profile as Fig. 6 shows. The system has the highest velocity 300 rpm set, and the operation range is segmented into 6 velocity levels for acceleration and deceleration control. The 16-bit binary control code of each axis has the information that it should be moved in a designated time interval. In here, the time interval, T s, was set as 6 ms, and the binary control code has the format as Fig. 7 shows. Fig. 6. Trapezoidal velocity profile. t 3-2 The Stepping Motor Drive System Design It has the advantage of system driven by stepping motor for the open loop control characters. With the assumption of system moved in faithful following the pulse commands, the drive system speed can be known in advance. The trapezoidal velocity profile used in the experiment is programmed as Fig. 6 shows. The control for current PWM can be completed with the associated acceleration and deceleration setting. The current control algorithm is illustrated as follows: For a general motor electrical model, one has the following equation to describe each of the phases of stepping motor for input voltage e (t) : La dia Raia eb e( t) (3) dt where L a and R a are respectively the phase inductance and resistance; e b is the back emf; i a is the phase current. And the back emf, e b, could be represented as eb K b (4) Fig. 7. The binary code for motion controller. III. FPGA implementation for motion and current controllers The motion control implemented in this work is an FPGA-based system which integrates both the motor drive and motion controller. First, the embedded MCU in USB is triggered by motion controller and feedbacks pulse commands to realize the velocity control with DDA algorithm. Current sensorless controller then manipulates the motor currents to the desired level with PWM algorithm. The block diagram of FPGA-based motion controller is shown in Fig. 5. 3-1 Motion Controller Design In Fig. 5, a motion controller is programmed for caving machine. In the motion system, FPGA-based system where K b is the back emf constant, and is the motor velocity. To manipulate the phase current to the desired level, the external applied equivalent voltage is adjusted according to the motor speed. However, for a sensorless current control algorithm, the feedback signal of phase current is omitted. With the assumption of trapezoidal velocity profile for motion control being in faithful executed, the back emf, e b, could be known in advance with the knowledge of the desired current control level. In the data processing phase of HMI, the motor speed was programmed in advance according to the permitted maximum acceleration and deceleration rate. Thus, we added the motor speed information into the command code to help the execution of open-loop velocity/acceleration control. Digital PWM for current control is thus executed. Fig. 8 shows the designed PCB board for the stepping motor driver. Three hybrid stepping motors were used for the motion platform, and H-bridge driver was adopted to
control the currents and drive the rotor. The PWM waveform for current sensorless control was simulated and shown in Fig. 9, where the motor speed is 50 rpm (speed mode 0001) and OUT_Wave is the result. The signal flow diagram for DDA motion and current PWM control are illustrated in Fig. 10. First, the displacement commands (in here is 3-axis and total 6 bytes) are loaded into the FPGA motion controller sequentially. In each of the command, the desired rotating direction and velocity (displacement) are included. The motion controller separates the rotation direction code from the velocity (displacement) command, and sent them to the rotation direction control, DDA control and PWM control respectively. The rotation control unit decides the direction of motor and generates the pattern to trigger the H-bridge IGBT drive system, DDA unit executes the interpolator, and PWM unit adjusts the motor stator phase current to the desired level with the prior motor speed. For all the system design, the external DC supply for motor drive system is assumed constant. Fig. 10. Command execution flow diagram. Fig. 8. Stepping motor driver board. Fig. 11. The experimental profile. Fig. 9. The simulated PWM signal for current sensorless control. IV. Practical Implementation and Results To verify the proposed structure of hardware system, the profile of Fig. 11 is used to test the system s performance. The original figure size of Fig. 11 is 40 mm by 38 mm, and the converted binary control code has the memory size 534 kb. The trapezoidal velocity profile has shown in Fig. 6 with maximum velocity 300 rpm and maximum 2 acceleration 1046.67 rad / sec. With those settings, the estimated execution time is 6 min. The three stepping motors used in the experiment are 200 steps/rev, and have the parameters La 13. 1 mh, R a 5 and K b 1.2V / rad / sec respectively. And the drivers which are constructed by H-bridge are powered by DC 48V. For the designated velocity profile and the current command 2 A, the results of current control of motor drive are shown in Figs. 12, 13 and 14 respectively. Fig. 12 is the H-bridge four gate driver trigger signals come from the FPGA-based motion controller in the condition of DC 48V power off. It is used to show the triggering sequences from motion controller and the style of PWM for current control. Fig. 13 is the current control results of motor run at various speeds, and Fig. 14 is used to demonstrate the motor operated at reversing. Those show that the performances of current sensorless control have been attained. The proposed motion control system is used to drive the caving machine shown in Fig. 1, and one 15000 rpm spindle is turned on from start to the end to remove the subject. Finally, the caving result on a wood with the desired profile of Fig. 11 is shown in Fig. 15. It shows that the proposed motor motion drive has successfully applied to the developed system. V. Conclusions This paper has demonstrated the motion controller design with FPGA and USB. USB is mainly used as
memory to store the route in binary format, while FPGA-based motion control and drive system accepts the pulse command sent from USB, interprets them, and drives the stepping motors according to the programmed routes. Including the DDA interpolator, trapezoidal velocity/acceleration/deceleration control, PWM current control, etc., are realized by Altera Cyclone II, Type C8 of 208 pins, FPGA, It reveals that the control system is simple, low cost, and high performance. Acknowledgments The authors would like to thank the financial support of National Science Council of Taiwan under grant number NSC-97-2221-E-167-008. They also like to give their deep appreciation to the Chiu Ting Machinery Co Ltd. for the support of prototype caving machine. Fig. 14. The trigger signals and phase currents at reversing. References [1] Y. Tao, H. Lin, Y. Hu,X. Zhang and Z. Wang, Efficient Implementation of CNC Position Controller using FPGA, INDIN 2008, pp. 1177-1182, 2008. [2] T. Takahashi and J. Goetz, Implementation of complete AC servo control in a low cost FPGA and subsequent ASSP conversion, APEC '04, vol. 1, pp. 565-570, 2004. [3] Y. Y. Tzou and T. S. Kuo, Design and implementation of an FPGA-Based Motor Control IC for Permanent Magnet AC Servo Motors, IECON 97, vol. 2, pp. 943-947, 1997. [4] J. U. Cho, Q. N. Le and J. W. Jeon, An FPGA-Based Multiplex-Axis Motion Control Chip, IEEE Trans. on Industrial Electronics, vol. 56, no. 3, pp. 856-870, March 2009. Fig. 15. The processing result of Fig. 12. Fig. 12. The four trigger signals for H-bridge driver (power off). Fig. 13. The trigger signals and phase currents.