4

I'm trying to control atleast 2 stepper motors with the raspberry, which works fine with the following setup:

So at this moment I am forced to use the Python scripts, because the MotorHAT has only a Python library. Now I've found a Javascript library for stepper motors, which is actually for arduino boards, but still has raspberry support. The library is called Johnny-Five http://johnny-five.io/examples/stepper-driver/ I tried to set the library up and got now the following javascript:

var raspi = require('raspi-io');
var five = require('johnny-five');
var board = new five.Board({
   io: new raspi()
});

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

  var stepper = new five.Stepper({
    type: five.Stepper.TYPE.DRIVER,
    stepsPerRev: 200,
     pins: {
     step: 11,
     dir: 13
    }
 });


stepper.rpm(180).ccw().accel(1600).decel(1600).step(2000, function() {

console.log("Done moving CCW");

// once first movement is done, make 10 revolutions clockwise at previously
//      defined speed, accel, and decel by passing an object into stepper.step
stepper.step({
  steps: 2000,
  direction: five.Stepper.DIRECTION.CW
}, function() {
  console.log("Done moving CW");
});
});
});

This script prints the following error:

  Error: Stepper is not supported
    at new Stepper ...
    at Board ...
    at Board.emit (events.js:92.17)
    at process._tickCallback (node.js:448:13)

If anyone could figure out my fault or knows a better solution to control the stepper motors from a website, that would be great!

11
  • 1) Is the JavaScript library said to be compatible with the Pi. 2) Do not make us guess errors, it is very annoying. If you have error messages put the exact text in your question.
    – joan
    Commented Oct 9, 2015 at 8:15
  • I updated the question for the Error message and I already wrote : ..."which is actually for arduino boards, but still has raspberry support."
    – TobiasW
    Commented Oct 9, 2015 at 8:20
  • I can see no suggestion that the JavaScript you link will work on the Pi. A script comment explicity calls up Arduino code.
    – joan
    Commented Oct 9, 2015 at 8:33
  • This is arduino code right, but if you look at my link and at this code you can see some differences, the header is changed for raspberry pi, like the johnny-five library suggests, I can't explain everything here, if u don't look at the material i tried to provide in my question :/
    – TobiasW
    Commented Oct 9, 2015 at 9:25
  • Hopefully someone else will trawl through the web-site to find the information to which you refer.
    – joan
    Commented Oct 9, 2015 at 9:29

4 Answers 4

2

This library, which didn't exist in the past as I asked this question solves this problem. https://www.npmjs.com/package/stepper-wiringpi

0

Johnny-five does not support stepper for Raspberry pie model boards. You can see it here.

If you want to control steppers, I suggest you use Arduino.

0

to escape python i use the following javascript library

https://www.npmjs.com/package/motor-hat full supports for MotorHAT from Adafruit https://www.adafruit.com/products/2348

-2

I think you forgot to upload the Advanced Firmata, which have the codes for Steppers, to your Arduino.

How to upload the Advanced Firmata to your Arduino:

Clone or download and copy AdvancedFirmata into your Arduino projects/sketch directory (or anywhere on your hard drive). Open in the Arduino IDE, verify and upload to your board.

If you download rather than clone this repository, rename the folder to "AdvancedFirmata" after unzipping and before copying into your Arduino projects directory.

Remember to choose correct Board, Processor and Port.

1
  • How would the OP determine if that is the problem? How would he upload this firmata? Commented Nov 24, 2015 at 15:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.