The role of RAMPGEN and RMPCNTL modules in motor control programs[Copy link]
The test program is obviously not the main body of pmsm3_1, but there are many places that are difficult to understand. The following is my personal opinion. There may be some mistakes. I hope you can give more suggestions after reading it. Welcome to communicate. First, this program is an open-loop control. There are three main input quantities, the d and q axes of the stator current and the speed reference speedref. These three quantities are actually connected through a current ipark transformation module. Why do I say that? Because the Park transformation not only requires the components of the d and q axes, but also the real-time angle theta of the rotating coordinate axis. Theta angle can be obtained through an observer or sensor in a closed loop, but under open-loop conditions, this angle has another role and meaning, that is, to cooperate with your speed reference and convert your speed reference into a real-time angle. In fact, the reason is not complicated. The conversion between angular velocity and angle is nothing more than a proportional and cumulative relationship, that is, take your current angle plus the angle increment within the sampling period, and for a constant system, it is also a constant, which is the sampling period multiplied by the speed. Second, let's talk about the main function of the subroutine rmp_cntl.c. This program is actually a function generator that uses a step wave to simulate a sine wave. Why do we need to generate this signal? What is the function of this signal? I personally think that this step wave generator generates the input signal of the system, or more precisely, the speed given signal. Why do we use such a wave as the speed given signal? Isn't a speedref already given? My understanding is this: if you only take speedref as a given value without doing any processing, then this program is an open-loop speed control application. The purpose of the author of this program is not to make a general application, but a test program. What is a test program? The test program is to create various input signals to see how the system we designed will perform. Therefore, this test program must add test signals. There are many types of test signals. The most common one in motor control systems is the sine signal. By adding a sine signal to the system, we can see whether the amplitude and phase of the output signal will be distorted. (For linear systems, this output signal is also a triangular function wave) The speedref we gave at this time becomes TargetValue, which is the maximum value of the step wave. Three, finally, let's focus on the subroutine rampgen.c. This program is a ramp function generator. The angle as output is actually a ramp signal. When your angle increases to 360 degrees, you have to start the cycle from 0 instead of 361 degrees, because the trigonometric function system of the computer only has numbers within 360. Even if you look up the table, it is still the same. Otherwise, how much space would be needed! The following question is, how much should the ramp signal increase in each interrupt cycle? This is mainly determined by three factors: 1. The given speed. The speed of this test program is the step wave signal given by rmp_cntl.c; 2. The duration of the interrupt cycle; 3. The base frequency of the motor: This frequency is generally the upper limit of the speed regulation. If it increases further, it will weaken the magnetic field. The last two factors are not very direct, nor do they have a strict quantitative relationship, but the author of this program has taken these two factors into consideration in order to adapt the program to different motors and hardware. If others want to use other types of motors, they only need to modify these parameters in some header files or the main program without having to modify the relevant quantities in other programs. In this program, the product of the last two quantities is actually the coefficient StepAngleMax. It affects the amplitude of the ramp signal in an interrupt cycle. The last question is why Angle is limited to between positive and negative 1. Some students say that this is because it is a trigonometric function. I personally think that this is not quite correct. I suggest that friends who are interested in this read the description of IQ_math and see the description of the definition domain of the _IQsinPU function. This way you will understand why Okay, that's all. If you have any questions, you can contact me on QQ. Welcome! Carry out motion control to the end!