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

Topics about the Hardware of Revolution Pi
Post Reply
yushengzhou
Posts: 7
Joined: 17 Oct 2018, 09:29
Answers: 0

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

Post 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?
User avatar
RevPiModIO
KUNBUS
Posts: 322
Joined: 20 Jan 2017, 08:44
Answers: 0
Contact:

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

Post 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
python3-RevPiModIO - https://revpimodio.org/ || Der RevPi ist das Beste, was passieren konnte!
Post Reply