Arduino问答实验室

Arduino 的 PWM (脉冲宽度调制) 说明-官网翻译,适合新手。2条评论

作者:学长   发布于:2013年9月1日 15:26:03 周日    分类: Arduino    3173 人浏览

PWM (脉冲宽度调制) 


The Fading example demonstrates the use of analog output (PWM) to fade an LED. It is available in the File->Sketchbook->Examples->Analog menu of the Arduino software.

Fading 的示例展示了使用模拟输出(PWM)来让 LED 渐暗,可以从 Arduino-IDE 的菜单  File->Sketchbook->Examples->Analog 打开。


Pulse Width Modulation, or PWM, is a technique for getting analog results with digital means. Digital control is used to create a square wave, a signal switched between on and off. This on-off pattern can simulate voltages in between full on (5 Volts) and off (0 Volts) by changing the portion of the time the signal spends on versus the time that the signal spends off. The duration of "on time" is called the pulse width. To get varying analog values, you change, or modulate, that pulse width. If you repeat this on-off pattern fast enough with an LED for example, the result is as if the signal is a steady voltage between 0 and 5v controlling the brightness of the LED.

脉冲宽度调制或称PWM,是通过数字均值获得模拟结果的技术。数字控制被用来创建一个方波,信号在开和关之间切换。这种开关模式通过改变“开”时间段和“关”时间段的比值完全模拟从开(5伏特)和关(0伏特)之间的电压。“开时间“的周期称为脉冲宽度。为了得到不同的模拟值,你可以更改,或调节脉冲宽度。如果你重复这种开关模式速度足够快,其结果是一个介于0和5V之间的稳定电压用以控制LED的亮度。
 
In the graphic below, the green lines represent a regular time period. This duration or period is the inverse of the PWM frequency. In other words, with Arduino's PWM frequency at about 500Hz, the green lines would measure 2 milliseconds each. A call to analogWrite() is on a scale of 0 - 255, such that analogWrite(255) requests a 100% duty cycle (always on), and analogWrite(127) is a 50% duty cycle (on half the time) for example.
下图中,绿色线表示一个固定的时间期限。此持续时间或周期是PWM的频率的倒数。换言之,Arduino的PWM频率约为500Hz,每个绿线之间表示2毫秒。一个analogWrite()的调用区间为0- 255,例如analogWrite(255)需要100%占空比(常开),和analogWrite(127)是50%占空比(上一半的时间)。
 
pwm.gif
 
Once you get this example running, grab your arduino and shake it back and forth. What you are doing here is essentially mapping time across the space. To our eyes, the movement blurs each LED blink into a line. As the LED fades in and out, those little lines will grow and shrink in length. Now you are seeing the pulse width.

一旦你运行这个例子,抓住你的Arduino来回摇晃。你这么做的实质上就是时间对空间的映射。在我们的眼睛看来,每个运动模糊成一条线的LED闪烁。由于LED渐亮和渐暗,那些LED 形成的线的长度会增长和缩短。现在你看到的就是脉冲宽度。


译注,最后一段翻得的不是很好,但时间所迫也只能先这样,有空再修改吧。


Arduino问答实验室- 本站版权
1、本主题由文章作者发表,文章作者与Arduino问答实验室享有文章相关版权
2、转载或引用本文时请同时征得文章作者和Arduino问答实验室的同意
3、本站部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责
4、如本帖侵犯到任何版权问题,请立即告知本站即时予与以处理
5、原文链接:www.985z.com/?post=24
二维码
继续查看有关 arduino analogWirte PWM 的文章

2访客评论

  • janffe
    对最后一段不是很明白,麻烦作者更新一下?主要是对原理不懂

    2013-11-20 16:09 回复

    • 学长
      @janffe:其实最后一段不是那麽重要,只是在说明脉冲的时间长度。
      只不过越说明,反而越模糊了。

      2013-12-16 14:47 回复

我来说说

*

*