当前位置:网站首页>51 MCU peripherals: Motor
51 MCU peripherals: Motor
2022-07-25 08:41:00 【Luxi Feixi】
Motors are usually mechanical devices that convert electrical energy into kinetic energy . Generally, it can be divided into : alternating current dynamo 、 DC motor 、 Stepper motor 、 Servo motor, etc .
DC motor
AC motor and DC motor usually have two pins , The positive and negative poles of the AC or DC power supply can rotate , Power off and stop . Cannot be precisely controlled .
When using , Pass it through the current amplification chip , Connected to the two pins of the MCU , Then set these two pins separately 0 Harmony 1 that will do .
Be careful : DC motor is not divided into positive and negative , Positive and negative connections correspond to positive and negative .
DC motor experiment
The DC motor is directly connected to the main board of the development board VCC and GND Check whether the motor rotates on the outlet interface , It can also be exchanged VCC and GND Check whether the motor reverses .
Single chip microcomputer IO Mouth is a digital mouth , Its driving ability is very small ( most 20mA Level ), This driving capacity is with immovable motor . Therefore, the general single-chip microcomputer needs to use a special drive chip to drive the motor . The function of the drive chip is to convert the small current control signal of the single chip microcomputer into a logically identical drive source of large current . This is the so-called weak current control strong current . Use motor driver chip to drive DC motor , The specific circuit analysis will be detailed later when we talk about stepping motor . Let's skip here for a moment .The code is as follows :
/************************************************************ date :2022 year 7 month 23 Japan author : Stars The contents of the document : Motor demonstration **************************************************************/ #include<reg51.h> sbit P30 = P3^0; sbit P31 = P3^1; /************************************************************* Function entrance **************************************************************/ void main(void) { P30 = 1; P31 = 0; }
Stepper motor
Stepper motor is more complex than DC motor .
Stepping motor is a kind of motor which converts electric pulse signal into corresponding angular displacement or linear displacement . Each input pulse signal , The rotor turns an angle or moves forward , The output angular displacement or linear displacement is proportional to the number of input pulses , The speed is proportional to the pulse frequency . therefore , Stepping motor is also called pulse motor .
Most of the stepping motors used now use permanent magnet rotors . The reason why permanent magnets are widely used is high efficiency , Advantages of high resolution .
Step angle : step
The stepper motor has an inherent step angle , This parameter is related to the stepping motor itself .Generally, stepper motors can only move with integral multiples of the inherent step angle , The movement of this inherent step angle is called a beat .
The motor also has a motion method that can be smaller than the inherent step angle , This method is called subdivision , Supported by motor driver .
Phase number : It refers to how many winding groups the motor has . Commonly used two-phase 、 three-phase 、 Four phases 、 Five phase stepping motor .
This article takes 2 Take phase stepping motor as an example .
Polarity : Unipolar 、 Bipolar .
Number of beats ( a key ): One way four beat 、 Biphasic four beat 、 Half step and eight beats .
Single phase four beat A/ B A B/ Positive rotation ( Just reverse the order )
Biphasic four beat A/B AB AB/ A/B/ Positive rotation ( Just reverse the order )
Half step and eight beats A/ A/B B AB A AB/ B/ A/B/ Positive rotation ( Just reverse the order )Single phase four beat , Energize one winding , The other winding is not energized ,A and A/ Just reverse the level , But usually, who does the current timing belong to , Who is the high level . The level sequence of the four lines is as follows :
A A/ B B/
0 1 0 0 The first 1 pat
0 0 1 0 The first 2 pat
1 0 0 0 The first 3 pat
0 0 0 1 The first 4 pat
4 The beats add up to a complete cycle , Power the stepping motor according to this cycle , Then the stepping motor will rotate 1 A step angle .
Biphasic four beat , The levels of the four wires are as follows :
A A/ B B/
0 1 1 0 The first 1 pat
1 0 1 0 The first 2 pat
1 0 0 1 The first 3 pat
0 1 0 1 The first 4 pat4 The beats add up to a complete cycle , Power the stepping motor according to this cycle , Then the stepping motor will rotate 1 A step angle .
Two phase four beat has higher load than single-phase four beat , But it consumes more electricity , Choose according to the actual situation .
Half step eight beat is a compromise between the above two . Temporal logic is the same .
Controllers and drives
A stepping motor system needs three parts : controller + Driver + Stepper motor
In general : The controller is a single chip computer , The driver is usually connected to the MCU IO Special motor drive chip on the port ( For example, on our development board TC1117)
The controller is responsible for generating timing signals , The driver is responsible for converting the timing signal to the success rate driving signal for the stepping motor .
Look at the schematic
The driver chip can be regarded as a current amplifier , Only connect the signal input end to the pin of the MCU , Connect the signal output to the stepping motor , Then the stepping motor can be driven to rotate by providing the stepping signal according to the time sequence .
Code implementation
I connect the input terminal to the chip P3.0、P3.1、P3.2、P3.3 Four pins , Then the output of the amplifier chip is used to control the A/ A B/ B.
Use single-phase four beat (A/ B A B/) To drive , Then the beat of these pins in a cycle is :
1000
0001
0100
0010
The code is as follows :
/************************************************************ date :2022 year 7 month 23 Japan author : Stars The contents of the document : Motor demonstration **************************************************************/ #include<reg51.h> /************************************************************* Function entrance **************************************************************/ void main(void) { while(1) { P3 = 0x1; P3 = 0x8; P3 = 0x2; P3 = 0x4; } }It's no problem to write the sequence like this , But download it to the development board , No response , Instead, there is a strange noise inside , And the fever is more serious . Editor's Note it ? The wire is connected incorrectly ? Check it out. No problem .
Access to information online , See the following statement :
Exclude the first and second , That's what happens when the frequency is too fast .
So I added a delay before each cycle , as follows :
while(1) { Delay(); P3 = 0x1; P3 = 0x8; P3 = 0x2; P3 = 0x4; }But it doesn't work . Confirm that it is not after the inter cycle delay , I added a delay between each beat , as follows :
/************************************************************ date :2022 year 7 month 23 Japan author : Stars The contents of the document : Motor demonstration **************************************************************/ #include<reg51.h> void Delay(int count); /************************************************************* Function entrance **************************************************************/ void main(void) { while(1) { P3 = 0x1; Delay(5); P3 = 0x8; Delay(5); P3 = 0x2; Delay(5); P3 = 0x4; Delay(5); } } void Delay(int count) { int i = 0, j = 0; for(i; i < count; i++) { for(j; j < 100; j++); } }The motor finally turned ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think , Is the delay added to give the motor response time , Or the previous beat hasn't had time to produce the corresponding effect , The next beat is coming , Too fast won't work ??????????????????
I won't go into details , Remember first .
More start beats , And reverse rotation , Because it's easy , I won't go into that .
The rate is controlled by the delay between beats ; Turn it in the opposite direction and turn it upside down ; The same is true for other beats .
边栏推荐
- @Use of data annotation (instead of get and set methods in entity classes)
- Redis learning
- How can hospitals achieve efficient and low-cost operation and maintenance? Is there any software that can meet it?
- Chapter 3 business function development (modifying clues, data echo and modifying data)
- 阿里云服务的网络解决方案
- Graduation project of wechat small program ordering system of small program completion works (4) opening report
- 提高代码可续性的小技巧,以connectTo方法为例。
- Numpy learning
- C # introductory series (30) -- exception handling
- JS cool rolling picture deformation animation JS special effects
猜你喜欢

