STM32 motor Tutorial 3 - Brushed DC open loop speed control

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/zhanglifu3601881/article/details/102769917

 

Foreword

      Brush Motor is a kind of motor you first contact, introduce motor on high school physics classroom also use it as a model to show. Brush primary structure of the motor rotor is a stator + + brush, rotational torque obtained by the rotating magnetic field, to output the kinetic energy. Constant contact friction brush and commutator, the conductive and play the role of commutation in rotation.

https://images2018.cnblogs.com/blog/1435508/201808/1435508-20180822191635169-1771943257.gif

Brush motor with mechanical commutation, the magnetic pole does not move, the rotation of the coil. When the motor operates, the rotation of the coil and a commutator, and brushes magnet does not turn, alternate the direction of the coil current is rotatable with the motor commutator and a brush to complete.

In the brush motor, this process is a two input terminals of each power coil group sequentially arranged in a ring, each other separated by an insulating material, composed of something like a cylinder, integral with the motor shaft, the power by two small columns made of carbon (carbon brushes), under the action of spring pressure from two specific fixed position, pressed against the upper coil power input points on the cylindrical ring, to a set of coils is energized.

As the motor rotates, or at different times to different poles of different coils with the energization of a coil, the coil generates a magnetic field in the NS NS pole permanent magnet and an iron stator pole closest to a suitable angle difference, magnetic opposites attract, homosexual repulsion generated power, push the motor rotation. Carbon electrode coil wiring head slides on the surface like a brush, so called carbon "brush."

Mutual sliding, rubbing of the brushes will cause loss, need for regular replacement brushes; brush and off alternately between the coil terminals, the spark will occur, resulting in broken electromagnetic interference electronic device.

有刷电机采用机械自动换向方式,控制起来特别简单,特别是直流有刷电机,只需在电机电极上通上直流电就可以让其转动起来,本节以下图所示的1718直流有刷电机为例 ,为大家展示如何用NUCLEO-F103RB和X-NUCLEO-IHM07M1 3SH让其实现速度开环控制!!

 

 

示例详解

本节用到ST官方推出的NUCLEO-F103RB和X-NUCLEO-IHM07M1 3SH 开发板。

 

NUCLEO-F103RB对应的大致原理接线图:

X-NUCLEO-IHM07M1 3SH部分原理图:

 

 

    1. 准备操作
      1. X-NUCLEO-IHM07M1 3SH是一款专门用于PMSM(永磁同步)或BLDC(直流无刷 )的电机驱动板(后面的章节将会给大家展示),当然也可以用于驱动直流有刷电机,本节就用它来控制直流有刷电机(1718,电压7-11V,实际使用9.6V),X-NUCLEO-IHM07M1 3SH电机驱动板驱动芯片型号为L6230(详细数据手册可在st官网下载),本节仅用IN1,IN2,和OUT1,OUT2即可!

需要用到的信号

对应MCU引脚

EN1

PC10

IN1

PA8

EN2

PC11

IN2

PA9

本节将直接使能EN1及EN2引脚,PA8和PA9配置成定时器1的PWM引脚控,通过控制PWM的点空实现对有刷直流电机的速度控制。

 

      1. 在STM32CubeMX中,有专门的NUCLEO-F103RB工程模板,新建一个Cube工程,芯片型号为st32f103rb:

生成一个简单的工程模板实现了RCC,SYS,USART2接口的配置,同时还实现了LD2(LED)引脚的配置。接下来手动配置TIM1(产生主载波频率为72M / ( 2+1) / ( 999 +1) = 24K的PWM):

配置PC10,PC11为GPIO_OUTPUT模式:

Generating projects:

 

 

      1. Main.c added in the following code in the main function, allow the motor to achieve the forward 10 seconds 10 seconds reverse cycle, and when the revolution speed of the motor is switched between the positive rotation and reverse rotation is gradually increasing or decreasing:

After downloading the project is set to run automatically:

Compiled code, can be downloaded directly to run successfully saw motor is rotated up and consistent results as to achieve a programmed forward after 10 seconds 10 seconds reverse cycle, with the speed control, when the motor is switched in commutation becomes become more stable, while the maximum speed of the motor can be max_speed according to a program variable values ​​are different are not the same, classmates can modify the initial value max_speed's look at the actual results.

If the oscilloscope hand, the program can be seen that the output of the PWM waveform, and the motor current waveform:

 

In this section, so that the motor turning up and successfully implemented to control the direction of rotation, with the STM32 timer TIM1 PWM wave generation function to control the PWM duty wave (corresponding to the control voltage of the motor) the motor speed control (open loop) ! OK, the current test is completed! And if you have any questions or want to know there are other content, but also welcome message! ! Finally, like the number of students remember the public plus interest, and every day there are technical dry launched! !

 

Download the source text, thirteen public concern number:

33 In the number sent to the public in the " Downloads | STM32 Motor Tutorial 3 ":

 

 

Guess you like

Origin blog.csdn.net/zhanglifu3601881/article/details/102769917