Design of stepper motor drive module based on CPLD

Publisher:HeavenlyMelodyLatest update time:2013-05-26 Keywords:CPLD Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
0Introduction

  CNC technology is a technology that uses digital programming to control the automatic operation of machinery or other equipment. CNC machine tools are machine tools that use CNC technology, or machine tools equipped with CNC systems. The CNC system of machine tools mainly consists of several parts: input of part processing programs, data processing, interpolation calculation and control of motion mechanisms. This article mainly introduces the last part, the control of motion mechanisms, that is, how to control the action of the motor. There are many types of motors to choose from, and here we choose stepper motors.

  The stepper motor is a digitally controlled motor, a precision actuator that converts electrical pulses into angular displacement. It rotates step by step at a fixed angle. Each time a pulse is sent to the stepper motor, the motor rotates a fixed angle. As long as the number of pulses is correct, the motor can move in place without cumulative errors. Therefore, the control of the stepper motor can adopt an open-loop control method. How to accurately and economically control the stepper motor has become a topic of discussion for many researchers. This article will use CPLD to realize the control of the stepper motor. And finally through the experimental simulation results.

  1 Stepper Motor Driving Principle

  The driving of the stepper motor is to energize the excitation windings of each phase of the stepper motor to change the direction of the magnetic field inside the stepper motor to make the stepper motor rotate. Assume that the stepper motor we are using is a four-phase one, and the four phases are A, B, C, and D, corresponding to four pairs of magnetic poles. The inner surface of each magnetic pole is distributed with multiple small teeth of the same size and tooth spacing (different stepper motors have different numbers of small teeth). Assume that IV is the number of small teeth in the rotor. When these four phases are energized in the order of A-B-C-D, the internal magnetic field of the stepper motor changes one circle (360°). This energization method is a single-phase four-beat energization method. At this time, the step angle of the stepper motor is:

  θ=90°/N

  If N=50, then θ=1.8°

  If the selected power-on sequence is A—AB—B—BC—C—CD—D—AD, this power-on mode is a two-phase eight-beat power-on mode. At this time, the step angle of the stepper motor is:

  θ=45°/N

  If N=50, then θ=0.9°

  The step angle is the minimum angle that a stepper motor can rotate at one time. The smaller the step angle of the motor, the more precise the motor moves. Therefore, this article chooses the two-phase eight-beat power-on method to drive the motor.

  2 Design

  A complete, high-precision stepper motor control system block diagram is shown in Figure 1. The CPLD is connected to the stepper motor driver, which amplifies the CPLD output signal and sends it to the stepper motor. Since the various axes of the CNC machine tool are driven by the rotation of the motor, the rotation of the motor drives the movement of the corresponding axis.

  

  The functions of each module are described as follows:

  2.1CPLD module

  Use CPLD to control the stepper motor to start, stop, and reverse the motor. The traditional way is to use a single-chip microcomputer to control the stepper motor, but in a CNC system, the single-chip microcomputer has a lot of work to do. For example, the single-chip microcomputer must control the stepper motor and receive the data from the host computer to do corresponding calculations, control the display module, and handle alarms. If CPLD is used to drive the stepper motor, the burden of the single-chip microcomputer can be reduced. Using large-scale programmable logic devices as controllers can reflect that CPLD plays a higher role in control, rather than just being used as a logic device. And CPLD has a relatively economical price.

  In addition, CPLD has many peripheral interfaces. For example, EPM7032 produced by ALTERA has 36 I/O ports and more than 600 internal logic gates. In addition to the resources used to drive the stepper motor, the remaining resources can also be used for other purposes in the system.

  In the actual circuit board design stage, if you use the traditional design method to design the circuit, you must first determine the type and specifications of the device to be used, and then start from drawing the silicon wafer layout, step by step, until the design of the entire system. In this process, if there is a problem at any level, it must be reworked and the entire circuit board will be scrapped. However, if CPLD is used, the design method is a top-down design method, which is a process of gradually refining each design link in the entire design process. For example, at the beginning of our design, we can first connect the CPLD and the driver, and then use the software settings to use the pins we have connected. If there is an error in the program, the new program can be loaded into the CPLD through ISP (in-system programmable method) without replacing the circuit board.

  2.2 Driver module

  The operation of the stepper motor requires an electronic device to drive it. This device is the stepper motor driver. Since the signal output by the CPLD is not enough to drive the motor to rotate, a driver must be connected between the CPLD and the stepper motor to amplify the signal output by the CPLD. Every time the CPLD sends a pulse signal, the driver causes the stepper motor to rotate one step angle. Therefore, by controlling the frequency of the pulses sent to the stepper motor, the speed of the motor can be adjusted. The faster the pulses are sent, the faster the motor runs; the slower the pulses are sent, the slower the motor runs. The control of the motor speed can be achieved indirectly by adjusting the frequency of the CLK pulses sent to the CPLD; by controlling the number of step pulses, the motor can be precisely positioned.
