In many cases, it is necessary to let the stepper motor control the slide to move a very precise distance, and the running trajectory is irregular, and the speed needs to be adjustable during operation. This paper first introduces the hardware circuit principle of the system; analyzes the calculation method of controlling the irregular trajectory of the slide; on this basis, it proposes the method of using timer interrupt to accurately control the PWM number; introduces the specific software implementation method and analyzes the system test results.
1 System Hardware Design
本论文基于机车牵引梁数控磨削设备的电控设计,此设备用来磨削一个带弧线的六边形物体,因此要求设计两维滑台的电控部分,以精密控制磨削头的运行轨迹,经分析此轨迹呈不规则路线。系统硬件框图如图1所示,本系统的主控芯片是STM32F407,该芯片主频高达168 MHz,PWM定时器的频率同样可以达到168 MHz,在频率要求较高的设计中有较显著的优势。同时对于定时器中断控制PWM数量可以防止中断嵌套,且可以显著减少中断现场保护的开销,且该芯片支持SPI、CAN、I2C等多种协议。
The host and slave use two two-phase stepper motors to drive the X-axis and Y-axis slides respectively, and the stepper motors are driven by M860 drivers. The STM32 main control board sends PWM signals, direction and enable signals to the driver, which drives the stepper motor after optical coupling isolation and subdivision. The host and slave of this system use CAN bus for communication. CAN bus has the advantages of strong real-time performance, long transmission distance, strong anti-electromagnetic interference ability and low cost. The host and slave can run separately, and the CAN bus is used for synchronization only when necessary. The host sets the PWM frequency, slide position and other data, and sends signals such as start and stop operation. The slave receives relevant data and instructions through the CAN bus. When the slave ends the operation, it will send an end signal to the host. The host and slave are synchronized through the CAN bus.
2 System Software Design
2.1 Operation mode of two-dimensional slide
The two-dimensional slide is taken as the research object. The slide is driven by a stepper motor. The operation mode of the slide includes the separate operation and simultaneous operation of the two-dimensional slide. It is assumed that the tooth pitch of the slide is 10 mm (the stepper motor rotates one circle and the slide moves forward 10 mm).
Assume that the target slide advance distance is L. The driver subdivision multiple is, the total number of stepper motor steps, and the total number of PWM pulses are n, N, and P respectively.
In order to facilitate calculation, the driver subdivision multiple is set to 5 in this design.
P=N=100L (2)
That is, when the slide needs to move forward a distance of Lmm, the total number of steps of the stepper motor and the total number of PWM pulses should also be 100 L.
As shown in Figure 2, the irregular motion trajectory of the two-dimensional slide is composed of straight lines, oblique lines, and arcs. The various trajectory implementation methods are as follows:
1) Diagonal track
As shown in Figure 2, the two-dimensional slide has a process of simultaneous movement and termination. For the oblique line part, the X-axis slide moves a distance of n1 while the Y-axis slide moves a distance of n2. Formula 2 shows that the number of PWM pulses required for the X-axis slide and the Y-axis slide to move distances of n1 and n2 are P1 and P2 respectively, so P1=100n1, P2=100n2. Taking the X-axis as the reference, then
n2=n1·cosα (3)
P2=P1cosα (4)
The PWM frequency generated by the STM32 timer is determined by the system clock f, the pre-division value M, and the counting period T. The system clock f and the pre-division value M remain unchanged, and the PWM frequency is changed by changing the counting period T.
Taking the X-axis slide as the reference, Tx and Ty are the X-axis and Y-axis timer counting cycles, Vx and Vy are the X-axis and Y-axis timer frequencies, then
2) Single slide motion trajectory
As shown in Figure 2, for the part with a distance of n3, since it only needs to move in the X-axis direction, it can be seen from Formula 2 that the required PWM number is 100n3, so it is only necessary to set the PWM frequency of the X-axis timer to a fixed value. And count 100n3 PWM numbers and then stop, the distance the trajectory moves in the X-axis direction is n3.
For the part with distance n4, the only difference from the part with distance n3 is that it only needs to move in the Y-axis direction. Therefore, it is only necessary to set the PWM frequency of the Y-axis timer to a fixed value, count 100n4 PWMs and then stop. [page]
3) Arc trajectory
The arc part is realized by straight line cutting, the arc angle is 90 degrees, point D is the center point of the arc, and the arc radius is 55 mm.
Point D and above are based on the X axis. Assume that the PWM frequency generated by the X axis timer is, and the Y axis timer frequency changes once every 100 PWM outputs. Assume that point A changes PWM n-1 times, and point B changes PWM n times, then the coordinates of point A are (100(n-1), Ya), the coordinates of point B are (100n, Yb), and the radius of the arc is R, then
However, since the number of PWMs on the X axis corresponding to the midpoint of the arc is often not a multiple of 100, assuming that point C is the point closest to the midpoint D, and point C changes PWM m times, then the X axis coordinate of point C is 100m, and the X and Y axis coordinates of point D are both, then we have
Below point D, with the Y axis as the reference, assume that the PWM frequency generated by the Y axis timer is fixed at Vy, and the X axis timer frequency changes once every 100 PWM outputs. Assuming that point E changes PWM i-1 times, and point F changes PWM i times, then the coordinates of point E are (Xe, Yd-100(i-1)), the coordinates of point F are (Xf, Yd-100i), and the radius of the arc is R, then we have
Through equations (8), (11), and (19), the values of Tx and Ty are set in each step of the program to achieve the required trajectory movement of the X-axis and Y-axis slides.
2.2 System software flow chart
As shown in Figure 3, it is a flowchart of the system software. In order to prevent accidental collisions during system initialization, the system needs to find the zero point. After finding the zero point, the slider speed and the number of PWMs in each step of the trajectory are set, and the set data is sent to the slave through the CAN bus. After the setting is completed, when the host detects the signal coming from the object, the start signal is sent to the slave through the CAN bus, so that the host and the slave start running at the same time. When the slave finishes running, it sends a feedback signal to the slave, and the master and slave stop running at the same time. After a run is completed, it is determined whether the parameters need to be reset. If reset is required, the slider operation trajectory parameter setting state is entered, otherwise it enters the waiting state.
During the operation of the master and slave machines, it can be seen from the operation mode of the slide that the slide runs in an irregular trajectory. Therefore, according to the operation mode of the slide, the distance of the slide and the PWM frequency of the two slides need to be calculated before each step of operation.
3 System Testing
The system was applied to the actual environment, and a two-dimensional slide placed vertically on the ground was used as the research object, and the slide was made to run along the trajectory shown in Figure 2. A mark was made at the starting point of the equipment, and the slide was set to run at three speeds: 90 seconds/circle, 45 seconds/circle, and 30 seconds/circle. The slide was run for 10, 15, 20, and 25 circles respectively, and the distance from the starting point at the end of the operation was obtained. As shown in Table 1, the more circles the same speed is, the greater the error is; when the same number of circles is rotated, the higher the speed of the slide is, the greater the error is.
After actual analysis, it is concluded that these errors are caused by two aspects. On the one hand, since the slide is placed vertically on the ground, it is inevitable that the slide will fall due to gravity during the descent process. On the other hand, when the timer outputs a fixed number of PWMs, the PWM frequency needs to be changed frequently during the system movement, and changing the PWM frequency once will cause a delay of 1 CLOCK.
4 Conclusion
This article introduces the calculation method of using STM32 to control the irregular trajectory of the slide, and on this basis, it proposes a method of using timer interrupts to accurately control the PWM quantity. By precisely controlling the slides of the X-axis and Y-axis, the grinding head can move accurately in straight, oblique and arc trajectories to achieve the purpose of successfully grinding the workpiece. Actual tests have shown that the system works stably and with high accuracy.
This design is a two-dimensional slide, but the design ideas and methods can also be extended to the control design of a three-dimensional slide. To obtain more precise stepper motor control, you can consider using DSP as the main control chip, which can have higher computing speed and control accuracy. The method of precisely controlling the trajectory of a two-dimensional slide in this paper can be extended to many projects involving stepper motor control, such as another project in this laboratory - precision control of the microscope electric stage.
Previous article:Integrated power supply monitoring device based on ARM and FPGA
Next article:Application of ARM core board in electrical fire monitoring system
- Popular Resources
- Popular amplifiers
Professor at Beihang University, dedicated to promoting microcontrollers and embedded systems for over 20 years.
- LED chemical incompatibility test to see which chemicals LEDs can be used with
- Application of ARM9 hardware coprocessor on WinCE embedded motherboard
- What are the key points for selecting rotor flowmeter?
- LM317 high power charger circuit
- A brief analysis of Embest's application and development of embedded medical devices
- Single-phase RC protection circuit
- stm32 PVD programmable voltage monitor
- Introduction and measurement of edge trigger and level trigger of 51 single chip microcomputer
- Improved design of Linux system software shell protection technology
- What to do if the ABB robot protection device stops
- Keysight Technologies Helps Samsung Electronics Successfully Validate FiRa® 2.0 Safe Distance Measurement Test Case
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Innovation is not limited to Meizhi, Welling will appear at the 2024 China Home Appliance Technology Conference
- Huawei's Strategic Department Director Gai Gang: The cumulative installed base of open source Euler operating system exceeds 10 million sets
- Download from the Internet--ARM Getting Started Notes
- Learn ARM development(22)
- Learn ARM development(21)
- Learn ARM development(20)
- Learn ARM development(19)
- Learn ARM development(14)
- On the RS485 side DB9 connector, what are the two PINs A and B respectively?
- 【Distributed temperature and humidity collection system】+MQTT debugging
- The channel for exchanging TI points for chip points has been opened. Full redemption within a limited time. The ultimate redemption is coming~
- GPIO principle of TMS320F28335
- I really need help with this strange linking error. It has been bothering me for days.
- Introduction to the working principle and characteristics of rectifier transformer
- TD1509 has large output voltage ripple
- Design of data forwarder based on MSP430F149
- [Evaluation of EC-01F-Kit, the NB-IoT development board of Anxinke] 01. Communication test
- Mini Adafruit QT Py Development Board