A stepper motor is an actuator that converts electrical pulses into angular displacement. When a stepper driver receives a pulse signal, it drives the stepper motor to rotate a fixed angle (called the "step angle") in a set direction, and its rotation occurs at fixed angles. The amount of angular displacement can be controlled by controlling the number of pulses to achieve accurate positioning; at the same time, the speed and acceleration of the motor can be controlled by controlling the pulse frequency to achieve speed regulation. As a special type of motor used for control, the stepper motor is widely used in various open-loop control systems because it has no accumulated error (100% accuracy).
Positioning Principles and Solutions
Stepper motor acceleration and deceleration control principle
When a stepper motor drives an actuator to move from one position to another, it goes through a process of acceleration, constant speed, and deceleration. When the operating frequency of the stepper motor is lower than its own starting frequency, it can be started directly at the operating frequency and run at that frequency. When it needs to stop, it can be reduced directly from the operating frequency to zero speed.
When the stepper motor's operating frequency fb > fa (the starting frequency under load), directly starting at the fb frequency will cause the stepper motor to lose steps or even stall. Similarly, when suddenly stopping at the fb frequency, the stepper motor will overshoot due to inertia, affecting positioning accuracy. If the acceleration and deceleration are very slow, the stepper motor will not experience step loss or overshoot, but the efficiency of the actuator will be affected.
Therefore, when accelerating or decelerating a stepper motor, it is necessary to ensure that it moves to the designated position at the fastest speed (or in the shortest time) without losing steps or overshooting.
There are two common methods for controlling the acceleration/deceleration of stepper motors: linear acceleration/deceleration and exponential acceleration/deceleration. The exponential acceleration/deceleration method has strong tracking ability, but its balance is poor when the speed changes significantly. The linear method has good stability and is suitable for rapid positioning with large speed changes. Acceleration/deceleration is constant, the pattern is simple, and it is relatively easy to implement in software; this is the method used in this paper.
Positioning solution
To ensure the positioning accuracy of the system, the pulse equivalent, i.e., the distance the stepper motor moves by rotating one step angle, cannot be too large, and the acceleration and deceleration of the stepper motor must be slow to prevent step loss or overshoot. However, these two factors combined bring about a prominent problem: the positioning time is too long, which affects the working efficiency of the actuator.
Therefore, to achieve high positioning speed while ensuring positioning accuracy, the entire positioning process can be divided into two stages: coarse positioning stage and fine positioning stage.
In the coarse positioning stage, a larger pulse equivalent is used, such as 0.1 mm/step or 1 mm/step, or even higher.
In the fine positioning stage, to ensure positioning accuracy, a smaller pulse equivalent, such as 0.01 mm/step, is used. Although the pulse equivalent is smaller, the positioning speed is not affected because the fine positioning stroke is very short (approximately one-fiftieth of the total stroke). This can be achieved mechanically by using different speed-changing mechanisms.
Industrial machine tool control plays a crucial role in industrial automation control, and positioning drilling is a common step. Suppose the tool or worktable wants to move from point A to point C. Given AC = 200mm, AC is divided into two segments, AB = 196mm and BC = 4mm. Segment AB is the coarse positioning stroke, using a pulse equivalent of 0.1mm/step and a linear frequency increase/decrease law for rapid movement. Segment BC is the fine positioning stroke, using a pulse equivalent of 0.01mm/step, with low-frequency constant speed movement at point B to achieve precise positioning. Simultaneously with the transition from coarse to fine positioning, the PLC automatically changes the speed change mechanism.
Location Programming Design Summary
PLC pulse output command
Modern advanced PLCs not only possess basic logic instructions that meet sequential control requirements but also offer a rich set of function instructions. The Siemens S7-200 series PLC's PLUS instruction outputs PTO or PWM high-speed pulses in Q0.0 and Q0.1, with a maximum output frequency of 20kHz. Pulse Train (PTO) provides a square wave output (50% duty cycle), with user-defined control cycle and pulse count. Pulse Width Modulated (PWM) can provide continuous, variable duty cycle output, with user-defined control cycle and pulse width.
This paper uses the multi-segment pipeline operation mode of PTO to achieve coarse positioning, and the single-segment pipeline mode of PTO to achieve fine positioning.
In the example above, it is assumed that the motor 's starting and ending frequency is 2kHz, and the maximum pulse frequency is 10kHz. During the coarse positioning process, 200 pulses are used to accelerate the motor and 400 pulses are used to decelerate it. When using the PLC's PTO multi-segment pipeline pulse output, the pulse increment value during the frequency acceleration and deceleration process is calculated using the following formula.
The periodic increment of a given segment = (ECT - ICT) / Q
In the formula: ECT = end cycle time of the segment, ICT = initial cycle time of the segment. Using this formula, the cycle increment for the acceleration section (segment 1) is 2, and the cycle increment for the deceleration section (segment 3) is 1. Since segment 2 is a constant speed section, the cycle increment is 0. If the envelope table of PTO is stored starting from VB500, then Table 1 contains the envelope table values from the example above.
Source code
Main program LDSM0.1 // Initial scan is 1RQ0.0, 1 // Reset image register bits CALL0 // Call subroutine 0 to initialize coarse positioning parameters LDM0.0 // Coarse positioning complete RQ0.0, 1 CALL1 // Call subroutine 1 to initialize fine positioning parameters // Subroutine 0, coarse positioning LDSM0.0
MOVB16#A0, SMB67 // Set control word: Enable PTO operation, select ms increment, select multi-segment operation MOVW500, SMB168 // Specify envelope table start address as V500 MOVB3, VB500 // Set envelope table segment number to 3 MOVW500, VW501 // Set first segment initial period to 500ms MOVW-2, VD503 // Set first segment period increment to -2ms D200, VD505 // Set the number of pulses in the first segment to 200 MOVW100, VW509 // Set the initial period of the second segment to 100ms MOVW0, VD511 // Set the period increment of the second segment to 0ms MOVD1360, VD513 // Set the number of pulses in the second segment to 1360 MOVW100, VW517 // Set the initial period of the third segment to 100ms MOVW1, VD519 // Set the number of pulses in the second segment to 1360 MOVW100, VW517 // Set the initial period of the third segment to 100ms MOVW1, VD519 // Set the number of pulses in the second segment to 100ms The three-segment period increment is 1ms. MOVD400, VD521 // Set the number of pulses in the third segment to 400. ATCH2, 19 // Define interrupt program 2 to handle PTO completion interrupt. ENI // Enable interrupt. PLS0 // Start PTO operation subroutine 1, fine positioning. LDSM0.0 // First scan is 1. MOVB16#8D, SMB67 // Enable PTO function, select ms increment, set pulse number and period. MOVW500, SMW68 // Set the fine positioning period to 500ms. MOVD400, SMD72 // Set the number of pulses to 400. ATCH3, 19 // Define interrupt program 3 to handle PTO completion interrupt. ENI // Enable interrupt. PLS0 // Start PTO operation. // Interrupt program 2. LDSM0.0 // Always 1 = M0.0 // Start fine positioning. // Interrupt program 3. LDSM0.0 // Always 1 = M0.1 // Implement other functions.