Precision control of irregular trajectory of two-dimensional slide based on STM32

Publisher:点亮未来Latest update time:2015-10-15 Source: 21icKeywords:STM32 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
In modern industrial control, the control of stepper motors is the actuator of slide control. The biggest feature that distinguishes it from other control motors is that it is controlled by input pulse signals, that is, the total rotation angle of the motor is determined by the number of input pulses, and the motor speed is determined by the frequency of the pulse signal.

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等多种协议。

a.jpg

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.

b.jpg

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:

c.jpg

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

d.jpg

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

e.jpg

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 e1.jpgare both, then we have

f.jpg

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

g.jpg

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.

h.jpg

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.

i.jpg

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.

Keywords:STM32 Reference address:Precision control of irregular trajectory of two-dimensional slide based on STM32

Previous article:Integrated power supply monitoring device based on ARM and FPGA
Next article:Application of ARM core board in electrical fire monitoring system

Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
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号