MotorHat/Stepper

(require("MotorHat/Stepper"))(opts) → {module:MotorHat/Stepper~stepper}

Creates a stepper motor controller.
Pass in an options object to generate an uninitialized StepperLib object.

Parameters:
Name Type Description
opts Object

Servo controller initialization options.

Properties
Name Type Attributes Description
pwm Object

PWM Interface Object

frequency Number

PWM Controller frequency for the stepper.

pins Object

Pin definition for the motor.

Properties
Name Type Description
W1 Object

Pin definition for winding 1 of the stepper

Properties
Name Type Description
PWM Number

Pin number of the PWM output for winding 1.

IN1 Number

Pin number of the first coil output for winding 1.

IN2 Number

Pin number of the second coil output for winding 1.

W2 Object

Pin definition for winding 2 of the stepper

Properties
Name Type Description
PWM Number

Pin number of the PWM output for winding 2.

IN1 Number

Pin number of the first coil output for winding 2.

IN2 Number

Pin number of the second coil output for winding 2.

steps Number

Steps per revolution of the stepper motor.

style 'single' | 'double' | 'interleaved' | 'microstep'

Stepping style

microsteps 8 | 16

number of microsteps per step.

sps Number <optional>

Steps per second.

pps Number <optional>

Pulses per second.

rpm Number <optional>

Revolutions per minute.

Source:
Basic Usage:
const opts = {
pwm: pwm,
pins: {
W1: {
PWM: 8,
IN1: 10,
IN2: 9,
},
W2: {
PWM: 13,
IN1: 11,
IN2: 12,
},
steps: 540, // Steps per motor revolution
style: 'microstep', // 'single', 'double', 'interleaved' or 'microstep'
microsteps: 16, // If commanding with microsteps, do 8 or 16?
frequency: 1600, // PWM controller work freq
sps: 20, // Steps per second. Also possible to set rpm or pps (pulses per second)
};
const stepper = require('./stepper.js')(opts).init();
Returns:
Type
module:MotorHat/Stepper~stepper

Namespaces

stepper