PWM(脈衝寬度調製)

來源:互聯網
上載者:User

 

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%占空比(上一半的時間)。



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消失和縮小,那些小行的長度會增長和收縮。現在你就可以看到脈衝寬度。

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.