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 30, 2017
1 parent 0523f58 commit d8dec42
Show file tree
Hide file tree
Showing 7 changed files with 1,182 additions and 26 deletions.
29 changes: 29 additions & 0 deletions examples/stepper-accel.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.FOUR_WIRE,
motorPin1: 4,
motorPin2: 5,
motorPin3: 6,
motorPin4: 7,
stepType: board.STEPPER.STEPTYPE.WHOLE
});

board.accelStepperSpeed(0, 300);
board.accelStepperAcceleration(0, 100);
board.accelStepperStep(0, 2000, function(position) {
console.log("Current position: " + position);
});
});
});
30 changes: 30 additions & 0 deletions examples/stepper-driver.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
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, function(position) {
console.log("Current position: " + position);
});

});
});
54 changes: 54 additions & 0 deletions examples/stepper-multi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
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], function() {

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

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

});

});
});
27 changes: 27 additions & 0 deletions examples/stepper-three-wire.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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, function(position) {
console.log("Current position: " + position);
});

});
});
Loading

0 comments on commit d8dec42

Please sign in to comment.