yushengzhou
Topic Author
Posts: 7
Joined: 17 Oct 2018, 09:29

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

26 Oct 2018, 04:45

I have a RasPI and a Revpi, Now I want to have a revpi controlled motor, but failed.
My code look like this:
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:
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
Posts: 257
Joined: 20 Jan 2017, 08:44
Contact:

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

29 Oct 2018, 15:03

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...
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...
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!

Who is online

Users browsing this forum: No registered users and 1 guest