AccelStepper功能及函數功能(一)

本文爲原文翻譯,歡迎糾錯。

 

AccelStepper類引用

Detailed Description 詳細說明

Support for stepper motors with acceleration etc.

支持步進電機加速運行等

This defines a single 2 or 4 pin stepper motor, or stepper moter with fdriver chip, with optional acceleration, deceleration, absolute positioning commands etc. Multiple simultaneous steppers are supported, all moving at different speeds and accelerations.

這定義了一個2或4針單個步進電機,或驅動芯片驅動的步進電機,這些電機可定義加速,減速,絕對定位命令等。支持多個同步步進電機同時運行,所有步進電機都可以不同的速度和加速度運行。

Operation 運行

This module operates by computing a step time in microseconds. The step time is recomputed after each step and after speed and acceleration parameters are changed by the caller. The time of each step is recorded in microseconds. The run() function steps the motor once if a new step is due. The run() function must be called frequently until the motor is in the desired position, after which time run() will do nothing.

此模塊通過計算步長(以微秒爲單位)進行運行。在每一步之後,在調用函數更改速度和加速度參數之後,將重新計算步長時間。每一步的時間以微秒計。如果要執行新步驟,則run()函數將對電機執行一次步進。必須頻繁地調用run()函數,直到電機處於需要的位置,在此之後,run()將不執行任何操作。

Positioning 位置

Positions are specified by a signed long integer. At construction time, the current position of the motor is consider to be 0. Positive positions are clockwise from the initial position; negative positions are anticlockwise. The current position can be altered for instance after initialization positioning.

位置由帶符號的長整型定義。在運行時,電機的當前位置被認爲是0。初始位置順時針反向爲正;逆時針爲負。當前位置可以在初始化定位後更改。

Caveats 警告

This is an open loop controller: If the motor stalls or is oversped, AccelStepper will not have a correct idea of where the motor really is (since there is no feedback of the motor's real position. We only know where we think it is, relative to the initial starting point).

這是一個開環控制器:如果電機失速或超速,AccelStepper將不會識別電機的真正物理位置(因爲沒有反饋的電機的真正位置。我們只默認我們認爲它在相對於最初的起點的計算位置)。

Performance 執行

The fastest motor speed that can be reliably supported is about 4000 steps per second at a clock frequency of 16 MHz on Arduino such as Uno etc. Faster processors can support faster stepping speeds. However, any speed less than that down to very slow speeds (much less than one per second) are also supported, provided the run() function is called frequently enough to step the motor whenever required for the speed set. Calling setAcceleration() is expensive, since it requires a square root to be calculated.

在Arduino如Uno等的時鐘頻率爲16mhz的情況下,能夠可靠支持的最快電機速度約爲每秒4000步。更快的處理器可以支持更快的步進速度。然而,任何微小速度(遠低於一個每秒)也支持,提供了足夠頻繁run()函數調用以實現所需的速度。調用setAcceleration()是非常耗CPU資源,因爲它需要計算平方根。

Gregor Christandl reports that with an Arduino Due and a simple test program, he measured 43163 steps per second using runSpeed(), and 16214 steps per second using run();

Gregor Christandl報告說,用同一個Arduino Due和一個簡單的測試程序,他使用runSpeed()可達到每秒43163步,使用run()僅達到每秒16214步;

(按此來說,我使用的是1:120的減速電機,16細分,使用Run()函數,那實際最大速度爲16214/360/7.5/16=0.38圈每秒。且在循環內沒有多餘代碼執行的情況下)

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章