Basic stepper motor config won't move (3 hrs)

I'm taking a basic Mechatronics class with a professor that allows us to use Arduinos but refuses to offer any help since he doesn't know anything about them. I don't know much about electronics, but I'm comfortable with computer programming.

I'm trying to get stepper motor 28BYJ-48 with Darlington array chip ULN2803A to rotate clockwise and counterclockwise depending on the position of a switch. This should be stupidly easy, but I've been working on it for over three hours now, Googling Web and Images several pages deep. Currently I'm just trying to get it to rotate in one direction (the opposite direction will then be easy).

My relevant code (not including code for the switch, which works fine) is:


#include <Stepper.h>

const int stepsPerMotorRevolution = 32;
const int stepsPerOutputRevolution = 2048;
Stepper myStepper(stepsPerMotorRevolution,8,6,7,5);

void loop () {
switch (SwitchState) {
case LOW:
{
Serial.print("Here");
myStepper.setSpeed(500);
myStepper.step(stepsPerOutputRevolution);
delay(500);
break;
}
}


The only thing that happens is that "Here" is outputted about every ten seconds.
I suspect that it's my wiring that's incorrect- I've tried dozens of combinations- but there isn't a single image of how to connect everything with a ULN2803A- everything is for a ULN2003. I'm attaching my best shot at a circuit diagram. I'm not including the switch because that seems to work just fine (and worked for the previous assignment). I appreciate any help you guys can give me for something that seems so basic.

You have a short circuit from 5V to pin 8, that will burn out pin 8 if it goes low.
And where did that program come from? Why didn't you use one of the library examples?
Here's some datasheet links that might help, good luck.

http://www.ti.com/lit/ds/symlink/uln2803a.pdf

wex52:
but there isn't a single image of how to connect everything with a ULN2803A- everything is for a ULN2003.

The only difference is one more channel, the rest is identical.

There is a huge thread here:
http://forum.arduino.cc/index.php?topic=85335.0

outsider:
You have a short circuit from 5V to pin 8, that will burn out pin 8 if it goes low.
And where did that program come from? Why didn't you use one of the library examples?
Here's some datasheet links that might help, good luck.
http://robocraft.ru/files/datasheet/28BYJ-48.pdf
http://www.ti.com/lit/ds/symlink/uln2803a.pdf

Thank you for taking the time to try to help. I removed the short (a clumsy addition born of desperation after several rewirings), but I'm afraid it still doesn't work. I can feel the motor vibrating.

That program was an extension of a previous program that worked, with the previous code omitted (all it did was read a potentiometer and display a pattern of blinking LEDs). I used library examples as a basis, as well as several online examples that were very similar. I haven't been able to connect a single combination that works.

I read through both of the links that you gave me- the TI link had details that were over my head and beyond the scope of the course that I'm taking. The details that I did understand unfortunately didn't result in a rotating motor.

If you'd like to take a second crack at what I'm doing wrong, I'd greatly appreciate it, but I understand if you don't. Thanks again.

LarryD:
There is a huge thread here:
28BYJ-48 5-Volt Stepper - Motors, Mechanics, Power and CNC - Arduino Forum

Thanks for the link. Unfortunately, having read all 12 pages and visited several links provided in them, I still cannot get my motor to move. I only feel it vibrating. I'm only interested in getting it to work with the Stepper.h library for now. I suspect that if I can't get that to work, then I've got some sort of wiring/voltage/current issue that wouldn't allow the more detailed sequences of turning pins ON and OFF to work either.

It is very important the coil wires are connected in the right order.

Also, use a DVM and check there are not any open coils.

.

BTW
If you are trying to power the motor with the Arduino, don't!

You need an external 5 voltage power supply fo the motor.

.

LarryD:
It is very important the coil wires are connected in the right order.

Also, use a DVM and check there are not any open coils.

I feel like I've tried almost every one of the 24 permutations of four wires by this point, but in my research I've found that 8 of them should work, since you only have to get the right pairs (though it may not go in the right direction). I've since paired up pin 1 with pins 2, 3 and 4, and all of them result in vibration. I have a DVM and I got an A in my Intro to Circuits class 2 years ago, but I'm really not sure what to test with respect to the wires, although I've only spent about 15 minutes researching that (ongoing).

LarryD:
BTW
If you are trying to power the motor with the Arduino, don't!

You need an external 5 voltage power supply fo the motor.

I thought that using an Arduino to power a little 28BYJ-48 with no load attached to it would be ok. If not, that's just one more reason that my professor is awful since a power supply wasn't in our equipment list. He did have us buy 9V battery strap, but I'm a little hesitant to just directly connect a 9V battery to my motor.

LarryD:
BTW
If you are trying to power the motor with the Arduino, don't!

You need an external 5 voltage power supply fo the motor.

.

+1
The spec for the motor does not give current requirments but 300gm CM implies a fairly high one, more than the arduino can supply.

Th fact it vibrates makes me think its trying but cant quite make it.
Surprised the arduino reg is functioning lso with that sort of load.

wex52:
. He did have us buy 9V battery strap, but I'm a little hesitant to just directly connect a 9V battery to my motor.

If this is a pp3 its probably usless for this.

Supply should be connected to the chip not the motor.

EDIT.

Apologies its connected to the motor not the chip.
That chip has open collector outputs so your diagram is correct with the short removed.
Even if you have the motor connections wrong you should not damage it using a pp3 though although you may flatten your battery rather quickly.

wex52:
I thought that using an Arduino to power a little 28BYJ-48 with no load attached to it would be ok.

Do not be fooled by physical size, read the data sheet.
I have a matchbox sized BLDC motor rated at 800 watts (over 1HP ) continuously if cooled.

that's just one more reason that my professor is awful since a power supply wasn't in our equipment list.

You wont forget this though, will you ?

Learn by doing makes things stick in your brain, but can be a real pain in the butt.

.

LarryD:
You wont forget this though, will you ?

Learn by doing makes things stick in your brain, but can be a real pain in the butt.

Oh, I know. But I'm a 16-year veteran teacher myself, and the way this guy runs the class is inexcusable. 8-line rant deleted

Anyway, I'm looking through my equipment list, and I've got an LM7805CT voltage regulator which I can attach to a 9V battery with the 9V battery strap. A friend of mine who knows a little about electronics tried to guide me to create a circuit that I could use as a power source for the 28BYJ-48 motor. He says I don't need the datasheet-recommended capacitors because it's okay if the signal isn't "clean" for my purposes. But, he stuck on four 1-Ohm resistors in parallel to control the amperage. I'm getting 4V (instead of 5V) out of it, but the motor doesn't even vibrate. When I switch the power from the regulator to the Arduino, it starts vibrating again. When I reconnect to the regulator but remove the resistors, the motor will vibrate. Still can't get it to move though. I have tried all 3 possible wirings for 2 pairs of 4 wires for the motor.

I'm going to look into how to test if my motor is just flat-out busted or if an external power supply is just flat-out necessary. I kind of doubt the latter because a very detailed entry at arduino-info.wikispaces indicated that the Arduino would be sufficient for a one-motor demonstration.

I'm about to give up and join my classmates in figuring out how to do all of these assignments on a PICkit 3 instead of an Arduino. Learning is one thing, but I have to pass this class.

Those 9 volt batteries have very little drive capability, use a wall-wart.

You need a .1UF capacitor on the input to GND of the regulator for to prevent possible oscillating.

Do you have the ground of the I.C. going to the Arduino GND?

Edit
What do you measure across the battery terminals?

Also, you do realize that motor is geared down 64:1 do you?

.

Or use a battery pack of 4 cells, 6V no regulator required.
PP3 are a pretty useless power supply except for very low current circuits.

Voltage is not the issue here , you need more current.

Phone chargers are 5 V mostly, do you have one of those ?

wex52:
indicated that the Arduino would be sufficient for a one-motor demonstration.

Only for a very low consumption motor.

Most require more current.

BTW
Delay(500);
What is that for ?

EDIT
http://www.maplin.co.uk/p/4-c-battery-box-hf95d

One of these clips to your battery clip and gives 6V which you can use directly.

For safety though you should use current limiting, a wall wart would probably be better

wex52:
Anyway, I'm looking through my equipment list, and I've got an LM7805CT voltage regulator which I can attach to

Can you post your equipment list.

Also ask prof if he knows if a pp3 will drive that motor.

delay(500) is in the loop so step isonly executed every 1/2 sec so it is possible it is working but the gearing means you do not notice it.

wex52:
He did have us buy 9V battery strap, but I'm a little hesitant to just directly connect a 9V battery to my motor.

This sounds as though he knows the arduino does not supply enough current.
However it will not last long so if you spend 3 hours debugging it could be flat, test it with a meter as larry suggested.

How is the arduino powered ?.

Ref this link posted earlier.

http://forum.arduino.cc/index.php?topic=85335.0

First post mentions the stepper library is not suitable for this motor.

Also max speed 100 pps, so 500 rpm speed is far too high i think.

I would suggest try copying his code, get it working then modify.

This chap seems to have solved the problem

http://arduino-info.wikispaces.com/SmallSteppers

His symptoms would appear to be similar to yours , vibrting but not turning initially.

Also he has measured the stall current at 250 mA so a decent power supply is needed.

This chap

says 4.5v is too low so if your arduino is powered from USB lead , not good.

Sort out your power supply first or you could end up chasing your own tail with coding errors that do not exist.