0

I am pretty new to the Raspberry Pi. I'm trying to run a stepper-motor, which is connected with my raspberry, with my windows computer. I'm using the library gpiozero. The Code on my Raspberry is working correctly and also pretty fast so the conveyor belt, which is moved by the motor, is moving with a good speed (10 sec for one rotation). If I try to control the motor with my windows computer with the code below, the conveyor belt is moving really slow (~1.5 min for one rotation), so you can barelly see the conveyor belt moving. For examle I dont have any problem with starting the servo with gpiozero. So far this is my code:

import pigpio
import gpiozero
from gpiozero import DigitalOutputDevice as stepper
from gpiozero.pins.pigpio import PiGPIOFactory
gpiozero.Device.pin_factory = PiGPIOFactory(host='192.168.1.104') #Connecting the GPIO
A = stepper(19, initial_value=0,pin_factory=factory) #IN1
B = stepper(16, initial_value=0,pin_factory=factory) #IN2
C = stepper(26, initial_value=0,pin_factory=factory) #IN3
D = stepper(12,  initial_value=0,pin_factory=factory)#IN4
try:
#Instructions from the Manufacturer of the stepper, works on Raspberry (with RPi.GPIO and also on     # Windows but on Windows really slow
    def Step1():
        D.on()
        D.off()
    def Step2():
        D.on()
        C.on()
        D.off()
        C.off()
    def Step3():
        C.on()
        C.off()
    def Step4():
        B.on()
        C.on()
        B.off()
        C.off()
    def Step5():
        B.on()
        B.off()
    def Step6():
        A.on()
        B.on()
        A.off()
        B.off()
    def Step7():
        A.on()
        A.off()
    def Step8():
        D.on()
        A.on()
        D.off()
        A.off()
    for i in range(512): #512 should be the complete rotation of the motor
        Step8()
        Step7()
        Step6()
        Step5()
        Step4()
        Step3()
        Step2()
        Step1()
    
except KeyboardInterrupt:   #Closing GPIO channel on Keyboard Interrupt
    A.close()
    B.close()
    C.close()
    D.close() 
finally:           #probably unnecessary but I wanted to be sure 
    A.close()
    B.close()
    C.close()
    D.close() 

0 Answers0