1

Summary:
Raspberry Pi controls an EasyDriver and stepper motor, but results are inconsistent and the system fails regularly. Can't figure out why.

Long text:
Hi all,

I have a small setup where a stepper motor is supposed to drive a chopper wheel to modulate a signal. Counting steps is not a requirement since the motor comes with an encoder, but a stable speed is a requirement. I'm using the pigpio library (more specifically, the hardware_PWM function) to set the RPM on pin (12) on the Raspberry. Since setting it to full speed instantaneously does not make the stepper motor move at all, I've coded a small ramp-up in speed. The testing script I use has it ramp up to 32000 ppm (20 Hz / 1200 RPM), stay there for a few seconds and then ramp down again.

I've been having a regular issue where at any point during ramp-up, stable running or ramp-down (although usually ramp-up) the motor appears to lose its 'grip' on the rotating shaft and the chopper. From that moment on, the chopper will slow down to 0RPM, but the motor will continue to try and accelerate (ramp-up) or keep speed (stable RPM), causing a whine/buzz different from regular operation. I currently think it must be some sort of timing issue, as in my limited understanding a stepper motor can be compared to a swing in that you'd need to "push" at the right moment, or it'll do nothing or actually slow down. Is it possible that at some random point a timing mismatch between the pulse train and the "ideal push timings" occurs, causing this issue to happen? Surprisingly, others with similar setups and near-identical codes report no issues.

I realize this is probably a mix of Raspberry Pi, hardware and pigpio, but I hope this rings a bell with someone who can help me out, it'd be much appreciated!

Some specs, in case they help:
Motor: NEMA08-17-01D-AMT112S (https://www.cuidevices.com/product/resource/nema08-amt112s.pdf)
Power supply: LPV-150-24 (Repurposed LED-driver, https://www.meanwell-web.com/nl-nl/ac-dc-single-output-led-driver-constant-voltage-c-lpv--150--24)
Driver: EasyDriver ROB-12779 (https://www.sparkfun.com/products/12779)
Testing code: https://pastebin.com/tKS0jvDA (There's a typo in line 7 which is not in the actual code ;) )
Demo of error: https://www.youtube.com/watch?v=KtLGCtxPLPw
Demo notes: In the first cycle, it fails during spin-up, you can hear the frequency increasing but the shaft slows down. In the second attempt, it gets up to speed as it should, and then fails while slowing down, at which point the tune you hear is caused by the mass of the chopper effectively driving an unpowered motor :)

EDIT 29/04: Added code listing to post as requested:

import datetime
import time
import pigpio
import numpy as np
import Rpi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(6, GPIO.OUT)
GPIO.output(6,0)    #Enable motor
pi = pigpio.pi()

freq_startup_diff = 100 freq_startup_wait = 0.01 motor_freq = 32000 startup_range = np.arange(0,motor_freq+1,freq_startup_diff) print('Motor starting') for freq in startup_range: pi.hardware_PWM(int(12),int(freq),int(1e6*0.5)) print("Frequency equals {}".format(freq)) time.sleep(freq_startup_wait)

print('Motor started.')

time.sleep(3) print('Motor stopping.') stop_range = np.flip(startup_range) for freq in stop_range: pi.hardware_PWM(int(12),int(freq),int(1e6*0.5)) print("Frequency equals {}".format(freq)) time.sleep(freq_startup_wait)

GPIO.output(6,1) # Disable motor print('Motor stopped.')

SvB
  • 11
  • 2
  • 2
    You might be better off asking a version of this question on our larger sibling site, Electrical Engineering. – goldilocks Apr 28 '21 at 21:25
  • 1
    please include the actual code listing, not a link to code – jsotola Apr 29 '21 at 01:12
  • There are many reasons why a stepping motor is not stable. I have a couple of posts on EESE on using a variety of motor drivers with satisfactory results. The most recent experiment is still in progress: https://electronics.stackexchange.com/questions/561492/driving-step-motors-using-microstep-drivers-with-teensy-4/561658#561658. You might find from this post a lot of references on my older testing. Cheers. – tlfong01 Apr 29 '21 at 03:04
  • My experiment using A4899: https://electronics.stackexchange.com/questions/560123/fake-microstepping-in-a4899-and-lv8729-stepper-drivers – tlfong01 Apr 29 '21 at 03:06
  • One tool you might like to use for testing is a stable sig gen, like this: I always use it for offline testing: https://raspberrypi.stackexchange.com/questions/104779/how-can-rpi4b-python-uart-talk-to-xy-pwm-signal-generators. Cheers. – tlfong01 Apr 29 '21 at 03:15
  • Your NEMA08 motor with encoder is cute. My stepper also has an encoder, which is good for measuring speed, off line, using a scope. I have the feeling that you are not doing, like me, Micky Mouse hobbyist toy projects. For your industrial grade/scientific applications, Easy Driver is not a good choice, because it is very old, hobbyist grade, has no good microstepping control. – tlfong01 Apr 29 '21 at 03:27
  • Using the DM542 microstepper I am using, say, you can 1/32th microstepping, and use motor PSU at 36+V to jump start as fast as a Prosche! :). My post in EESE has a lot of good (newbie friendly) references on steppers. You need to study carefully the theory behind. Happy studying. Cheers. – tlfong01 Apr 29 '21 at 03:27
  • 1
    Appreciate all the comments, will have a look at the suggested sites and tips! tlfong01 is right in that this is not a MickeyMouse hobby project per se, but the use of cheap/common hardware in this prototype was intentional. Since I don't need any accurate stepping counter or special performance, just accelerating to high (but well within specs!) speeds I didn't think an EasyDriver would cause any issues. – SvB Apr 29 '21 at 12:10
  • @SvB, I agree that Easy Driver meets your spec/requirement. However, if you want high acceleration, microstepping might help, because *you can use high voltage source, 36+V to drive the motor accelerate high, but still using the plain full step mode which is for high speed (than microstepping). For these microsteppers, you can also limit the motor current, to adjust speed/acceleration*. Cheers. PS - Please reply to my account name @ tlfong01, so I will be immediately notified, not missing anything. – tlfong01 Apr 30 '21 at 03:44

0 Answers0