M♪o 之學習筆記本《丑》控制︰【紅火南】東籬南山

派生碼訊

丑 牛

陶淵明‧飲酒 其五

結盧在人境,面無車馬喧
問君何能爾,心遠地自偏
採菊東籬下,悠然見南山
山氣日夕佳,飛鳥相與還
此中有真意,欲辨以忘言。

紅火南︰ 鑽木取火,木雖燼,火可傳;思接千載,思愈,越益物。

 

派︰《思創》事物因何起?『傳記』長史一線牽,有心哉花花不發,無心插柳柳成蔭;心有靈犀一點通,窮經皓首難為功?若說到底︰真積力,久則入。人不能通,神來通!真情真事喜相逢!

mind_map

200px-Easy_Mandala

基本曼陀罗图

英國知名的心理學家托尼‧博贊 Tony Buzan 於一九七零年代提出『心智圖』mind map 工具一個『主題為中心勾畫心中想到的種種關聯』『觀點』,用以分析』、『理解』和『解決問題此『』繪看起來像心臟』與『血管』的網絡關係,真的用『心血』灌溉創造的想法 結晶

曼陀羅』藝術起源於佛教密宗,原本的目的與意義,雖然被日本金泉浩晃博士所『誤解 』,強加之以系統化的利用卻成為用於 5W1H 很好的計劃工具。有些人將之用於筆記』和備忘錄』,期望『記憶』能左右逢源,『靈感 』會泉湧不斷

那什麼是『創造』呢?『發明』可有一個『藍圖』?有人說人類有一種能力叫做『創造力』,又說這是一種唯獨人類才有的『綜合本領』,然後講這也是『一流』與『三流』人才區分的『分水嶺』。作者不知這種『創造力』是什麼樣的『力』?所以無法判斷那個敘述是否有說沒說什麼?只是心想假使人們如果知道很多□□』的歷史知道□□是如何的『從無到有』,那麼人們難道不會與發明不期而遇不能驚鴻一瞥創造』的源泉嗎??

 

生 ︰何謂『脈衝寬度調變』 PWM Pulse-width modulation  ?《 網 》網說︰

500px-Duty_cycle_general.svg

Fig. 1: a pulse wave, showing the definitions of y_{min}, y_{max} and D.

350px-Pwm.svg

Fig. 2: A simple method to generate the PWM pulse train corresponding to a given signal is the intersective PWM: the signal (here the red sinewave) is compared with a sawtooth waveform (blue). When the latter is less than the former, the PWM signal (magenta) is in high state (1). Otherwise it is in the low state (0).

Pulse-width modulation uses a rectangular pulse wave whose pulse width is modulated resulting in the variation of the average value of the waveform. If we consider a pulse waveform f(t), with period T, low value y_{min}, a high value y_{max} and a duty cycle D (see figure 1), the average value of the waveform is given by:

<br /> \bar y=\frac{1}{T}\int^T_0f(t)\,dt.<br />

As f(t) is a pulse wave, its value is y_{max} for 0<t<D\cdot T and y_{min} for D\cdot T <t<T. The above expression then becomes:

"<br

This latter expression can be fairly simplified in many cases where y_{min}=0 as \bar y=D\cdot y_{max}. From this, it is obvious that the average value of the signal (\bar y) is directly dependent on the duty cycle D.

The simplest way to generate a PWM signal is the intersective method, which requires only a sawtooth or a triangle waveform (easily generated using a simple oscillator) and a comparator. When the value of the reference signal (the red sine wave in figure 2) is more than the modulation waveform (blue), the PWM signal (magenta) is in the high state, otherwise it is in the low state.

 

☆ 編者言說明

這《 網 》網,大概是校園網路之『百科全書』的吧!或可以參考

Adafruit’s Raspberry Pi Lesson 9. Controlling a DC Motor 》之文章。

Using PWM in RPi.GPIO

To create a PWM instance:

p = GPIO.PWM(channel, frequency)

To start PWM:

p.start(dc) # where dc is the duty cycle (0.0 <= dc <= 100.0)

To change the frequency:

p.ChangeFrequency(freq) # where freq is the new frequency in Hz

To change the duty cycle:

p.ChangeDutyCycle(dc) # where 0.0 <= dc <= 100.0

To stop PWM:

p.stop()

Note that PWM will also stop if the instance variable ‘p’ goes out of scope.

 

碼 ︰無 習 。☿☹

 

行 ︰雖無有瑞士軍刀,何妨效法馬蓋仙,兩根母母線,一個『一千』導阻,玩個過癮︰☿☺!

pi@raspberrypi ~ $ sudo -s
root@raspberrypi:/home/pi# python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import RPi.GPIO as GPIO
>>> from time import sleep
>>> GPIO.setmode(GPIO.BCM)
>>> GPIO.setup(47, GPIO.OUT)
__main__:1: RuntimeWarning: This channel is already in use, continuing anyway.  Use GPIO.setwarnings(False) to disable warnings.
>>> GPIO.setup(8, GPIO.OUT)
>>> p = GPIO.PWM(8, 2)
>>> p.start(50)
>>> GPIO.setup(11, GPIO.IN)
>>> while True:
...     if GPIO.input(11) == 1:
...         GPIO.output(47, GPIO.HIGH)
...     else:
...         GPIO.output(47, GPIO.LOW)
...     sleep(0.01)

峰迴路可轉,取值之法需細思量。

 

訊 ︰ ☿ 山窮水盡疑無路,柳暗花明又一村。