Stepper Controller Object
- Source:
- See:
-
- Use Stepper() for object creation.
- Use module:MotorHat/Stepper~stepper#init for object initialization.
Methods
init(cbopt) → {module:MotorHat/Stepper~stepper}
Initialize the Stepeper controller instance.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
cb |
callback |
<optional> |
Optional node style callback for asynch initialization |
- Source:
Returns:
Returns init'd Stepper controller object (self),
either directly or in second parameter to callback if callback provided, to enable chaining.
oneStep(dir, cb)
Perform one step asynchronously.
Configuration as stepping style, speed, etc should have been set previously.
Parameters:
Name | Type | Description |
---|---|---|
dir |
'fwd' | 'back' | Direction of movement |
cb |
callback | Node style callback. cb(err, result). |
- Source:
oneStepSync(dir)
Perform one step asynchronously.
Configuration as stepping style, speed, etc should have been set previously.
Parameters:
Name | Type | Description |
---|---|---|
dir |
'fwd' | 'back' | Direction of movement |
- Source:
release(cb)
Release the stepper motor asynchronously.
Stops applying current to the motor coils.
Parameters:
Name | Type | Description |
---|---|---|
cb |
Callback | Node style callback |
- Source:
releaseSync()
Release the stepper motor synchronously.
Stops applying current to the motor coils.
- Source:
setCurrent(current)
Set the current rate at which to supply the steps.
Provide a number from 0 to 1 and the current will be reduced proportionally
Parameters:
Name | Type | Description |
---|---|---|
current |
Number | Current rate, from 0 to 1. |
- Source:
setFrequency(freq, cb)
Set PWM Controller working frequency asynchronously.
Parameters:
Name | Type | Description |
---|---|---|
freq |
Number | PWM frequency. |
cb |
callback | Node style callback. cb(err, result). |
- Source:
setFrequencySync(freq)
Set PWM Controller working frequency synchronously.
Parameters:
Name | Type | Description |
---|---|---|
freq |
Number | PWM frequency. |
- Source:
setMicrosteps(ms)
Set desired number of microsteps per step.
(Used for microstepping)
Parameters:
Name | Type | Description |
---|---|---|
ms |
8 | 16 | Microsteps per step |
- Source:
setSpeed(speed)
Set motor speed for step().
Parameters:
Name | Type | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
speed |
Object |
Properties
|
- Source:
setSteps(steps)
Set number of steps per revolution for motor.
Parameters:
Name | Type | Description |
---|---|---|
steps |
Number | Number of steps per revolution for stepper motor. |
- Source:
setStyle(style)
Set stepping style.
Parameters:
Name | Type | Description |
---|---|---|
style |
'single' | 'double' | 'interleaved' | 'microstep' | Stepping style. |
- Source:
step(dir, steps, cb) → {module:MotorHat/Stepper~stepper.StepResult}
Perform arbitrary number of steps asynchronously.
Configuration as stepping style, speed, etc should have been set previously.
Parameters:
Name | Type | Description |
---|---|---|
dir |
'fwd' | 'back' | Direction of movement |
steps |
Number | Number of steps. |
cb |
callback | Node style callback. cb(err, result). |
- Source:
Returns:
result The result of the action.
stepSync(dir, steps) → {module:MotorHat/Stepper~stepper.StepSyncResult}
Perform arbitrary number of steps synchronously.
Configuration as stepping style, speed, etc should have been set previously.
Parameters:
Name | Type | Description |
---|---|---|
dir |
'fwd' | 'back' | Direction of movement |
steps |
Number | Number of steps. |
- Source:
Returns:
result The result of the action.
Type Definitions
StepResult
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
StepResult.steps |
Number | Performed steps |
StepResult.dir |
String | Direction of steps performed |
StepResult.duration |
Number | Time in ms taken to perform the steps |
StepResult.retried |
Number | Number of steps retried. |
- Source:
StepSyncResult
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
StepResult.steps |
Number | Performed steps |
StepResult.dir |
String | Direction of steps performed |
StepResult.duration |
Number | Time in ms taken to perform the steps |
- Source: