Go Down

Topic: Stepper Motor 28BYJ48 , ULN2003 driver board and Arduino Library (Read 35897 times) previous topic - next topic

Rick Eis

Hi, I and very interested in Arduino and now trying to understand a small stepper motor.

The exact motor and driver board can be found here http://www.4tronix.co.uk/arduino/Stepper-Motors.php.   Though I did not purchase it from there.

The arduino sketch on that page works perfectly. It will compile and run just as it says.  All four leds work and the motor does an entire revolution then reverses just as it says it will.

All I am trying to do now is get the Arduino sketches found in the library working with this motor and driver board. The library and examples I'm speaking of are found in the Arduino 1.0.2 version library under Stepper.  The one example in particular I am trying to work, since it appears to be the easiest, is entitled "stepper_oneRevolution.ino"

When I compile and load this, all that happens is the lights blink and the motor buzzes approx one second on then one second off.

Any and all help would be appreciated.

Thank you in advance,

Rick Eis
Arizona USA

larryd

Your motor is geared down.
// The 28BYJ-48 motor is a 4-phase, 8-beat motor, geared down by
// a factor of 68. One bipolar winding is on motor pins 1 & 3 and
// the other on motor pins 2 & 4. The step angle is 5.625/64 and the
// operating Frequency is 100pps.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

nitinsane

LarryD, if you can be more helpful, I'll appreciate it. Yes, it is geared down but what that means? How it relates to what the original posted observed (1 second on, 1 off)? I just received the similar board and controller today and am eager to try it on.

Thanks in advance.

larryd

I have the same motor as you.
Quote
The arduino sketch on that page works perfectly. It will compile and run just as it says. All four leds work and the motor does an entire revolution then reverses just as it says it will.

The above program is written for half stepping a unipolar motor driving a gear box.
This is a very good sketch for your application and could be changed for high torque 2 phase stepping if you need more power.
The Stepper library is designed for Direct Drive (not geared) high torque 2 phase stepping motor applications.  It is for motors without a gear train.  You would have to rewrite it to work with your geared motor.
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

tatsuha


Yes, it is geared down but what that means?


I believe what he's hinting at is that you're trying to run the motor too fast.  Because of the way it's geared, it doesn't behave exactly like the example code.  If the output shaft were coming directly from the motor part, you would only have something like 64 steps to complete a full circle.  Since your motor has more gears inside, it will take more full spins of the motor part to get the final shaft to spin a full circle, but it has the same "top speed" (number of steps per second).  If you try to get your unit to run a full circle at the normal speed, it has to spin at about 68 times faster than the example is designed to do.  I hope this is clear and correct.

larryd

I modified "stepper_oneRevolution.ino" to get closed to what you wanted.
Please play with the variables to get closer to exactly 1 revolution.
Note: I had to swap 8 & 11 on my motor to get this to work.
Also this code will lock up the loop until the motor is finished moving, not what you really want...

