I use the pwm to drive a steppermotor with microstepping. So as i increase the stepcount, i need to increase the frequency to match the same speed. Am i right? Now my testcode looks like this:
import time
import RPi.GPIO as GPIO
DIR = 20 # Direction GPIO Pin
PWM = 21 # Step GPIO Pin
SLEEP = 16 # Sleep GPIO Pin
CW = 1 # Clockwise Rotation
CCW = 0 # Counterclockwise Rotation
SPR = 3200 # Steps per Revolution (360 / 1.8) (17hs16-2004s Stepper Motor, Step Angle 1.8)
def handler(signum, frame):
raise Exception("end of time")
# timeout = time.time() + 60*5 5 minutes from now
GPIO.setmode(GPIO.BCM)
GPIO.setup(DIR, GPIO.OUT)
GPIO.setup(PWM, GPIO.OUT)
GPIO.setup(SLEEP, GPIO.OUT)
GPIO.output(DIR, CW)
GPIO.output(SLEEP, GPIO.HIGH)
freq = 1500
pwm = GPIO.PWM(PWM, freq)
try:
pwm.start(50.0)
while(freq < 1000000):
freq = freq + 10
pwm.ChangeFrequency()
pwm.stop()
except KeyboardInterrupt:
GPIO.cleanup()
GPIO.output(SLEEP, GPIO.LOW)
GPIO.cleanup()
I just wrote the code out of memory just to give u an idea. And it is missing the microstepping mode and stuff. The gist of my observation is, while cranking up the frequency and therefor the noise of the motor, at some point the noise seems to indicate that the revs and therefor the frequency jump down. It sounds like shifting a car, which is odd. And at some point it doesn't get faster. Well i expected that, but i would like to know when.