在PWM控制下的直流有刷電機性能優化


結論

為了避免各位浪費時間, 先說結論: 選擇合適的電機驅動模式和PWM頻率, 能大幅提升直流電機的性能和可控性, 在常見的48:1減速電機上, 使用慢衰減模式低於100Hz的PWM頻率, 能達到最佳性能.

引言

在一些場合, 需要在慢速下精細控制機械的運轉和制動, 但是你會發現電機的啟動不是漸進的, 會突然產生速度, 然后又突然停止, 雖然也用了PWM控制速度, 但是為什么速度的變化不均勻呢? 一個明顯的原因是, 有刷直流電機在轉速低於200RPM(200轉每分鍾)時如果沒有經過調校, 很難得到足夠的扭矩來保持穩定轉動, 而在高速的區間, 速度的變化也不是線性的. 通過一些實驗發現, 可以通過調整PWM參數改善這些問題. 這篇文章將盡量詳細地說明這些信號參數, 並例舉一些常見的電機的測試結果, 希望通過這些數據可以改進你們項目中的電機性能.

首先讓我們看看PWM和直流有刷電機.

PWM 和直流有刷電機

有刷直流電機對於輸入的直流電壓產生磁力並轉動, 例如工作在6V的小電機在使用4節AA電池時全速轉動, 而在使用3節AA電池供電時速度就會慢一些, 使用2節時就會更慢. 在實際應用中加減電池數量是不現實的, 需要通過軟件來控制, 這就是PWM(Pulse Width Modulation, 脈沖寬度調制). 微控制器一般通過外置的電機驅動模塊來控制電機工作, 通過PWM信號控制電機的方向, 速度和扭矩. PWM信號一般包含三個主要特性: 占空比, 衰減模式和頻率.

占空比

占空比(Duty Cycle)就是在一個完整的PWM周期中, 高電平脈沖在時間上占的比例, 通常使用一個百分數來表示. 對應的 PWM 等價電壓就是供電電壓乘以占空比這個百分比. PWM脈沖的寬度由代碼控制, 越寬輸出的能量就越高, 電機運轉就越快. 當直接連接到供電電壓上時, 就等價於一個100%占空比的PWM信號.

通過占空比可以控制電機的速度, 但是電流衰減模式和PWM信號頻率的選擇會影響到電機的工作效率, 特別是當占空比小於30%的情況.

衰減模式

電機的再循環電流衰減模式是當前電機控制方面一個特殊的特性. 可以區分為快衰減和慢衰減. 在最簡單的電機控制中, 通過一個開關控制電機的工作和停止, 開關合上時電機運轉, 在開關斷開時, 電機失去動力並自行減速並停止. 這種情況叫快衰減, 因為輸入的電流迅速減小. 這種模式也稱為滑落模式因為電機在開關關閉后是自由滑落到停止狀態.

而在很多場合, 例如在邊緣運行的機器, 相對於自由滑落停止, 我們更希望有剎車控制, 這時候慢衰減模式就更適合這種場合. 這種模式通過利用電機轉動時的發電效應增加了可控性.

電機的發電效應很容易驗證, 用一個小電機連上LED發光管, 在轉動電機時發光管就會亮, 這說明電機轉動時會反向輸出電壓. 這種現象稱為電動勢, EMF(electro-motive force), 單位也是伏特, 和電壓一樣.

當電機自由停轉時就會產生電壓, 如果將電機的輸入端短接, 那么產生的EMF會讓電機反方向轉動, 這將導致電機快速停止, 就像剎車一樣. 電機驅動, 例如DRV8833在慢衰減模式下會主動剎車, 之所以稱為慢衰減模式, 時因為電機此時還在用它自己產生的電流來工作, 電流並沒有立即消失. 有些地方也稱這種模式為剎車模式.

The Yellow-TT motor's spin threshold decreases to 1200 RPM when operating in slow decay mode compared to 3000 RPM for fast decay mode. That means that the output shaft of the 1:48 gearbox turns the attached wheel at 25 RPM versus 63 RPM; forward speed drops to 8.5 cm/sec from 21.4 cm/sec.

Also note that the speed versus motor voltage curve for slow decay (blue line) is more linear than fast decay (green line). The linear relationship between speed and voltage simplifies calculating motor speed from the throttle value.

equivalent_voltage = power_supply * throttle

motor_speed = (2500 * equivalent_voltage) - 2000

