当前位置:网站首页>Principle and application of PWM
Principle and application of PWM
2022-06-12 07:15:00 【Snow falls on the devil's land】
What is? PWM
PWM(Pulse Width Modulation) Short for pulse width modulation , It is a very effective technology to control analog circuit by using digital output of microprocessor , Widely used in measurement 、 signal communication 、 Industrial control .
PWM The frequency of
It means in 1 In seconds , The number of times the signal goes from high level to low level and back to high level , In other words, one second PWM How many cycles are there , Company Hz.
PWM The cycle of
T=1/f,T It's a cycle ,f It's the frequency .
If the frequency is 50Hz , In other words, a cycle is 20ms, Then there will be... In a second 50 Time PWM cycle .
Duty cycle
Is a pulse period , The ratio of the time of high level to the time of the whole cycle , The unit is % (0%-100%)
The length of a cycle , As shown in the figure below .

among , The period is the time of a pulse signal ,1s Period within T The number of times is equal to the frequency f, Pulse width time refers to high-level time .
Above picture , Ratio of pulse width time to total cycle time , Is the duty cycle .
For example , The time of the cycle is 10ms, The pulse width time is 8ms, Then the duty cycle is 8/10= 80%, This is the duty cycle 80% Pulse signal of .
PWM It's pulse width modulation , The pulse width can be adjusted by adjusting the duty cycle .
PWM principle
With STM32 For example, SCM , Its IO The port can only output high level and low level .
Suppose the high level is 5V、 Low level is 0V, So to output different analog voltages, you need to use PWM. By changing IO The duty cycle of the square wave output from the port , Thus, the analog voltage signal simulated by the digital signal is obtained .
The voltage is applied to the analog load in a pulse sequence , High level when connected 1, Low level when disconnected 0. DC power supply output when connected , When disconnected, the DC power supply is disconnected . By controlling the on and off time , In theory , It can output any voltage value not greater than the maximum voltage 5V The analog voltage of .
For example , Duty ratio 50% That's half the high-level time , Half the low-level time . At a certain frequency , You can get the simulated 2.5V Output voltage . that 75% Duty cycle of , The resulting voltage is 3.75V, As shown in the figure below .

in other words , At a certain frequency , Different output analog voltages can be obtained through different duty cycles ,PWM It is through this principle that the digital analog signal conversion is realized .
PWM application
LED Breathing lights
Take the frequently used breathing lamp for example .
The eyes of ordinary people are very sensitive to 80Hz The above refresh rate has no flicker at all , So what we usually see LED The lamp , When its frequency is greater than 50Hz When , The human eye will produce a visual persistence effect , Basically, there is no flicker , But mistakenly thought it was a constant light LED The lamp .
Since no flicker can be seen at very high frequencies , The larger the duty cycle LED The brighter , The smaller the duty cycle LED The darker , Examples of related breathing lamps :STM32 in PWM Configuration and application of . therefore , When the frequency is constant , It can be changed with different duty cycles LED The brightness of the light , Make it reach the effect of a breathing lamp .
PWM Control of motor speed
The output of different voltages can be realized by adjusting the duty cycle , Realize the adjustment of motor speed .
For DC motors , The motor output pin is high-level, and the motor can rotate , When the output is high , The motor will turn , But it's speeding up bit by bit , When the high level suddenly turns to the low level , The motor will not stop because the inductance can prevent the sudden change of current , Will maintain the original speed , In reciprocating , The speed of the motor is the average voltage output in the cycle , So in essence, our speed regulation is to put the motor in a , It seems to stop , The state of rotating at full speed and not at full speed , Then the average speed in a cycle is the speed adjusted by our duty cycle .
In motor control , The higher the voltage , The faster the motor speed , And by PWM Output different analog voltages , The motor can reach different output speeds .
Of course , In motor control , Different motors have their own frequency Too low frequency will lead to unstable movement , If the frequency is just within the hearing range of the human ear , Sometimes you can hear a whistling sound . When the frequency is too high , The motor may not react , The normal motor frequency is 6-16kHZ It's better between .
PWM Control of steering gear
The steering gear is controlled by a fixed frequency , Give it different duty cycle to control different steering angle .
The frequency of the steering gear is usually 50HZ, That's one 20ms Left and right time base pulses , And the high-level part of the pulse is generally 0.5ms-2.5ms Range , To control different steering angles .
500-2500us Of PWM The high level part corresponds to the control 180 The steering gear 0-180 degree .
With 180 For example, angle servo , So the corresponding control relationship is :
0.5ms-------------0 degree ;1.0ms------------45 degree ;1.5ms------------90 degree ;2.0ms-----------135 degree ;2.5ms-----------180 degree ;
The figure below demonstrates the duty cycle from 1ms Change to 2ms when , The change of the corner .

边栏推荐
- 5 lines of code identify various verification codes
- The most understandable explanation of coordinate transformation (push to + diagram)
- Jackson XML is directly converted to JSON without writing entity classes manually
- Elegantly spliced XML
- Node, topic, parameter renaming and global, relative and private namespaces in ROS (example + code)
- Noi openjudge computes the n-th power of 2
- “我被大厂裁员了”
- Detailed explanation of coordinate tracking of TF2 operation in ROS (example + code)
- @DateTimeFormat @JsonFormat 的区别
- When SQL server2019 is installed, the next step cannot be performed. How to solve this problem?
猜你喜欢

ROS dynamic parameter configuration: use of dynparam command line tool (example + code)

Dépannage de l'opération cl210openstack - chapitre expérience

Detailed explanation of coordinate tracking of TF2 operation in ROS (example + code)

RT thread studio learning (IX) TF Card File System

8086/8088 instruction execution pipeline disconnection reason

“我被大厂裁员了”

Scons编译IMGUI

SQL -- course experiment examination

库里扛起了勇士对凯尔特人的第四场

5 ROS simulation modeling (4-navigation navigation simulation)
随机推荐
Pyhon的第六天
Planning and design of 1000 person medium-sized campus / enterprise network based on ENSP and firewall (with all configuration commands)
企业微信官方 加解密库 PHP7版本报错 mcrypt_module_open 未定义方法 并且被PHP抛弃 解决方法使用 openssl解决
SQL -- course experiment examination
Introduction to JDE object management platform and use of from
2022起重机械指挥考试题模拟考试平台操作
esp32 hosted
Some operations of MATLAB array
leetcode.39 --- 组合总和
Design an open source continuous deployment pipeline based on requirements
postman拼接替换参数循环调用接口
Scons编译IMGUI
Interview intelligence questions
Decoupling in D
Lambda function perfect use guide
@DateTimeFormat @JsonFormat 的区别
Error mcrypt in php7 version of official encryption and decryption library of enterprise wechat_ module_ Open has no method defined and is discarded by PHP. The solution is to use OpenSSL
最近面了15个人,发现这个测试基础题都答不上来...
Detailed explanation of multi coordinate transformation in ROS (example + code)
d的自动无垃集代码.