Stepper Motor Vibrating, but not Revolving

Greetings,
I am using a NodeMCU(12-E) V2.0 micro-controller to control a Stepper Motor.

Important Motor Specs:

  • Steps per Rev: 200
  • (The power from the GPIO pins are sufficient)
  • Bipolar (4 wires)

I have the datasheet here: https://www.omc-stepperonline.com/download/24HR04-1004S.pdf
which shows which wires are A, A/, B, and B/

I connected A to GPIO pin 4, A/ to 0, B to 5, and B/ to 16

There is no driver, the motor pins are connected directly to the gpio pins, which all provide sufficient power.

The issue I am encountering is that the motor simply vibrates, but does not turn in full revolutions. By setting the delay speed to a high number (super slow) I could feel that individual steps are being made, however I believe that one of the steps brings it back to the original position, and does not continue to rotate in the same direction. The steps are far too subtle for me do figure out which step this is occurring on, but I know there is motion because I can feel steps at low speeds, and vibration at high speeds.

Here is the code:

#define in_B_1 5
#define in_B_2 16
#define in_A_1 4
#define in_A_2 0

int currentStep = 0;

void setup()
{
   pinMode(in_A_1, OUTPUT);
   pinMode(in_A_2, OUTPUT);
   pinMode(in_B_1, OUTPUT);
   pinMode(in_B_2, OUTPUT);
}

unsigned int time_delay = 20;

void step1(){
   //A+,B+
   digitalWrite(in_A_1, 1);
   digitalWrite(in_A_2, 0);
   digitalWrite(in_B_1, 1);
   digitalWrite(in_B_2, 0);
   delay(time_delay);
}

void step2(){
   //A+,B-
   digitalWrite(in_A_1, 0);
   digitalWrite(in_A_2, 1);
   digitalWrite(in_B_1, 1);
   digitalWrite(in_B_2, 0);
   delay(time_delay);
}

void step3(){
   //A-,B-
   digitalWrite(in_A_1, 0);
   digitalWrite(in_A_2, 1);
   digitalWrite(in_B_1, 0);
   digitalWrite(in_B_2, 1);
   delay(time_delay);
}

void step4(){
   //A-,B+
   digitalWrite(in_A_1, 1);
   digitalWrite(in_A_2, 0);
   digitalWrite(in_B_1, 0);
   digitalWrite(in_B_2, 1);
   delay(time_delay);
}

void loop()
{
 CW();
}

void CW(){
 step1();
 step2();
 step3();
 step4();
}

I have also tried:

#define in_B_1 5
#define in_B_2 16
#define in_A_1 4
#define in_A_2 0

int currentStep = 0;

void setup()
{
   pinMode(in_A_1, OUTPUT);
   pinMode(in_A_2, OUTPUT);
   pinMode(in_B_1, OUTPUT);
   pinMode(in_B_2, OUTPUT);
}

unsigned int time_delay = 20;

void step1(){
   //A+
   digitalWrite(in_A_1, 1);
   digitalWrite(in_A_2, 0);
   digitalWrite(in_B_1, 0);
   digitalWrite(in_B_2, 0);
   delay(time_delay);
}

void step2(){
   //B+
   digitalWrite(in_A_1, 0);
   digitalWrite(in_A_2, 0);
   digitalWrite(in_B_1, 1);
   digitalWrite(in_B_2, 0);
   delay(time_delay);
}

void step3(){
   //A-
   digitalWrite(in_A_1, 0);
   digitalWrite(in_A_2, 1);
   digitalWrite(in_B_1, 0);
   digitalWrite(in_B_2, 0);
   delay(time_delay);
}

void step4(){
   //B-
   digitalWrite(in_A_1, 0);
   digitalWrite(in_A_2, 0);
   digitalWrite(in_B_1, 0);
   digitalWrite(in_B_2, 1);
   delay(time_delay);
}

void loop()
{
 CW();
}

void CW(){
 step1();
 step2();
 step3();
 step4();
}

Same issue, but now the vibrations are more subtle

SidKadari:
There is no driver, the motor pins are connected directly to the gpio pins, which all provide sufficient power.

What is your evidence for this? The maximum current rating of the ESP8266 GPIO pins is 12 mA. I can't imagine a motor that could be powered by that.

