Electrical – Inconsistency Issues With Stepper Motor

arduinodrivermotorstepper motor

I am attempting to get my stepper motor to rotate 90 degrees, stop for a second, and repeat these steps.

Please note I am a beginner, but I have taken physics courses so I do understand most basic electronics concepts such as voltage, amperage, series, parallel, resistance, etc…

So the way I am setting this up is with a raspberry pi connected connected to an a4988 Pololu stepper motor driver which outputs 2 amps at optimal cooling and 12v, with a bipolar stepper motor that is rated at 2/amps per phase and is receiving 12v. The motors are being powered by a 30 amp, 12v power supply.

Everything is wired according to the attached diagram, and has been tested many times. Many different scripts have been used, and currently we are using a Python script from the RPI that runs 50 steps (90 degrees), then waits one second. This code works and is correct, because sometimes it works. When running, the motor does heat up, but not hot to the touch. Additionally, when powered but not running code, it buzzes and clicks sometimes, not moving. Online sources said this was okay.

It seems to be very random when it works and when it does not work, for example when testing the current going through one of the coil wires using a multimeter wired in series, the motor works perfectly, but when the multimeter is not there, the motor freaks out, buzzes, and changes direction erratically, one theory of mine as to why this is is due to the added resistance, in which case putting a resistor in series may fix the problem, but doesn't seem to address the root of the issue.

Other actions taken: -Using an arduino uno instead of Pi, same issues -Running the code using different ways, different libraries etc. -switched to different motor, and driver. -re-wired everything multiple times -adjusting the voltage control screw on the driver. -provided adequate cooling to the PSU and driver (2 120mil computer fans)

https://i.imgur.com/Ku2UgAxl.jpg

— wiring layout

https://i.imgur.com/undefined.jpeg — picture of setup

https://i.imgur.com/Fx7ErH1.jpg

— code used

any help or suggestions would be greatly appreciated, too many hours have gone into this. LMK if any additional info is needed.

Best Answer

Several possibilities:

You might try adding delays to get 50% duty cycle as suggested by jonk.
...
GPIO.output(21,true)
time.sleep(0.01)
GPIO.output(21,false)
time.sleep(0.01)
...

You might also try adding acceleration and deceleration ramps to your code and using an Arduino library that supports them (like AccelStepper).

Also, context switching on the Raspberry Pi will cause non-uniformity in the timing of the step pulse train which translates to asking the motor to accelerate and decelerate very quickly which may exceed the motor's torque capabilities. Stepper motor's torque generally drops with rotational speed but usually has a resonance band where torque drops to near zero at a certain speed range. Putting a flywheel on the shaft (or other load with a bit of angular inertia) can minimize the resonance effect.