1 Introduction
As the manufacturing industry moves towards large-scale production and product personalization, product model changes are accelerating, production batches are becoming smaller, and the trends of multi-model co-production, larger parts, and integration are becoming increasingly apparent. This demands that presses not only operate at high speed, high precision, and high load, but also possess greater flexibility, enabling rapid and convenient changes in output motion patterns. These continuously improving processing technologies and diversified production conditions have spurred significant changes in the forging equipment industry. Driven by demand, servo presses directly driven by servo motors have emerged worldwide, capable of meeting the requirements of forming processes such as plastic processing, forming of difficult-to-form materials, forming of complex shapes, composite forming, and high-precision forming. Servo presses use AC servo motors instead of ordinary AC motors, eliminating the flywheel and clutch found in traditional crank presses, thus simplifying the mechanical structure and enhancing reliability. Therefore, developing digital control systems for presses suitable for processing different materials is of great practical significance for improving the level of material processing technology and the digital capabilities of processing equipment.
Compared with traditional presses, the basic structure and control system requirements of servo presses are different. Servo presses eliminate the flywheel and clutch of traditional presses, but retain the crank-slider drive mechanism. Its transmission system adopts a single-stage gear reduction system to transmit its motion and power to the crankshaft of the press. The reciprocating motion of the press is realized by the rotation of the crankshaft.
Meanwhile, servo presses place higher demands on the control system, which generally requires the control system to meet the following requirements: programmable slider motion curves to adapt to different processing objects and processing techniques for different materials; precise control of slider position and speed; and fast response.
2. Overall Scheme Design of Control System
Based on the functional requirements of the servo press , this system adopts a hardware design scheme of "industrial computer + ARM motion control card". The industrial computer is responsible for the non-real-time part of the system, completing the reading and setting of motion curves, process optimization, and display of operating status parameters.
The control card is responsible for the real-time portion of the system, handling the real-time motion control and data logic processing of the servo press . The ARM motion control card communicates with the industrial computer using mature serial communication. It employs the STM32 series ARM chip; the STM32 is a 32-bit microcontroller from STMicroelectronics, and the microprocessor used in this controller is the Cortex-2M3 core developed by ARM. The Cortex-M3 incorporates several technological improvements, resulting in faster code execution speeds and lower power consumption. In terms of peripherals, this model includes two 12-bit successive approximation analog-to-digital converters with a maximum conversion time of 1ms; three USART communication interfaces supporting full-duplex data exchange and providing a wide range of baud rates, up to 415Mbps; two SPI communication ports supporting 18MHz master-slave control mode; two I2C bus interfaces supporting inter-chip communication and transmission; three 16-bit general-purpose timers, each with four channels and three operating modes per channel: input capture mode, output compare mode, and PWM control mode; and a 16-bit advanced timer dedicated to motor vector drive, with six functional channels and adjustable dead time. Additionally, it includes commonly used USB and CAN bus interfaces, as well as seven DMA channels for automatic data transfer. The system block diagram of the STM32-based servo motor control system is shown in Figure 1.
Figure 1 Control System Block Diagram
Based on the system's working principle, this control system can be divided into four parts: PWM generation, pulse counting, I/O control, and serial communication. Since this system uses a servo driver to control a servo motor, the control signals include PWM pulse signals, motor direction signals, and servo enable signals. The PWM pulse signal is generated by a dedicated STM32 timer. The STM32 supports online adjustment of the PWM pulse frequency and duty cycle, and its pre-loaded register automatically loads the new set value into the shadow register after the count overflows, while simultaneously updating the period counter and prescaler. The direction and enable signals are generated by ordinary I/O ports. The digital signals generated by the STM32 are output through optocoupler isolation, which prevents electrical interference and performs level conversion, improving the driving capability of the I/O ports.
The incremental pulse encoder outputs three differential signals, A, B, and Z, which are then sent to the STM32 timer after opto-isolation. In this system, the position and speed of the motor are obtained by counting the feedback pulses generated within a certain time period, thus realizing closed-loop control of speed and position.
The I/O control module includes input I/O and output I/O. The input and output I/O signals are sent to the general I/O ports of the STM32 via relays. The input I/O mainly includes motor enable and disable, servo excitation and other signals. The output I/O is used as an alarm signal for abnormal motor operation. The abnormal signal is sent to the I/O port via relay to generate an interrupt signal. The main controller jumps to the interrupt subroutine to execute according to the corresponding interrupt signal.
The STM32 has three USART communication interfaces, supporting full-duplex data exchange and providing a wide range of baud rate options to meet the communication requirements here. It uses serial communication with the host computer to obtain instructions and motion parameters from the host computer and return the motion status of the slider.
3. Software implementation of the control system
3.1 Overall Software Structure
The software portion uses Real2ViewMDK (Microcontroller Development Kit) for program coding, employing a modular programming approach. It independently completes the program setup for the system configuration module, encoder feedback module, timer module, communication module, and PID closed-loop control module. The overall program structure is shown in Figure 2.
Figure 2 Software Structure Diagram
Figure 3 Main Program Flow
3.2 Main Program Flow
In the motor's motion section, since serial communication is used to transmit motor control parameters, it is necessary to define the data format for serial communication. In this program design, the data frame is divided into command control words, status query words (which require data return from the lower-level machine), and motor parameter words. Taking the transmission of motion parameters from the upper-level machine as an example, the upper-level machine sends a position command, the controller checks whether the data has been received, and sends a signal to the driver based on the received data to control the motor to run precisely to the specified position. If an error occurs, error compensation is performed. The system program flowchart is shown in Figure 3.
3.3 Rotor position and angular velocity detection
The pulse encoder module primarily calculates position and speed, enabling closed-loop control of displacement and velocity. Incremental encoders output pulse signals; the number of pulses depends on the relative rotational displacement, not the absolute rotational position. They offer high accuracy and relatively low cost. If a reference position is pre-set, an incremental encoder can perform the function of an absolute encoder, measuring the absolute rotational position. Speed calculation can be done in two ways: one is using an f/v converter to convert frequency into a voltage signal, and the other is directly calculating speed by counting pulses within a given time period. Considering the complexity of implementation, the latter method is used here.
3.4 Timer Module
In the entire control program, the generation and control of PWM pulses is the most critical link. The ability to reliably generate real-time adjustable PWM pulses directly affects the flexibility and accuracy of the entire system. STM32 has two types of timers: general-purpose timers and advanced timers. T1M1 is an advanced timer, while TIM2, TIM3, and TIM4 are general-purpose timers. The general-purpose timer consists of a 16-bit auto-reload counter, which can be driven by a programmable prescaler. The general-purpose timer can be set to three auto-reload modes: 16-bit up, down, and center. The general-purpose timer can be configured with a system clock up to 72MHz. Each general-purpose timer has four 16-bit high-precision capture/compare channels and can be configured to output six complementary PWM pulses.
This control system uses an up-counting PWM mode pulse to drive the motor. Pulse width modulation (PWM) is a method of digitally encoding the level width of a pulse signal. Through the application of a high-precision timer, the duration of both the high and low levels in the pulse period can be represented by integer multiples of the high frequency of the basic high-precision timer. Given a fixed output voltage, a single complete PWM pulse signal contains three parameters: pulse frequency, pulse duty cycle, and number of pulses. The first two parameters determine the pulse shape, and the last parameter determines the pulse duration. The flowchart of the PWM generation program is shown in Figure 4.
Figure 4 Pulse generation flowchart
3.4.1 Port Configuration of Pulse Signals
The pulse signal port configuration includes 3 timer PWM outputs, 3 enable signals, and 3 direction signals. The timer PWM pulse signal output ports are configured in multiplexed push-pull output mode, and the direction and enable signal output ports are configured in push-pull output mode. The encoder capture input port is configured in floating input mode. GPIO can be configured in 2MHz, 10MHz, and 50MHz types according to the connection speed requirements.
3.4.2 Setting the pulse frequency and duty cycle
In the STM32 controller chip, the registers related to timers include the counter register (TMCNT), prescaler register (TMPSC), capture/compare register (TMCCR), and autoload register (TMARR). Generating PWM pulses with specified parameters mainly involves configuring these registers. The following describes the PWM signal configuration steps:
(1) Base Frequency Setting. In STM32, the base frequency of the TIM1 advanced timer is determined by the ABP1 bridge clock, while the base frequency of the general-purpose timer is determined by the ABP2 bridge clock. In the system module, both the ABP1 and ABP2 bridge clocks are configured to the highest system clock of 72MHz. Since the pulse frequency range represented by the 16-bit timer is limited, in order to expand the frequency range of its output pulses, it is necessary to reduce the input frequency by setting the prescaler register to a base frequency of 72MHz/TMPSC. After this setting, both the counter register and the auto-load register compare and count using the divided base frequency as the unit.
(2) Base frequency setting. In up-counting mode, the counter register counts from 0 to the value set in the auto-load register, then restarts counting from 0 while generating a counter overflow interrupt. By setting the auto-load register, the timing of the overflow interrupt can be adjusted. After the overflow interrupt occurs, the system will automatically perform a level transition and start the next pulse cycle. Therefore, the frequency of the PWM signal can be determined by 72MHz/TMARR.
(3) Duty cycle setting. During the process of the counter register incrementing from 0 to the value set in the automatic device register, a level transition can be achieved by setting the comparison register and changing the relationship between the comparison register and the count register. Therefore, in order to expand the range of pulses that can be generated, it may be necessary to prescale the 72MHz system clock. So in the actual program, it is necessary to first determine whether prescaler is needed. If it is needed, then the minimum prescaler coefficient must be calculated.
3.4.3 Pulse Counting
STM32 can directly set the period and duty cycle of the PWM pulse signal to determine the shape of the pulse signal, but it needs to count the pulses to determine the number of pulses to send and to decide whether to start or stop the timer. During the PWM generation process, a compare interrupt will be generated when the current value of the count register is greater than the value set in the compare register. When the value of the count register increases to the value set in the auto-reload register, an overflow interrupt will be generated. Both interrupts are edge-triggered; the compare interrupt will be triggered on the falling edge, while the overflow interrupt will be triggered on the rising edge. Pulse counting can be achieved at the moment the interrupt is triggered.
4. Conclusion
This paper establishes a control system for a servo press using STM32 and proposes an implementation mode for the servo press control system. The control slider achieves arbitrary speed and motion curves, improving material formability, reducing noise, and saving energy. From the established servo press control system, it can be seen that perfecting the control of the servo motor, minimizing computational energy, and obtaining precise stamping energy are issues that require further research.