What pert wants to say is that you are completely wrong. A stepper motor always needs a driver

pert:
What is your evidence for this? The maximum current rating of the ESP8266 GPIO pins is 12 mA. I can't imagine a motor that could be powered by that.

My evidence for this is from a test i did just recently.

I attached a long clip to the shaft, so i could see any movement on the shaft and not just a vibration. What I had found out, is that the shaft moves one step in one direction, skips the next step, one step in the other direction, skips, and continues. This means to me that one of the two coils inside the motor are being affected, because when my code changes the direction of one of the coils, it moves the shaft, however this is not happening with the other coil, therefore it just goes back and forth repeatdly.

I consider this as sufficient evidence that the power is enough, because one of the coils is receiving a charge and generating a magnetic field, which is all the stepper motor should need to work.

Johan_Ha:
What pert wants to say is that you are completely wrong. A stepper motor always needs a driver

No I do not believe a stepper motor needs a driver.

here is a short video on how a stepper works, I am using the variable reluctance motor: https://www.youtube.com/watch?v=TWMai3oirnM

All I should need to do is power the coils directly through the gpio pins of my NODEMCU 2.0, and that should drive the motor.

When you measured the current with your ammeter, what did it read?

evadne:
When you measured the current with your ammeter, what did it read?

I did not measure it

Stepper motors need drivers.
Servos just need control signal, generally a 1-2mS wide pulse every 20mS (50Hz rate). 1mS is full one way, 1.5mS is the middle, 2mS is the other way.
Even a little 28BYJ-48 needs a UNL2003 to make it move.

Your motor is similar:

SidKadari:
I did not measure it

Do.

CrossRoads:
Stepper motors need drivers.
Servos just need control signal, generally a 1-2mS wide pulse every 20mS (50Hz rate). 1mS is full one way, 1.5mS is the middle, 2mS is the other way.
Even a little 28BYJ-48 needs a UNL2003 to make it move.

Your motor is similar:

can you take a look at this tutorial --- https://www.youtube.com/watch?v=xEjfAWV3WWU
It is essentially the method I am trying to use to control the motor, and doing research into exactly how the stepper motor works, I believe this should work.

Please let me know if I am wrong, or if this video is fake

Here is a short video on how my motor works -- https://www.youtube.com/watch?v=eyqwLiowZiU

I was mistaken in a previous post after taking my motor apart to inspect for damage issues I found that it is a hybrid stepper motor, so in the second video skip to 2:32 for my motor.

I believe the logic should work, if not please let me know.

Thanks again for the help guys

Still need a motor driver to put enough current into your motor's 3.6 ohm coils to make them move. Especially if you are planning to attach a load to the motor.

CrossRoads:
Still need a motor driver to put enough current into your motor's 3.6 ohm coils to make them move. Especially if you are planning to attach a load to the motor.

Once again tell me how this works,

My motor is moving, it is just moving in a constant back and forth motion, and does not continue, I assume this means the power coming in is high enough, because if it weren't how would the shaft move.

In other words if the current is not sufficient, then the shaft would not move at all because the electromagnetic field would not be enough to reach and effect the rotor inside the motor.

SidKadari:
can you take a look at this tutorial --- https://www.youtube.com/watch?v=xEjfAWV3WWU
It is essentially the method I am trying to use to control the motor, and doing research into exactly how the stepper motor works, I believe this should work.

Please let me know if I am wrong, or if this video is fake

I doubt it's fake, but it is a very bad idea. The absolute maximum current of the Nano is 40 mA, so you can get away with things on the Nano that will kill your ESP8266 outright, but you shouldn't actually use it at the absolute maximum rating. There's also a very good chance even that tiny stepper is drawing more than 40 mA, especially once it's under load. There is also the issue of flyback. Inductive loads like the coils on a stepper motor produce voltage spikes when switched. The stepper driver is designed to handle that, but the microcontroller on the Nano or your ESP8266 is not.

It's fairly common to find tutorials online with people using Arduino boards in manners that exceed the rated specifications of the microcontroller (lighting LEDs without a current limiting resistor being the most common). Sure, it might work for the duration of the video, but what about if you do this in a project and then it stops working after a couple of months? What if it does subtle damage that makes the microcontroller no longer work reliably? I would be forever distrustful of your ESP8266 after what you've put it through. Then when you're having some random problems, as is inevitable even with a perfect microcontroller, you always have to wonder "is it my code, or is it that something is partly fried from that time when I tried to direct drive a stepper?"

The result of exceeding the rated specifications is unsure. What is sure is that if you respect the specifications then you will get a long and reliable lifetime from your electronics.

SidKadari:
I believe the logic should work, if not please let me know.

No body's questioning the logic, it's the power that's the issue. (Edit: although I haven't checked you logic.)

Before I even bought a stepper, I wrote a sketch to mimic the movement with leds. That simply verified that the logic in my code would correctly drag the motor round. But when I got the motor I put the output to a uln2003 to switch externally supplied power.

You opened with this:

  • (The power from the GPIO pins are sufficient)

That means three things must be true:

  • You know the power required
  • You know the power a pin can supply
  • Power in 2 is more than the the power in 1

Are those three things known to be true?

SidKadari:
I did not measure [the current]

This ad's from the 50's I think:

tdg.jpg

It's still true.

pert:
I doubt it's fake, but it is a very bad idea. The absolute maximum current of the Nano is 40 mA, so you can get away with things on the Nano that will kill your ESP8266 outright, but you shouldn't actually use it at the absolute maximum rating. There's also a very good chance even that tiny stepper is drawing more than 40 mA, especially once it's under load. There is also the issue of flyback. Inductive loads like the coils on a stepper motor produce voltage spikes when switched. The stepper driver is designed to handle that, but the microcontroller on the Nano or your ESP8266 is not.

It's fairly common to find tutorials online with people using Arduino boards in manners that exceed the rated specifications of the microcontroller (lighting LEDs without a current limiting resistor being the most common). Sure, it might work for the duration of the video, but what about if you do this in a project and then it stops working after a couple of months? What if it does subtle damage that makes the microcontroller no longer work reliably? I would be forever distrustful of your ESP8266 after what you've put it through. Then when you're having some random problems, as is inevitable even with a perfect microcontroller, you always have to wonder "is it my code, or is it that something is partly fried from that time when I tried to direct drive a stepper?"

The result of exceeding the rated specifications is unsure. What is sure is that if you respect the specifications then you will get a long and reliable lifetime from your electronics.

evadne:
No body's questioning the logic, it's the power that's the issue. (Edit: although I haven't checked you logic.)

Before I even bought a stepper, I wrote a sketch to mimic the movement with leds. That simply verified that the logic in my code would correctly drag the motor round. But when I got the motor I put the output to a uln2003 to switch externally supplied power.

You opened with this:

That means three things must be true:

  • You know the power required
  • You know the power a pin can supply
  • Power in 2 is more than the the power in 1

Are those three things known to be true?

This ad's from the 50's I think:

tdg.jpg

It's still true.

Alright thanks you guys are a big help this should help me reconfigure my system a lot I really appreciate it.

I think I will just go ahead and buy a small driver, however I am trying to avoid this, as I have very limited space in my final result, so if there is any safe way to control a stepper without a driver, please let me know.

Once again thanks for all the help.

Take a look at the stepper driver motor boards here.

0.6 inch x 0.8 inch, vs your motor diameter of 66mm, or 2.6 inch.

If you can find a way to wire up 8 transistors to make up 2 H-bridges in a small space
https://www.ti.com/lit/ds/symlink/drv8834.pdf - see page 11
then go for it.

SidKadari:
so if there is any safe way to control a stepper without a driver, please let me know.

There isn't! On one side you have your microcontroller outputting the signals for the steppermotor. The maximum current for the signals is some 20 to 40 mA. On the other side you have your hungry motor wanting to swallow hundreds or thousands of mA.

You might find a microcontroller that can output thousands of mA, but in that case it has a built in driver.

Instead of buying a driver, you might connect some mosfets and diodes to read your signals from the microcontroller and further handle the current to the motor. But in that case you have built your own driver.

It just happens that there are lots of example projects for beginners, where you can connect a LED or even a tiny motor directly to the signal pins of a microcontroller. Each of these examples should have a warning text: This example is only for demonstrating how to program the logic. In any real world application you should not power anything with the signal pins. Use transistors or drivers inbetween, instead.