gearbox_speed = motor_speed / 48

With a 5-volt power supply, the motor and gearbox output shaft speeds for a throttle setting of 0.5 are 4250 RPM and 88.5 RPM.

equivalent_voltage = 5 * 0.5= 2.5

motor_speed = (2500 * 2.5) - 2000 = 4250

gearbox_speed = 4250 / 48 = 88.5

Decay mode terminology is confusing. Remember that the decay mode describes how quickly the motor recirculation current dissipates, not its effect on motor speed. A motor's rotational speed drops more quickly when using slow decay mode (braking) as compared to fast decay (coasting).

Selecting the proper current decay mode for your project will go a long way to fine-tuning required brushed DC motor performance. One other PWM parameter, frequency, is useful for increasing low-speed torque and lowering the throttle value needed to start the motor spinning.

PWM頻率

PWM頻率就是每秒輸出的PWM周期數, 單位是Hz, 在數學上等於周期長度的倒數 (PWM_Frequency = 1 / PWM_Interval_Period).

當計算PWM等價電壓時, 我們通常假定電機工作於一個理想狀態的非PWM的電源提供的電壓. 但是實際情況和這個差距很大. 例如對於常見的48:1小電機, 在連接1.5V的電池時可以輕松啟動, 但是在PWM等價電壓為1.5V時卻紋絲不動, 直到等價電壓上升到2V時才開始轉動, 然而一開始轉動就迅速爬升到4000RPM.

這種情況, 是因為有刷直流電機的轉子都包含兩個/三個或更多纏繞在鐵芯或其他磁性材料上的線圈, 電機在電路上類似於一個電感, 取決於匝數的大小和磁芯的材料, 線圈通常需要幾個毫秒才能達到起足夠推動其軸轉動的力矩. 所以在使用PWM進行電機速度控制時轉子線圈的電感就成為一個很大的影響因素. 直接使用直流電壓供電時電機線圈的工作狀態是最好的, 因為磁場達到轉動的強度需要足夠的時間. 而對於高頻PWM, 加在電機線圈上的脈沖變化太快, 就會導致線圈在脈沖寬度上無法達到轉動所需的力矩而無法轉動. 此時如果在占空比不變的前提下降低PWM的頻率, 隨着PWM頻率的降低, 脈沖寬度是在增加的, 當頻率降低到某個數值之后, 脈沖的寬度就足夠電機線圈產生帶動轉子的力矩. 這樣, 電機就能在更低的PWM等價電壓上啟動.

對於常見的48:1小電機, 最佳的工作頻率接近25Hz. 當頻率為25Hz時, 電機在等價電壓為0.5V時就能開始工作, 此時轉速可以低至100RPM. 因為齒輪將轉速減為1/48, 所以此時車輪轉速才2RPM.

選擇衰減模式和頻率

慢衰減常用於控制有刷直流電機, 因為它可以有效制動. 另外它也能幫助占空比和電機速度保持線性關系.

比較一下這兩種模式, 如果需要慢速操作, 慢衰減可以增加有效力矩並增加電機的整體速度范圍. Choosing slow decay also provides a linear mapping of the software throttle setting to motor speed which is helpful when measuring velocity and distance traveled.

Slow decay mode appears to be superior in most categories, but isn't the best choice if power consumption is your primary concern. For some battery-powered robots, the power saved using fast decay mode outweighs the more precise control offered by slow current decay.

Fast decay mode is the default mode in CircuitPython motor control libraries. Changing the operational mode parameter to slow decay can be accomplished with a simple, one-line statement. See the Code Examples section for the details.

After changing the mode, test the operation to confirm that the lowest required motor speed is working as needed. If a lower spin threshold is required, try reducing the PWM frequency to the lowest possible value (usually about 25Hz) and work up towards the maximum of the motor controller. Choose the frequency that provides the best balance of torque throughout the desired speed range while balancing the motor chatter that can happen at lower frequencies.

As a rule of thumb, most small brushed DC motors will operate nicely with a PWM frequency of 50Hz to 100Hz and slow decay mode. Projects like the StringCar Racer that don't use gearbox motors seem to work best at 25Hz.

In combination with its CircuitPython library, a motor controller board will offer a range of selectable PWM frequencies as well as decay mode. The table above shows the available frequency range and mode support for a variety of Adafruit motor controllers. Refer to the Code Examples section for how to select a specific decay mode and PWM frequency for your motor controller board.

參考


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM