AccelStepper功能及函數功能(二)

AccelStepper Class Reference  AccelStepper類引用

Support for stepper motors with acceleration etc. More...

支持步進電機加減速等

#include <AccelStepper.h>

Public Types 公共類型

enum   MotorInterfaceType { 
  FUNCTION = 0, DRIVER = 1, FULL2WIRE = 2, FULL3WIRE = 3, 
  FULL4WIRE = 4, HALF3WIRE = 6, HALF4WIRE = 8 
}
 

Symbolic names for number of pins. Use this in the pins argument the AccelStepper constructor to provide a symbolic name for the number of pins to use. More...

針數的符號名稱。在引腳參數AccelStepper構造函數中使用它,爲要使用的引腳數量提供一個符號名稱。

 

Public Member Functions公共成員函數

  AccelStepper (uint8_t interface=AccelStepper::FULL4WIRE, uint8_t pin1=2, uint8_t pin2=3, uint8_t pin3=4, uint8_t pin4=5, bool enable=true) 設置電機類型
 
  AccelStepper (void(*forward)(), void(*backward)())
 
void  moveTo (long absolute) 移動到絕對位置
 
void  move (long relative) 移動相對位置
 
boolean  run () 帶加減速運行
 
boolean  runSpeed () 恆速運行
 
void  setMaxSpeed (float speed)  設置最大速度
 
float  maxSpeed () 獲取最大速度
 
void  setAcceleration (float acceleration) 設置加速度
 
void  setSpeed (float speed) 設置速度
 
float  speed () 獲取當前速度
 
long  distanceToGo () 
 
long  targetPosition () 目標位置
 
long  currentPosition () 獲取當前位置
 
void  setCurrentPosition (long position) 設置到前位置
 
void  runToPosition () 以加減速的方式運行到指定位置
 
boolean  runSpeedToPosition () 以恆定速度運行到指定位置
 
void  runToNewPosition (long position) 運動到一個新的位置
 
void  stop () 停止點擊運動
 
virtual void  disableOutputs () 不使能輸出引腳
 
virtual void  enableOutputs () 使能輸出引腳
 
void  setMinPulseWidth (unsigned int minWidth)  設置最小脈衝寬度
 
void  setEnablePin (uint8_t enablePin=0xff)  設置使能引腳
 
void  setPinsInverted (bool directionInvert=false, bool stepInvert=false, bool enableInvert=false) 
 
void  setPinsInverted (bool pin1Invert, bool pin2Invert, bool pin3Invert, bool pin4Invert, bool enableInvert)
 
bool  isRunning () 判斷電機是否仍在運行
 

Protected Types保護類型

enum   Direction { DIRECTION_CCW = 0, DIRECTION_CW = 1 }
 

Direction indicator Symbolic names for the direction the motor is turning. More...

方向指示器電機旋轉方向的符號名稱

 

Protected Member Functions受保護的成員函數

void  computeNewSpeed () 計算新的速度
 
virtual void  setOutputPins (uint8_t mask)  設置輸出引腳
 
virtual void  step (long step) 
 
virtual void  step0 (long step)
 
virtual void  step1 (long step)
 
virtual void  step2 (long step)
 
virtual void  step3 (long step)
 
virtual void  step4 (long step)
 
virtual void  step6 (long step)
 
virtual void  step8 (long step)
 

Protected Attributes 受保護的屬性

boolean  _direction
 

Detailed Description 功能詳述見第一部分

第一部分連接如下:

https://blog.csdn.net/wenguitao/article/details/104857586

Member Enumeration Documentation 枚舉成員清單

◆ Direction  方向

enum AccelStepper::Direction
protected

Direction indicator Symbolic names for the direction the motor is turning.

方向指示器電機旋轉方向的符號名稱。

Enumerator
DIRECTION_CCW 

Counter-Clockwise.

DIRECTION_CW 

Clockwise.

◆ MotorInterfaceType 電機接口類型

enum AccelStepper::MotorInterfaceType

Symbolic names for number of pins. Use this in the pins argument the AccelStepper constructor to provide a symbolic name for the number of pins to use.

針數的符號名稱。在引腳參數AccelStepper構造函數中使用它,爲要使用的引腳數量提供一個符號名稱。

Enumerator
FUNCTION 

Use the functional interface, implementing your own driver functions (internal use only)

使用函數接口,實現自己的驅動程序功能(僅供內部使用)

DRIVER 

Stepper Driver, 2 driver pins required. 驅動器驅動,需要2個引腳,一個方向,一個是脈衝。

FULL2WIRE 

2 wire stepper, 2 motor pins required 2線電機

FULL3WIRE 

3 wire stepper, such as HDD spindle, 3 motor pins required 3線電機

FULL4WIRE 

4 wire full stepper, 4 motor pins required 4線全步電機

HALF3WIRE 

3 wire half stepper, such as HDD spindle, 3 motor pins required 3線半步電機

HALF4WIRE 

4 wire half stepper, 4 motor pins required 4線半步電機

Constructor & Destructor Documentation

構造函數和析構函數

◆ AccelStepper() [1/2]

AccelStepper::AccelStepper ( uint8_t  interface = AccelStepper::FULL4WIRE,
    uint8_t  pin1 = 2,
    uint8_t  pin2 = 3,
    uint8_t  pin3 = 4,
    uint8_t  pin4 = 5,
    bool  enable = true 
  )    

Constructor. You can have multiple simultaneous steppers, all moving at different speeds and accelerations, provided you call their run() functions at frequent enough intervals. Current Position is set to 0, target position is set to 0. MaxSpeed and Acceleration default to 1.0. The motor pins will be initialised to OUTPUT mode during the constructor by a call to enableOutputs().

構造函數。您可以有多個同步步進器,它們都以不同的速度和加速度移動,前提是您以足夠頻率的間隔調用它們的run()函數。當前位置設置爲0,目標位置設置爲0。MaxSpeed和加速度默認爲1.0。在構造函數期間,通過調用enableoutput()將電機引腳初始化爲輸出模式。

Parameters 參數

[in] interface

Number of pins to interface to. Integer values are supported, but it is preferred to use the MotorInterfaceType symbolic names. AccelStepper::DRIVER (1) means a stepper driver (with Step and Direction pins). If an enable line is also needed, call setEnablePin() after construction. You may also invert the pins using setPinsInverted(). Caution: DRIVER implements a blocking delay of minPulseWidth microseconds (default 1us) for each step. You can change this with setMinPulseWidth()AccelStepper::FULL2WIRE (2) means a 2 wire stepper (2 pins required). AccelStepper::FULL3WIRE (3) means a 3 wire stepper, such as HDD spindle (3 pins required). AccelStepper::FULL4WIRE (4) means a 4 wire stepper (4 pins required). AccelStepper::HALF3WIRE (6) means a 3 wire half stepper, such as HDD spindle (3 pins required) AccelStepper::HALF4WIRE (8) means a 4 wire half stepper (4 pins required) Defaults to AccelStepper::FULL4WIRE (4) pins.

接口的引腳數。支持整型數值,但建議使用MotorInterfaceType符號名。 AccelStepper::DRIVER (1) 是指一個步進驅動器(帶有步進數和方向針腳)。如果還需要使能針腳,那麼在構造之後調用setEnablePin()。你也可以使用setPinsInverted()來翻轉引腳。注意:驅動程序爲每一步實現一個minPulseWidth微秒的阻塞延遲(默認1us)。您可以使用setMinPulseWidth()來更改它。AccelStepper::FULL2WIRE (2)表示2線步進電機(需要2個引腳)。AccelStepper::FULL3WIRE (3)表示3線步進電機。例如硬盤主軸(需要3個針)。 AccelStepper :: FULL4WIRE(4)表示4線步進電機(需要4個引腳)。 AccelStepper :: HALF3WIRE(6)表示3線半步進電機,例如HDD主軸(需要3個引腳)AccelStepper :: HALF4WIRE(8)表示4線半步進器(需要4個引腳)默認爲AccelStepper :: FULL4WIRE(4) 針腳。

[in] pin1

Arduino digital pin number for motor pin 1. Defaults to pin 2. For a AccelStepper::DRIVER (interface==1), this is the Step input to the driver. Low to high transition means to step)

電機引腳1的Arduino數字引腳號默認爲pin 2。對於AccelStepper::DRIVER(接口==1),這是驅動程序的步數脈衝輸入。從低到高的轉變意味着步進)

[in] pin2

Arduino digital pin number for motor pin 2. Defaults to pin 3. For a AccelStepper::DRIVER (interface==1), this is the Direction input the driver. High means forward.

電機引腳2的Arduino數字引腳號默認爲pin 3。對於AccelStepper::DRIVER(接口==1),這是驅動程序的方向輸入。置高意味着前進。

[in] pin3

Arduino digital pin number for motor pin 3. Defaults to pin 4.

Arduino數字引腳號碼爲電機引腳3。默認爲pin 4。

[in] pin4

Arduino digital pin number for motor pin 4. Defaults to pin 5.

Arduino數字引腳號碼爲電機引腳4。默認爲pin 5。

[in] enable

If this is true (the default), enableOutputs() will be called to enable the output pins at construction time.

如果值爲ture(默認值),將調用enableoutput()以在構建時啓用輸出引腳。

References _directionDIRECTION_CCWenableOutputs(), and setAcceleration().

 

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