Intelligent operation and maintenance scenario analysis: how to detect abnormal business system status through exception detection

DIY can decorate the mall system, you can also have!

Mongodb database
![[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)](/img/07/235785b7658b5ae022dfa3f53ec86d.png)
[ten thousand words long text] Based on LSM tree thought Net 6.0 C # realize kV database (case version)

Idea failed to start the project yamlexception Chinese file encoding format

Refreshing mobile terminal personal center page

Wechat sports field reservation of the finished works of the applet graduation project (4) opening report

25 Ph.D. degrees revoked
![[dark horse programmer] redis learning notes 002: persistence: RDB and AOF](/img/f2/77adb63718baf42501e5a62059ea0a.png)
[dark horse programmer] redis learning notes 002: persistence: RDB and AOF

Wechat sports ground reservation applet graduation project of applet completion works (1) development outline
随机推荐
Initial knowledge of WebService (generate jar packages and call methods in remote services)
@Principle of Autowired annotation
记录两次多端排查问题的过程
C#入门系列(三十) -- 异常处理
Chapter 3 business function development (query clues)
Talk about your transformation test development process
Source code of short video live broadcast system
nuscenes数据集3D MOT demo,端到端的目标检测和跟踪,检测跟踪联合框架
Rstudio shows that it can't connect to the web page, or it has a new website.
Sun Tzu's art of war
Apartment repair reporting system (idea, SSM, MySQL)
Redis学习
When crontab scheduled task executes jar through script, it encounters a pit where jar package execution is invalid
Refreshing mobile terminal personal center page
孙子兵法随感
这是我见过写得最烂的Controller层代码...
Blue and white porcelain used by Charles
C语言基础
Some easy-to-use plug-ins and settings installed in vscode
Graduation design of wechat small program ordering system of small program completion works (5) assignment


