Page 1 of 1

Why is the stepper motor running so slowly(almost did not move)?

Posted: 26 Oct 2018, 04:45
by yushengzhou
I have a RasPI and a Revpi, Now I want to have a revpi controlled motor, but failed.
My code look like this:

Code: Select all

LinearActuatorDir_x =40
LinearActuatorStepPin_x = 38
def Forward_x():
    GPIO.output(LinearActuatorDir_x, 0)
    GPIO.output(LinearActuatorStepPin_x, 0)
    time.sleep(0.0003)
    GPIO.output(LinearActuatorStepPin_x, 1)
    time.sleep(0.0003)
   )
   
RevPI code is:

Code: Select all

LinearActuatorDir_x = "I_1"
LinearActuatorStepPin_x  = "I_2"
def Forward():
    rpi.io["LinearActuatorDir_x "].value = 0
    rpi.io["LinearActuatorStepPin_x  "].value = 0
    time.sleep(0.0003)
    rpi.io["LinearActuatorStepPin_x  "].value = 1
    time.sleep(0.0003)
    
Everything is the same except RevPI and Raspberry Pi, Why raspberry pie can drive, but revpi can't?

Re: Why is the stepper motor running so slowly(almost did not move)?

Posted: 29 Oct 2018, 15:03
by RevPiModIO
It is because of the cycletime! The RevolutionPi has a cycletime which is about 5ms (with 1 DIO on a RevPi Core3)!

So if you use RevPiModIO, you have to rise cycletime (default about 20ms) to 5 ms to be in sync with the real cyletime of the piBridge...

Code: Select all

rpi.cycletime = 5
BUT that means a minimum sleep of 0.005 :S

Maybe you could control you motor with the PWM function of the DIO/DO modules? https://revolution.kunbus.com/tutorials ... o-modules/

Configure the MEM values of the modules in piCtory and use the "PWM_1" Output to set the speed...

Code: Select all

rpi.io.PWM_1.vlaue = 0
rpi.io.PWM_1.vlaue = 255