3 Software Implementation

  This article realizes the control of stepper motor by programming CPLD, using VHDL language and MAX+PLUSII programming environment. The control program consists of two parts, one is the entity part and the other is the structure part. The entity is used to describe the port information and the structure is used to describe the circuit function.

  3.1 Entity

  There are 6 ports defined in the entity.

  CLK: Clock signal

  reset: reset signal

  DIR: Forward signal

  START: Start signal

  STOP: Stop signal

  phase: output signal

  3.2 Structure part

  In software design, the key point is to first correctly write the state transition table under the two-phase eight-beat power-on mode.

  

  In Table 1, '1' indicates power on, '0' indicates power off, and S0 to S7 respectively represent the eight states under the power-on mode of A-AB-B-BC-C-CD-D-AD. In this state sequence, the motor rotates forward, otherwise the motor rotates reversely. S0 to S7 in the table are all represented by binary numbers. If converted to hexadecimal numbers, they are 1, 3, 2, 6, 4, C, 8, 9 respectively.

  The structure of the program consists of three parts: the description part, the master control sequence process, and the master control combination process. The description part defines the relevant signals and constants; the master control sequence process is responsible for sending the calculated information of the next state to the initial state and is responsible for the final output; the master control combination process is responsible for the relevant calculations, such as judging start and stop, forward and reverse, and how to take the next state under the forward and reverse state. The following program is the program segment of the master control combination process in the structure, how to judge the forward and reverse rotation of the motor and how the motor will move in the next step.

  

  3.3 System simulation results

  The software waveform simulation of the entire control program is as follows:

  

  From Figure 2, we can see the state of the motor when simulating the start, stop, forward and reverse rotation of the stepper motor. For example, after reset, when START='1', if DIR='1' at this time, it means that the motor is in forward rotation, then the power-on state of the motor is A-AB-B-BC-C-CD-D-AD, and the corresponding CPLD output state is S0~S7. When DIR='0', it means that the motor is in reverse rotation. For the screenshot of Figure 2, at the rising edge of CLK, the output is state S2, because its previous state can be seen from the figure as S1.

  4 Conclusion

  In the CNC system, we hope to achieve accurate, efficient and economical control. In the control of the motion mechanism, CPLD can play a very good role. First, it can simplify the hardware circuit and improve the reliability of the circuit. Secondly, it can change the structure of the device by programming the device to achieve the expected function, and load the program to the device through the ISP in-system programmable method.

  The CPLD can be used to control the start, stop, and forward and reverse rotation of the stepper motor. This paper verifies the correctness of the scheme through software simulation. The motor listed in this paper is a four-phase motor. If it is a three-phase or five-phase motor, it can be implemented according to the method in this paper. If the motor is powered by a single phase, it can also be implemented according to the method in this paper, and only a slight modification of the parameters is required.

Keywords:CPLD Reference address:Design of stepper motor drive module based on CPLD

Previous article:Simulation Design of Video Acquisition System Based on DSP
Next article:DSP+FPGA embedded multi-channel video surveillance system hardware platform

Latest Analog Electronics Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号