当前位置:网站首页>STM32 sensorless brushless motor drive
STM32 sensorless brushless motor drive
2022-06-13 01:58:00 【richardgann】
Preface :
stm32 How to control the induction less brushless motor ?
First of all, we need to know the working principle of brushless motor , So that we can meet the actual needs , Yes stm32 Make point-to-point calls to internal resources , So as to program .
I believe we can find this Blog All students have a general understanding of brushless motor , But the specific use details and principles , It may not be clear .
Here I will explain to you some key points in writing programs , When the brushless motor control is clear , So I can understand how to write the program .
The hardware uses KY_Motor Development board .
link :https://item.taobao.com/item.htm?spm=a1z10.1-c-s.w4004-18361242577.2.110f294eEKyjHQ&id=602257529707

The important part of brushless motor control is commutation , The most important knowledge point of sensorless brushless is zero point detection .
1、 Motor commutation and zero point detection .

Zero detection circuit

//PA5 Pin interrupt , Calculate commutation time
void EXTI9_5_IRQHandler(void)
{
Zero=GPIO_ReadInputData(GPIOA);
Zero=Zero&0x0038;
Zero=Zero>>3;// Zero crossing signal ,513264
if(!Direction)Zero=7-Zero;
Zero_SW();
counter1++;
if(EXTI_GetITStatus(EXTI_Line5)!= RESET)
{
EXTI_ClearITPendingBit(EXTI_Line5);
}
}Here through the test U、V、W Which three-phase circuit is connected , Then, the comparator is used to determine which circuit is on .
Explain here zero = zero & 0x0038 What does that mean? , In terms of hardware, we adopt PA3、PA4、PA5 Three pins are used as zero detection pins ,0x0038 The binary of is xx 0011 1000, That is to say PA3、PA4、PA5 And 111 Meet each other , Then we can get the value of which circuit is turned on .
then zero The value of is shifted to the right 3 position , The zero crossing signal can be obtained 513264, take 513264 It is also correspondingly converted into binary numbers , You will understand how to obtain the value of the zero crossing signal .
In the program, we are divided into PA3、PA4、PA5 Three pins are used for interrupt processing , The procedures are the same , But the short and medium term is different , Let's change the procedure by ourselves .
After obtaining the zero crossing signal, we need to use the obtained signal for motor commutation , This is the classic six arm full bridge drive circuit .

Two of them are connected , Implementation method we implement it by the following methods .
// Zero crossing commutation function
void Zero_SW(void)
{
switch(Zero)
{
case 5:
TIM1->CCR2=0; //AB
TIM1->CCR1 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
break;
case 1:
TIM1->CCR2=0; //AC
TIM1->CCR1 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_14);
GPIO_SetBits(GPIOB, GPIO_Pin_15);
break;
case 3:
TIM1->CCR1=0; //BC
TIM1->CCR2 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_14);
GPIO_SetBits(GPIOB, GPIO_Pin_15);
break;
case 2:
TIM1->CCR1=0; //BA
TIM1->CCR2 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_14 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_13);
break;
case 6:
TIM1->CCR2=0;//CA
TIM1->CCR3 = My_PWM;
TIM1->CCR1=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_14 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_13);
break;
case 4:
TIM1->CCR2=0; //CB
TIM1->CCR3 = My_PWM;
TIM1->CCR1=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
break;
default:
break;
}
}This program is easy to understand , Don't explain too much .
========================================================================
Here we are , The more important two parts of the program of the sensorless brushless motor drive are explained . Let's next look at the startup function .
// Start the function
void START_UP(void)
{
switch(phase)
{
case 1:
TIM1->CCR2=0; //AB
TIM1->CCR1 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
break;
case 2:
TIM1->CCR2=0; //AC
TIM1->CCR1 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_14);
GPIO_SetBits(GPIOB, GPIO_Pin_15);
break;
case 3:
TIM1->CCR1=0; //BC
TIM1->CCR2 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_14);
GPIO_SetBits(GPIOB, GPIO_Pin_15);
break;
case 4:
TIM1->CCR1=0; //BA
TIM1->CCR2 = My_PWM;
TIM1->CCR3=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_14 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_13);
break;
case 5:
TIM1->CCR2=0;//CA
TIM1->CCR3 = My_PWM;
TIM1->CCR1=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_14 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_13);
break;
case 6:
TIM1->CCR2=0; //CB
TIM1->CCR3 = My_PWM;
TIM1->CCR1=0;
GPIO_ResetBits(GPIOB, GPIO_Pin_13 | GPIO_Pin_15);
GPIO_SetBits(GPIOB, GPIO_Pin_14);
break;
default:
break;
}
}Careful students will find out , The starting function is the same as the zero commutation function .
Because the program cannot judge which point is at zero point when the motor is started , Therefore, it is necessary to turn on the motor first , After conduction , A reverse electromotive force is generated , It can also collect the zero point signal , So we know which way is open .
The user interface program added to the program is not listed here , This program controls the motor start and acceleration and deceleration control by pressing the key , Another important thing is , With the same procedure, different motors may not start smoothly , You know why ?
More interesting content, please pay attention to WeChat official account : Guangyi electronics (dlrcclub).
边栏推荐
- Installing pytorch geometric
- 6、 Implementation of warehouse out management function
- Viewing the ambition of Xiaodu technology from intelligent giant screen TV v86
- What is solid angle
- 传感器:SHT30温湿度传感器检测环境温湿度实验(底部附代码)
- C语言压缩字符串保存到二进制文件,从二进制文件读取压缩字符串后解压。
- [the second day of the actual combat of the smart lock project based on stm32f401ret6 in 10 days] light up with the key ----- input and output of GPIO
- Ctrip reshapes new Ctrip
- Pytoch freeze pre training weights (feature extraction and BN layer)
- swiper 横向轮播 grid
猜你喜欢

Numpy multidimensional array transpose transpose

How does Google's audience work?

How to learn C language and share super detailed experience (learning note 1 -- basic data types of C language)

Day 1 of the 10 day smart lock project (understand the SCM stm32f401ret6 and C language foundation)

Use mediapipe+opencv to make a simple virtual keyboard

回顾ITIL各版本历程,找到企业运维发展的关键点

When AI meets music, iFLYTEK music leads the industry reform with technology

leetcode743. Network latency (medium, Dijkstra)

4、 Improvement of warehousing management function

Top level configuration + cooling black technology + cool appearance, the Red Devils 6S Pro is worthy of the flagship game of the year
随机推荐
About tkinter Canvas does not display pictures
In the third quarter, the revenue and net profit increased "against the trend". What did vatti do right?
QT realizes mind mapping function (II)
Detailed understanding of white noise
Viewing the ambition of Xiaodu technology from intelligent giant screen TV v86
华为设备配置CE双归属
Audiences with similar interests
Day 1 of the 10 day smart lock project (understand the SCM stm32f401ret6 and C language foundation)
传感器:SHT30温湿度传感器检测环境温湿度实验(底部附代码)
Alertwindowmanager pop up prompt window help (Part 1)
How do you use your own data to achieve your marketing goals?
When AI meets music, iFLYTEK music leads the industry reform with technology
The commercial value of Kwai is being seen by more and more brands and businesses
Service creation and operation example of ROS
Detailed explanation of C language conditional compilation
Application and routine of C language typedef struct
Jeux de plombiers
Application circuit and understanding of BAT54C as power supply protection
六、出库管理功能的实现
Get started quickly cmake