Skip to content

Commit

Permalink
firmataAccelStepper
Browse files Browse the repository at this point in the history
First commit
  • Loading branch information
dtex committed Aug 27, 2017
1 parent 0523f58 commit 750c07c
Show file tree
Hide file tree
Showing 7 changed files with 1,193 additions and 128 deletions.
32 changes: 32 additions & 0 deletions examples/stepper-accel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var Board = require("../");

Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}

var board = new Board(port.comName);

board.on("ready", function() {

board.accelStepperConfig({
deviceNum: 0,
type: board.STEPPER.TYPE.FOUR_WIRE,
motorPin1: 5,
motorPin2: 6,
motorPin3: 7,
motorPin4: 8,
stepType: board.STEPPER.STEPTYPE.WHOLE
});

board.accelStepperSpeed(0, 400);
board.accelStepperAcceleration(0, 100);
board.accelStepperStep(0, 2000);

board.on("stepper-done-0", function(position) {
console.log("Current position: " + position);
});

});
});
32 changes: 32 additions & 0 deletions examples/stepper-driver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
var Board = require("../");

Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}

var board = new Board(port.comName);

board.on("ready", function() {

board.accelStepperConfig({
deviceNum: 0,
type: board.STEPPER.TYPE.DRIVER,
stepPin: 5,
directionPin: 6,
enablePin: 2,
invertPins: [2]
});

board.accelStepperSpeed(0, 400);
board.accelStepperAcceleration(0, 100);
board.accelStepperEnable(0, true);
board.accelStepperStep(0, 200);

board.on("stepper-done-0", function(position) {
console.log("Current position: " + position);
});

});
});
57 changes: 57 additions & 0 deletions examples/stepper-multi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var Board = require("../");

Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}

var board = new Board(port.comName);

board.on("ready", function() {

board.accelStepperConfig({
deviceNum: 0,
type: board.STEPPER.TYPE.FOUR_WIRE,
motorPin1: 5,
motorPin2: 6,
motorPin3: 7,
motorPin4: 8,
stepType: board.STEPPER.STEPTYPE.WHOLE
});

board.accelStepperConfig({
deviceNum: 1,
type: board.STEPPER.TYPE.FOUR_WIRE,
motorPin1: 9,
motorPin2: 10,
motorPin3: 11,
motorPin4: 12,
stepType: board.STEPPER.STEPTYPE.HALF
});

board.accelStepperSpeed(0, 400);
board.accelStepperSpeed(1, 400);

board.multiStepperConfig({
groupNum: 0,
devices: [0, 1]
});

board.multiStepperTo(0, [2000, 3000]);

board.on("multi-stepper-done-0", function() {
board.accelStepperReportPosition(0);
board.accelStepperReportPosition(1);
});

board.on("stepper-position-0", function(value) {
console.log("Stepper 0 position: " + value);
});

board.on("stepper-position-1", function(value) {
console.log("Stepper 1 position: " + value);
});

});
});
29 changes: 29 additions & 0 deletions examples/stepper-three-wire.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
var Board = require("../");

Board.requestPort(function(error, port) {
if (error) {
console.log(error);
return;
}

var board = new Board(port.comName);

board.on("ready", function() {

board.accelStepperConfig({
deviceNum: 0,
type: board.STEPPER.TYPE.THREE_WIRE,
motorPin1: 2,
motorPin2: 3,
motorPin3: 4
});

board.accelStepperSpeed(0, 100);
board.accelStepperStep(0, 1000);

board.on("stepper-done-0", function(position) {
console.log("Current position: " + position);
});

});
});
Loading

0 comments on commit 750c07c

Please sign in to comment.