Inconsistent Motor Direction

Un shield de pilotage pour 4 moteurs à courant continu ou 2 moteurs pas à pas, qui permet une alimentation sur 12V et qui n'utilise que 4 sorties Pwm (sur 6) et 2 entrées analogiques (sur 6) de l'Arduino

Inconsistent Motor Direction

Message non lude webdes03 » Dim 10 Fév 2013 14:27

I just assembled my Rotoshield, and I'm seeing some odd behavior. I have a 4-wire stepper motor connected to M1/M2, and a program commanding it to move forward every X seconds. The motor moves, but for some reason, every 3-4 movements it switches direction and moves backwards, despite the program telling it to move forward.

Any ideas?

Code: Tout sélectionner
#include <Wire.h>
#include <snootor.h>

SnootorStep M;

void setup(){
  Wire.begin();
  M.init(460,400,1, MOTOR_MODE_FULLSTEP);
}

void loop(){
  M.forward(200);
  SC.delay(500);
}
webdes03
 
Messages: 5
Inscription: Dim 10 Fév 2013 14:19

Re: Inconsistent Motor Direction

Message non lude Lionel » Dim 10 Fév 2013 19:10

Hi,

could you try HALFSTEP mode as in the following code.

Code: Tout sélectionner
    // Snootlab Max 7313 Motor shield library
    // Based on Adafruit Motor shield library
    // https://github.com/adafruit/Adafruit-Motor-Shield-library
    // copyleft Snootlab, 2011
    // this code is public domain, enjoy!

    #include <Wire.h>
    #include <snootor.h>


    SnootorStep M;


    void setup(){
    // Serial.begin(9600);
      Wire.begin();

    /*
     * Stepper initialization :
     *
     * init(delay,stepcount,motornum, mode);
     *
     * where :
     *
     * * delay is the time between each basic step, in microseconds, which determines the motor speed
     * * stepcount is the number of steps per turn
     * * motornum is 1 or 2, depending wiring
     * * mode is either MOTOR_MODE_HALFSTEP or MOTOR_MODE_FULLSTEP
     */
      M.init(2500,48,1,MOTOR_MODE_HALFSTEP);
    }

    void loop(){
      static int d;
      uint8_t i;
      M.setMode(MOTOR_MODE_HALFSTEP);
    //  Serial.println("start halfstep mode...");
      M.forward(96);
      SC.delay(2000);
      delay(2000);

    }
Image - Distributeur officiel Arduino - Conception de shields
Avatar de l’utilisateur
Lionel
 
Messages: 734
Inscription: Mar 21 Déc 2010 09:52
Localisation: Toulouse

Re: Inconsistent Motor Direction

Message non lude webdes03 » Lun 11 Fév 2013 00:02

Thanks for the quick (and English) reply Lionel!

It looks like I'm seeing the same behavior using halfstep mode. My stepper motor is this one if it makes a difference. It has 400 steps/revolution.

Given that, I believe my init line should be the following, is that correct?

Code: Tout sélectionner
M.init(2500,400,1, MOTOR_MODE_FULLSTEP);
webdes03
 
Messages: 5
Inscription: Dim 10 Fév 2013 14:19

Re: Inconsistent Motor Direction

Message non lude webdes03 » Lun 18 Fév 2013 01:07

webdes03 a écrit:It looks like I'm seeing the same behavior using halfstep mode. My stepper motor is this one if it makes a difference. It has 400 steps/revolution.

Given that, I believe my init line should be the following, is that correct?

Code: Tout sélectionner
M.init(2500,400,1, MOTOR_MODE_FULLSTEP);


Any thoughts? It has been a week and I haven't seen a reply. I've still been unable to get my Rotoshield to correctly do anything. I tried disconnecting the motor and starting over, but now it just buzzes and doesn't move at all.

What's the correct behavior for the M3/M4 LED's during the move? Should they both be green when rotating? I'm seeing lots of red and/or orange. Is there any better documentation on how you're supposed to connect to the Rotoshield? I know the four wires of my motor are Coil A (Green/Black), and Coil B (Red/Blue), but it doesn't seem to matter how I connect it, nothing happens.
webdes03
 
Messages: 5
Inscription: Dim 10 Fév 2013 14:19


Retourner vers Rotoshield

Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 1 invité

cron