STM32 Simulink automatic code generation motor control - record a motor initial position detection and NS pole judgment experiment

Table of contents

foreword

 Fundamental

simulation implementation

Code Generation and Development Board Verification


foreword

I have done the simulation of pulse vibration high-frequency injection to the experiment of code generation and development board operation before. The motor can calculate the angle through high-frequency injection, but when detecting the initial position, I tried many methods, but the effect is mediocre, and it is easy to reverse. , due to time constraints, I didn’t spend too much time and energy. Recently, I tried another method, and the effect is quite obvious. Record it here, and all the codes of the algorithm layer are automatically generated. STM32 Simulink Automatic Code Generation Motor Control - Pulse Vibration High Frequency Injection_High Frequency Injection Code_Carlos Yi's Blog-CSDN Blog

 Fundamental

When doing high-frequency injection, it will be found that after injecting high-frequency signals for angle estimation, it will converge to a certain angle. If the magnetic pole is not added to judge, the convergence angle may be poor, which will cause reverse convergence, that is, the motor \piwill reverse. Therefore, it is necessary to judge whether the initial position angle is correct at startup. The way to realize it is that the Q-axis current injects a high-frequency signal into the 0 and D-axis. At this time, the rotor is not moving, and the rotor position information can be extracted through high-frequency injection. Then judge whether to add or not according to the maximum value and minimum value of the D-axis current in a high-frequency cycle \pi.

simulation implementation

The following is the Id returned by the feedback, and the maximum and minimum values ​​of the Id are extracted

 Then cooperate with the state machine to judge

Code Generation and Development Board Verification

The complete start-up process is as follows. When starting up, the high-frequency injection converges to a certain angle, and the initial position angle obtained after NS judgment has basically coincided with the angle of the encoder. The purple is the angle of the encoder. The small motor has its own Hall. If you want to have an encoder, you can refer to: Record the process of installing a 5012 encoder (Tamagawa protocol) for the small motor_Software configuration process of the motor encoder_Carlos Yi's Blog-CSDN Blog

 As follows, after the angle converges, it is judged that it does not need to be added \pi, but the angle error between the angle and the encoder is about ten degrees

 Try other positions, the initial position can also converge to the initial position of the encoder

 

 

 You can watch the demo video of the launch

Initial Position Detection Demo

Summarize

From the experimental waveform, the detection of the initial position angle has been realized, and it can be started normally several times in a row without reversal, but there is still a lot of room for optimization, so record it first.

Guess you like

Origin blog.csdn.net/weixin_42665184/article/details/130814871
Recommended