rwaldron / johnny-five

JavaScript Robotics and IoT programming framework, developed at Bocoup.
http://johnny-five.io
Other
13.3k stars 1.77k forks source link

Stepper motor with L298N motor driver #1061

Closed alexcroox closed 8 years ago

alexcroox commented 8 years ago

Following the wiki guide to steppers with a driver, I am using the L298N with this stepper motor

http://cdn.instructables.com/F2V/3IT4/I2X6RNGR/F2V3IT4I2X6RNGR.MEDIUM.jpg

new five.Stepper({
  type: five.Stepper.TYPE.DRIVER,
  stepsPerRev: 200,
  pins: [ 11, 12 ]
});

Which is the step and direction pin on that driver?

I'm excited by the prospect of only having to use 2 digital pins for a single stepper as I have to drive 2x stepper motors from a single Uno so the more pins I can spare the better. All other examples online use all 4 IN pins on the driver to the Ardiuno.

dtex commented 8 years ago

Stepper is not my area of expertise, but I don't think DRIVER is the right type for this motor controller. I'm pretty sure that's intended for things like the Easy Driver and Big Easy Driver

alexcroox commented 8 years ago

ah OK thanks for the info

calugo commented 7 years ago

Hello! This is closed, however I would like to ask if using the type FOUR_WIRE, makes this work? I have been tinkering with the example codes, but the motor behaves erratically, here is my code:

var board = new five.Board();

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

  /**
   * In order to use the Stepper class, your board must be flashed with
   * either of the following:
   *
   * - AdvancedFirmata https://github.com/soundanalogous/AdvancedFirmata
   * - ConfigurableFirmata https://github.com/firmata/arduino/releases/tag/v2.6.2
   *
   */

  var stepper = new five.Stepper({
    type: five.Stepper.TYPE.FOUR_WIRE,
    stepsPerRev: 200,
    pins: {
      motor1: 8,
      motor2: 9,
      motor3: 10,
      motor4: 11
    }
  });

  stepper.rpm(200).cw().step(4000, function() {
    console.log("Done moving CCW");

  });
});

This is for a bipolar stepper like this and the L298N driver.

I guess what I am asking is if anybody has this driver working with J5 and a 4 wire bipolar stepper

Thanks in advance and sorry for the hassle.

Carlos.

dtex commented 7 years ago

Not a hassle at all. I'm using that exact motor controller to control a similar stepper and yes I use TYPE.FOUR_WIRE. In what way is it behaving erratically? What's it do when you call step()?

calugo commented 7 years ago

Hello!

Well, it is a bit odd, the motor "hums" but does not move at all, however when i flash a standard *ino code which is equivalent (perform a number of steps cw and ccw) it works just fine.

I wonder if the pin order in the node code is somehow different.... I really cannot tell.

Any suggestions?

Regards,

Carlos

On 2 May 2017 at 00:37, Donovan Buck notifications@github.com wrote:

Not a hassle at all. I'm using that exact motor controller to control a similar stepper and yes I use TYPE.FOUR_WIRE. In what way is it behaving erratically? What's it do when you call step()?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rwaldron/johnny-five/issues/1061#issuecomment-298460763, or mute the thread https://github.com/notifications/unsubscribe-auth/AGbVTM-NAEi1RgOcjeWLmwZJJSTuA9pqks5r1mzLgaJpZM4HxO41 .

calugo commented 7 years ago

Oh, terrible mistake! I had a loose wire,

Thanks a lot anyway!

On 2 May 2017 at 01:15, Carlos Lugo kupkasmale@gmail.com wrote:

Hello!

Well, it is a bit odd, the motor "hums" but does not move at all, however when i flash a standard *ino code which is equivalent (perform a number of steps cw and ccw) it works just fine.

I wonder if the pin order in the node code is somehow different.... I really cannot tell.

Any suggestions?

Regards,

Carlos

On 2 May 2017 at 00:37, Donovan Buck notifications@github.com wrote:

Not a hassle at all. I'm using that exact motor controller to control a similar stepper and yes I use TYPE.FOUR_WIRE. In what way is it behaving erratically? What's it do when you call step()?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rwaldron/johnny-five/issues/1061#issuecomment-298460763, or mute the thread https://github.com/notifications/unsubscribe-auth/AGbVTM-NAEi1RgOcjeWLmwZJJSTuA9pqks5r1mzLgaJpZM4HxO41 .