Go Down

Topic: This motor code cant turn the stepper motor in one direction (Read 713 times) previous topic - next topic

creativen

I just bought motor shield like this http://www.cutedigi.com/arduino-shields/motor-driver-shield-for-arduino.html
Then follow the step, till I download the example sketch:

Code: [Select]
// Adafruit Motor shield library
// copyright Adafruit Industries LLC, 2009
// this code is public domain, enjoy!

#include <AFMotor.h>

// Connect a stepper motor with 48 steps per revolution (7.5 degree)
// to motor port #2 (M3 and M4)
AF_Stepper motor(48, 2);

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motor.setSpeed(10);  // 10 rpm   
 
}

void loop() {
  Serial.println("Single coil steps");
  motor.step(500, FORWARD, SINGLE);
}
 


Is there anyone knows why my stepper just turn back and forth? what is wrong with the code?

kf2qd


MarkT

Stepper motors need the 4 phases energized in the correct order, and with 4 wires there are 3 fundamental ways to
hook it up (ignoring cyclic rotations of the phases or reversing the motor), 2 of which don't work, 1 of which does...

If the phases are marked A+, A-, B+, B- then its easy, just ensure you alternate from A to B:

A+/B+/A-/B-   or  A-/B+/A+/B- will work for instance.  However  anything thats AABB or ABBA or BAAB etc won't work.

However sometimes phases are unmarked or marked "1,2,3,4" which frankly could mean anything - trial and error are
then needed (or using a multimeter to identify A winding from B winding).
[ I won't respond to messages, use the forum please ]

creativen

Yes, you are right, I wire it wrong. Thank you so so much!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy