1 Introduction
Modern manufacturing processes have increasingly higher requirements for precise positioning, motion speed and acceleration, relative and absolute position movement and torque control in motion control. Programmable logic controllers (PLCs) usually have the ability to output pulse sequences, which can control servo systems or stepper motor systems to perform actions. This control method has good versatility and reliability, reasonable cost and easy software development to change according to control requirements, so it is widely used [1]. The key to PLC control of motors is the pulse sequence it generates. This article takes Schneider Modicon M218 PLC as an example to illustrate four pulse generation methods.
2. Motor pulse control principle
The motors used in PLC motor control systems are mainly stepper motors and servo motors. Both types of motors are control motors, and their operation depends on the control signal. They require stepper drivers and servo controllers to receive the control signal and convert it appropriately to drive the motor [2]. Therefore, the control signal generated by the PLC is the key to achieving control. The control signal here includes pulse and direction signals, etc. The structure of the PLC motor control system is shown in Figure 1.
Figure 1. Structure diagram of PLC motor control system
3PLC Pulse Sequence Programming Design
3.1 PTO Pulse Sequence Output
The Schneider M218 PLC's internal PTO (Pulse Output Transmission) is a pulse sequence with a 50% duty cycle and variable frequency, capable of precisely positioning the motor driver, with a maximum frequency of 100kHz. The M218 includes function blocks for pulse output management, PTO error diagnosis, relative position movement, absolute position movement, constant speed continuous movement, controlled axis stop, rapid start/stop, and precise positioning. To achieve high-precision motor control, only the function blocks need to be used flexibly and detailed parameters set, eliminating the hassle of lower-level programming.
Taking rapid start/stop and precise position compensation as an example, this function block is triggered by an external digital signal, continuously outputting pulses at a constant frequency. After the start signal is triggered, the frequency starts from 0 and increases to the target frequency according to the set acceleration. After the stop signal is triggered, the function block starts outputting the position compensation value, and decelerates to 0 according to the set deceleration after outputting the position compensation value. PTO_REF_IN is the reference input for PTO. Execute is the rising edge enable input. StartInput is the external start input. DelayStart is the motion execution delay. Acceleration is the acceleration value. Direction is the motion direction. Velocity is the target velocity. MaxDistance is the maximum protection distance for motion execution. StopInput is the external stop input. Compensation is the position compensation pulse value. Deceleration is the deceleration value. PTO_REF_OUT is the reference output for PTO. InMode is external input trigger enabled. Status is the motion state. Active is the external input trigger execution state. CommendAborted is the execution request ignored. Error is the monitored error. ErrID is the error type. Its graphical language is shown in Figure 2.
Figure 2. Graphical language for rapid start/stop and precise position compensation
3.2 PWM Pulse Width Modulation
PWM (Pulse Width Modulation) can generate square wave signals with variable frequency and width. The duty cycle ranges from 1% to 99%, the frequency is configurable from 20Hz to 1kHz, and the accuracy is 0.1Hz. This signal can directly command the variable speed motion of the axis.
In the PWM (Pulse Width Modulation) function block, EN_Enable enables PWM output triggered by an external event, F_Enable enables PWM via an internal variable, EN_SYNC allows hardware-triggered restart, F_SYNC restarts PWM via an internal variable, Frequency is the frequency of the PWM output signal, Duty is the duty cycle of the PWM output signal, InFrequency is the PWM output signal at a specified frequency, Busy is a Boolean variable that outputs TRUE when the frequency or duty cycle changes, Error monitors for error output, and ErrID is the error code output. Its graphical representation is shown in Figure 3.
Figure 3. Graphical representation of PWM pulse width modulation function
3.3FG Frequency Generator
The frequency generator can generate a square wave signal with a 50% duty cycle at a specified frequency. The frequency can be configured from 1Hz to 100kHz in 1Hz steps.
In the frequency generator function block, EN_Enable is external enable; if configured in the frequency generator channel, it can be triggered by an external event. F_Enable enables the frequency generator via a software variable. EN_SYNC allows the frequency generator to restart via an external event, and F_SYNC restarts the frequency generator via a software variable. Frequency is the frequency of the frequency generator's output signal. InFrequency specifies the frequency generator's output signal frequency. Busy is a Boolean variable; it is set to TRUE if an enable command is set and the frequency changes, and reset to FALSE if InFrequency or Error is set, or if the enable command is reset. Error is a Boolean variable; TRUE indicates an error was detected, and ErrID is the detected error code. Its graphical representation is shown in Figure 4.
Figure 4. Functional graphical representation of the frequency generator
3.4TWDPTO220DT Expansion Module
The TWDPTO220DT of the Schneider M218 PLC is a module specifically designed for pulse output motion control. Two of these modules can be added to the M218 via a direct connection using a flexible ribbon cable. The module's function is similar to the PTO pulse sequence output function inside the M218. Its typical six motion function blocks are frequency generator, movement speed, absolute value movement, relative value movement, origin search, and position setting.
Taking relative value movement as an example, PTO_REF_IN is the input module channel reference number, Execute is the function triggered by the rising edge, Distance is the target distance, Velocity is the target velocity, Mode is the buffer mode, 0 indicates abort, 1 indicates buffering, 2 indicates mixing before, PTO_REF_OUT is the output module channel reference number, Done indicates that the instruction was successfully completed, Busy indicates that the instruction has been received but not yet completed, Command_Aborted indicates that the instruction has been interrupted by other instructions, and Error indicates that the instruction is incorrect. Its graphical language is shown in Figure 5.
Figure 5. TWDPTO220DT Extension Module Relative Value Movement Graphical Language
4. Conclusion
The Schneider M218 PLC's built-in pulse sequence output module, pulse width modulation module, and frequency generator can provide the required pulse output for different types of motors. However, they share channel 0 and channel 1, so the built-in module can only control two motors at a time. Through the maximum expansion of two expansion modules, it is possible to control four motors simultaneously.