-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
kolban
committed
Apr 30, 2016
1 parent
4761d5c
commit d0ff681
Showing
4 changed files
with
252 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Sample for the stepper-wiringpi.js. | ||
* | ||
* Here we are testing a Stepper motor that has 200 steps per revolution | ||
* which equates to 360/200 = 1.8 degrees per step. | ||
* | ||
* In this test we continuously run forwards for 5 seconds and then continuously run | ||
* backwards for 5 seconds and then keep repeating. | ||
*/ | ||
|
||
var speed = 150; // RPM | ||
var directionPin = 20; // Pin used for direction | ||
var stepPin = 21; // Pin used for stepping | ||
|
||
console.log("Starting stepper-wiringpi - digital_ForwardBackward"); | ||
|
||
var stepperWiringPi = require("../src/stepper-wiringpi"); | ||
var motor1 = stepperWiringPi.setupDigital(200, stepPin, directionPin); | ||
var direction = stepperWiringPi.FORWARD; | ||
|
||
console.log("Globals: FORWARD=%d, BACKWARD=%d", stepperWiringPi.FORWARD, stepperWiringPi.BACKWARD); | ||
|
||
function changeDirection() { | ||
console.log("Changing direction from %d", direction); | ||
if (direction == stepperWiringPi.FORWARD) { | ||
direction = stepperWiringPi.BACKWARD; | ||
motor1.backward(); | ||
} else { | ||
direction = stepperWiringPi.FORWARD; | ||
motor1.forward(); | ||
} | ||
setTimeout(changeDirection.bind(this), 5000); | ||
} // End of changeDirection | ||
|
||
debugger; | ||
motor1.setSpeed(speed); | ||
|
||
changeDirection(); | ||
|
||
console.log("Starting to move ..."); | ||
// End of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Sample for the stepper-wiringpi.js. | ||
* | ||
* Here we are testing a Stepper motor that has 200 steps per revolution | ||
* which equates to 360/200 = 1.8 degrees per step. | ||
* | ||
* In this test we continuously run forwards for 5 seconds and then continuously run | ||
* backwards for 5 seconds and then keep repeating. | ||
*/ | ||
|
||
var speed = 150; // RPM | ||
var directionPin = 20; // Pin used for direction | ||
var stepPin = 12; // Pin used for stepping | ||
|
||
console.log("Starting stepper-wiringpi - digital_ForwardBackward"); | ||
|
||
var stepperWiringPi = require("../src/stepper-wiringpi"); | ||
var motor1 = stepperWiringPi.setupDigital(200, stepPin, directionPin, true); | ||
var direction = stepperWiringPi.FORWARD; | ||
|
||
console.log("Globals: FORWARD=%d, BACKWARD=%d", stepperWiringPi.FORWARD, stepperWiringPi.BACKWARD); | ||
|
||
function changeDirection() { | ||
console.log("Changing direction from %d", direction); | ||
if (direction == stepperWiringPi.FORWARD) { | ||
direction = stepperWiringPi.BACKWARD; | ||
motor1.backward(); | ||
} else { | ||
direction = stepperWiringPi.FORWARD; | ||
motor1.forward(); | ||
} | ||
setTimeout(changeDirection.bind(this), 5000); | ||
} // End of changeDirection | ||
|
||
debugger; | ||
motor1.setSpeed(speed); | ||
|
||
changeDirection(); | ||
|
||
console.log("Starting to move ..."); | ||
// End of file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Sample for the stepper-wiringpi.js. | ||
* | ||
* Here we are testing a Stepper motor that has 200 steps per revolution | ||
* which equates to 360/200 = 1.8 degrees per step. | ||
*/ | ||
var CH0_Pin = 21; | ||
var wpi = require("wiring-pi"); | ||
wpi.setup("gpio"); | ||
wpi.pinMode(CH0_Pin, wpi.INPUT); | ||
wpi.pcf8574Setup(100, 0x20); | ||
|
||
// In this test we are going to use a PCF8574 for control and control | ||
// two motors | ||
console.log("Starting stepper-wiringpi - test5"); | ||
|
||
var stepperWiringPi = require("../src/stepper-wiringpi"); | ||
var m1pinIN1 = 100; // Stepper Red | ||
var m1pinIN2 = 101; // Stepper Blue | ||
var m1pinIN3 = 102; // Stepper Green | ||
var m1pinIN4 = 103; // Stepper Black | ||
|
||
var m2pinIN1 = 104; // Stepper Red | ||
var m2pinIN2 = 105; // Stepper Blue | ||
var m2pinIN3 = 106; // Stepper Green | ||
var m2pinIN4 = 107; // Stepper Black | ||
|
||
var motor1 = stepperWiringPi.setup(200, m1pinIN1, m1pinIN2, m1pinIN3, m1pinIN4); | ||
var motor2 = stepperWiringPi.setup(200, m2pinIN1, m2pinIN2, m2pinIN3, m2pinIN4); | ||
var direction = 1; | ||
console.log("Globals: FORWARD=%d, BACKWARD=%d", stepperWiringPi.FORWARD, stepperWiringPi.BACKWARD); | ||
|
||
function changeDirection() { | ||
console.log("Changing direction from %d", direction); | ||
if (direction == stepperWiringPi.FORWARD) { | ||
direction = stepperWiringPi.BACKWARD; | ||
motor1.backward(); | ||
motor2.backward(); | ||
} else { | ||
direction = stepperWiringPi.FORWARD; | ||
motor1.forward(); | ||
motor2.forward(); | ||
} | ||
setTimeout(changeDirection.bind(this), 2000); | ||
} | ||
|
||
motor1.setSpeed(1); | ||
motor2.setSpeed(1); | ||
|
||
changeDirection(); | ||
|
||
setInterval(function() { | ||
var i = wpi.pulseIn(CH0_Pin, wpi.HIGH); | ||
console.log("CH0: " + i); | ||
}, 500); | ||
console.log("Step requested submitted."); |