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圈每秒。且在循环内没有多余代码执行的情况下)

 

 

 

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