Code: [Select]
/*
Stepper Motor Control - one revolution <<<<<<<<<<<<<<<<<<<<< Modified

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.  

 
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
//const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                    // for your motor

// initialize the stepper library on pins 8 through 11:
//  Stepper myStepper(stepsPerRevolution, 8,9,10,11);              
 Stepper myStepper(stepsPerRevolution, 11,9,10,8);   // <<<<<<<<<<< Note 8 & 11 swapped
void setup() {
 // set the speed at 60 rpm:
 myStepper.setSpeed(120);                  //<<<<<<<<<<<<<<< This was 60
 // initialize the serial port:
 Serial.begin(9600);
}

void loop() {
 // step one revolution  in one direction:
 Serial.println("clockwise");
//**************************    
 for (int x=1;x<12;x++)                         //<<<<<<<<<<<<  we want to iterate to get a full revolution
 {
 myStepper.step(stepsPerRevolution);
 Serial.println(x);                                 //<<<<<<<<<<<< This is just for debugging
 }
//**************************    
 delay(500);
 // step one revolution in the other direction:
 Serial.println("counterclockwise");
//**************************    
 for (int x =1;x<12;x++)
 {
 myStepper.step(-stepsPerRevolution);
 Serial.println(x);  
 }
//**************************  
 delay(500);
}
No technical PMs.
If you are asked a question, please respond with an answer.
If you are asked for more information, please supply it.
If you need clarification, ask for help.

zoomx

This motor is geared down by a factor of 64, not 68. The datasheet says that it has 64 steps per revolution (before gear box) but when you use halfsteps. You have 64*64=4096 steps per revolution.
Stepper.h doesn't use halfsteps so you have 32*64=2048 steps per revolution.

Use
Code: [Select]
stepsPerRevolution = 256
and
Code: [Select]
for (int x=1;x<9;x++)

to get one revolution 8*256=2048.

Goldenshuttle

using this same driver and motor. I need motor to go 20 revolution then stop 2 seconds; then 20 revolt then 2 sec stop and so on...speed does not matter...please how can I modify the sketch  ??




I modified "stepper_oneRevolution.ino" to get closed to what you wanted.
Please play with the variables to get closer to exactly 1 revolution.
Note: I had to swap 8 & 11 on my motor to get this to work.
Also this code will lock up the loop until the motor is finished moving, not what you really want...

Code: [Select]
/*
Stepper Motor Control - one revolution <<<<<<<<<<<<<<<<<<<<< Modified

This program drives a unipolar or bipolar stepper motor.
The motor is attached to digital pins 8 - 11 of the Arduino.

The motor should revolve one revolution in one direction, then
one revolution in the other direction.  

 
Created 11 Mar. 2007
Modified 30 Nov. 2009
by Tom Igoe

*/

#include <Stepper.h>
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
//const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
                                    // for your motor

// initialize the stepper library on pins 8 through 11:
//  Stepper myStepper(stepsPerRevolution, 8,9,10,11);              
 Stepper myStepper(stepsPerRevolution, 11,9,10,8);   // <<<<<<<<<<< Note 8 & 11 swapped
void setup() {
 // set the speed at 60 rpm:
 myStepper.setSpeed(120);                  //<<<<<<<<<<<<<<< This was 60
 // initialize the serial port:
 Serial.begin(9600);
}

void loop() {
 // step one revolution  in one direction:
 Serial.println("clockwise");
//**************************    
 for (int x=1;x<12;x++)                         //<<<<<<<<<<<<  we want to iterate to get a full revolution
 {
 myStepper.step(stepsPerRevolution);
 Serial.println(x);                                 //<<<<<<<<<<<< This is just for debugging
 }
//**************************    
 delay(500);
 // step one revolution in the other direction:
 Serial.println("counterclockwise");
//**************************    
 for (int x =1;x<12;x++)
 {
 myStepper.step(-stepsPerRevolution);
 Serial.println(x);  
 }
//**************************  
 delay(500);
}

Live to learn & make

rd105

I am using the same set up , I can get everything to work. It will go clockwise, and counterclockwise depending what the program calls for. However when motor is paused 2 lights on the board stay on . I am using the Stepper Library which I modified per this forum , switching pins 8 and 11. I am m using a  power supply for the board but they aren't power indicators . What is going on. Is this Normal. Thanks in advanced for any insight.

eMax1323

Hi, I was trying to make a similar work with Stepper Motor 28BYJ48 and ULN2003 driver.
I saw that the pins to be used in order to control the driver are 4, but I am currently out of pins on the arduino uno, I just have 3 pins left, 0, 1 and the 9.
Is there a way to pilot the driver (and the motor) just with 2 wires?
I do not need high performance, the motor has to make 90° rotation in one way and 90° rot the other way to open and close a hole with a fan in it in order to avoid any flow with the fan turned off (it's for a fermentation box, I'm a beer geek...).

Does anyone know how to fix this problem?

I'm quite good with arduino but know nothing about stepper motors and their drivers

Thanks in advance
eMax1323

Go Up