Stepper motor doesn't work

Hi,

=== edit after finished thread ===
TLDR: Go to the last post if you use the same "shield" for A4988 (pictured below).
=== edit ends ===

please can someone help me with wiring?

I'm trying this with simple code (which works fine, measured pins and they do what is expected of them) but stepper motor will not even move.

Aligators provide 12v for motor, nano esp32 has power from usb connection.

4 wires from stepper change color out of the photo into white, grey, purple and blue. Pairs checked and connected as they should (afaik).

What can be wrong here? This is first time with stepper motor for me, so i might be missing something obvious. Please help!

Usually not a good idea for high current motor

Does your driver work with 3.3V logic signals?
Did you set the current limit on the driver?
Can your power supply provide enough current for the motor?
Is the motor wired correctly?
Is the driver wired correctly?

1 Like

Thanks, Jim!

It is A4988 with additional pcb for easier connections and such. Now I look at spec it says logic 5v! Thank you! Can this be responsible for not working at all?

How did I missed that? :confused: I knew esp32 do not have 5v coz it gave me headache in the past. argh!

Yes, I did.

Yes, it's table top lab power supply. Driver accepts 12-24v - do you think it would be better to give it 24?

That I do not know, but with this new information I will have to change nano ESP32 into just nano or uno with 5v on board and check if this wiring works.

Thanks for the hint.

Hi,
When you get everything setup for 5V, can you please post a copy of your circuit, a picture of a hand drawn circuit in jpg, png?
Hand drawn and photographed is perfectly acceptable.
Please include ALL hardware, power supplies, component names and pin labels.

Thanks.. Tom... :smiley: :+1: :coffee: :australia:

1 Like

Well, what you ask for if bigger challenge then making this stepper work for me :wink:

But, I'll try! Challenge accepted!

But have in mind that my skills of making circuit diagrams are like 0/10 :wink:

The A4988 will work with 3.3V, provided VDD is connected to the nanoESP 3.3V output.

Yes, it's table top lab power supply. Driver accepts 12-24v - do you think it would be better to give it 24?

12V is OK but can it supply enough current?

Yes, I did.

To something a little higher than that required by the motor?

This website has dos and don'ts for that driver

1 Like

Ah, so I will not have to change to other board! It is connected to pin 3.3v on arduino.

Yes, up to 10A it says in the spec.

To 0.02v lower then what I calculated. Stepper is 1A, so my calculations gave me 0.544 and I've set it to 0.52.

Thanks for the link - going through it now.

EDIT:
I thought I will paste here my stepper spec as well:
P/N: SHP-42D0019
COIL: ~3.5VDC/1A/3.5 Ohms/4.4mH
TYPE: 2 Phase Bi-Polar 4 lead
STEP ANGLE: 1.8 deg

Looks like you did everything right.
So maybe a wiring error or you accidentally burned out the driver.
In any case, it's time to see your code.
In the IDE, click on Edit, then click on Copy for Forum, that will copy your code. Then come back to the forum and just do a paste.

1 Like
    // Define pin connections & motor's steps per revolution
    const int dirPin = 21;
    const int stepPin = 38;
    const int stepsPerRevolution = 200;
    void setup()
    {
         Serial.begin(9600);
    	// Declare pins as Outputs
    	pinMode(stepPin, OUTPUT);
    	pinMode(dirPin, OUTPUT);
    }
    void loop()
    {
      Serial.println("loop start");
    	// Set motor direction clockwise
    	digitalWrite(dirPin, HIGH);
    	// Spin motor slowly
    	for(int x = 0; x < stepsPerRevolution; x++)
    	{
    		digitalWrite(stepPin, HIGH);
    		delayMicroseconds(2000);
    		digitalWrite(stepPin, LOW);
    		delayMicroseconds(2000);
    	}
    	delay(1000); // Wait a second
    	
    	// Set motor direction counterclockwise
    	digitalWrite(dirPin, LOW);
    	// Spin motor quickly
    	for(int x = 0; x < stepsPerRevolution; x++)
    	{
    		digitalWrite(stepPin, HIGH);
    		delayMicroseconds(1000);
    		digitalWrite(stepPin, LOW);
    		delayMicroseconds(1000);
    	}
    	delay(1000); // Wait a second
    }

I can't tell from you photo if you have it wired correctly but if you follow the information on the pololu web page it should be correct. Also I see nothing wrong in your code.

1 Like

Hi,
I agree with @jim-p , your code looks okay.
Can you measure any voltage on the stepper wires when you run your code.

Try longer steps than 2000 ms.
The stepper will not reverse in your code, as the direction is set as clockwise immediately before the for loop.

Slow everything down, so you can observe some voltage levels.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

I will have some time later tonight and I will try to measure.

I have already measured the pins on arduino which are connected to step and dir and those show changes - so that way I knew code is trying to do correct thing.

What should I see while measuring coils while they (should) work?

Also EN(able) on driver - I just left it not connected, but maybe I should have connected it and set it to LOW in the code? Does this matter?

One more question: driver becomes very hot even though stepper does not move - is this expected? I mean, it's not smoking hot, but 'can't really hold it' kind of hot. Can this be hint to wrong wiring?

Of course I could not wait until when I should! :wink: My kids can wait! :wink:

So I measured voltage between common ground and coils:

Coil 1: 11.75V
Coil 2: 6.85V

I have no idea what that means - good or bad? :slight_smile:

You should have two readings per coil with reference to gnd.
There are four wires.

Tom.. :smiley: :+1: :coffee: :australia:

1 Like

Of course...

Coil 1:
2.8V
2.8V

Coil 2:
11.75V
11.75V

Interestingly they do not change at all while code runs. Even if I will disconnect arduino from usb (so power down) those readings are the same...

edit 1:
Not sure how I measured 6.85V before?

edit2:
I think I wrongly measured one wire from one coil and other from other coil...

And I made wiring diagram as I said I will :slight_smile:

1 Like

OK, I'm confused now. While creating this schema above I started wondering if the stepper connection is correct. I mean I'm pretty sure which cables from the stepper are one coil, however I found contradictory information about connection to driver:

Should I treat number or letter as same coil indicator?

Is A1 and A2 one coil? Or A1 and B1 one coil?

After changing my connections to the ones on the diagram it is now more difficult to measure voltage on coils because they are changing. It seems like a good thing, but stepper is still stationary like a stone.

Your wiring is not correct. The numbers ( 1 and 2 ) are the coil indicators. You can see it at the pololu website ( scroll down a little bit).

1 Like

Does your A4988 module have the same shunt resistors (that determine Vref voltage) as the Pololu A4988 carrier?

1 Like

Have you lengthened the step widths?
Say to 100ms.

Tom... :smiley: :+1: :coffee: :australia:

1 Like