Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
stepper-wiringpi
Advanced tools
Control a stepper motor from the Raspberry Pi.
The package can be installed using npm
.
$ npm install stepper-wiringpi
The class controls a stepper motor. It has a number of core capabilities that are motor related. First we have the notion of the rotation speed. This is measured in rotations per minute (RPM) and is adjusted with the call to:
motor.setSpeed(60);
which would set the RPM of the motor to one rotation a second. Setting the speed doesn't actually cause the motor to turn. We would then call one of the direction functions which are:
motor.forward();
and
motor.backward();
Calling either of these starts the motor turning at the currently set speed. If we change the speed while the motor is rotating, it will change the rate of rotation.
If we wish to stop a motor from turning, we can call:
motor.stop();
We do not have to stop a motor before changing direction. We can choose to call:
motor.forward();
motor.backward();
There is a second mode of operation where we can specify an exact number of steps to turn and the motor will rotate those steps at the current speed.
motor.step(10);
will rotate the motor forwards 10 steps while
motor.step(-10);
the step
function has an additional optional parameter which is a callback function that is invoked when the steps have been made.
will rotate the motor backwards 10 steps.
To mechanically use the package, first we include the package with a call to require
naming the package we wish to include.
var StepperWiringPi = require("stepper-wiringpi");
From here, we can create instances of a stepper motor driver using:
var motor = StepperWiringPi.setup(stepsInRevolution, pin1, pin2, pin3, pin4);
The object returned is an instance of a motor that can be driven.
To support multiple stepper motor physical types, the package supports 2, 4 and 5 wire interfaces. The choice of which type is used
is specified by the number of pins supplied in the setup
call.
In summary, the methods are:
Method | Description |
---|---|
setup(stepsInRevolution, pin1, pin2, [pin3, pin4, [pin5]]) | Setup the motor |
setSpeed(rpm) | Set the speed of rotation |
forward() | Start rotating forwards |
backward() | Start rotating backwards |
stop() | Stop rotating |
step(steps, [callback]) | Step the motor |
halt() | Halt the motor (free turn) |
This package depends upon:
This package is a port of the Arduino Stepper library to Node.js and the Node.js WiringPi package. Re-designs were made to include support for JavaScript oriented usage such as non-blocking. The original Arduino stepper library can be found here:
https://github.com/arduino/Arduino/tree/master/libraries/Stepper
It is anticipated that one use of this package will be to control wheeled robots. Because of this, it will likely be necessary to support multiple instances of the class, one per motor.
Given that each motor requires 2, 4 or 5 discrete GPIO pins, we can see that we will quickly run out of available pins on todays current devices. For example, for a 2 wheeled robot using 4 pin stepper motors, we will immediately consume 8 GPIOs. This leads us to believe that we may very well need to include support for popular GPIO expanders. An idea/issue has been raised with the Wiring-Pi project for Node.js to investigate the addition of that support into the base Wiring-Pi package which is where we believe it should be implemented.
FAQs
Module to control a stepper motor
We found that stepper-wiringpi demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.