I want to make a motorized rc paddle boat type machine for fun. I plan to use two stepper motors to spin two wheels on either side of the boat. I am controlling it with python. I have a master script to act as a front end, and two other scripts to manage the motors. Front end:
#!/usr/bin/env python
from m1 import runone
from m1 import setup
from m2 import runtwo
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
setup()
runone()
runtwo()
runone() runs the motor on one side, runtwo() the other, and setup() set's up the pins, and stes them to output. My problem is that it won't that runtwo() can't run until runone() finishes and runone() won't finish until the motor stops. For the ability to turn, the motors need to turn on and off independent of each other. So I can only run one motor! I've tried multithreading and encountered the same error! Thanks in advance. If I need to post more of my code just tell me.
The code for runone()
def runone():
while True:
forward1(0.005, 10000)
def forward1(delay, steps):
for i in range(0, steps):
setStep1(1, 0, 0, 0)
time.sleep(delay)
setStep1(0, 1, 0, 0)
time.sleep(delay)
setStep1(0, 0, 1, 0)
time.sleep(delay)
setStep1(0, 0, 0, 1)
time.sleep(delay)
def setStep1(w11, w12, w13, w14):
GPIO.output(IN11, w11)
GPIO.output(IN12, w12)
GPIO.output(IN13, w13)
GPIO.output(IN14, w14)
startone()
,stopone()
,starttwo()
andstoptwo()
which would do as their names suggest.startone()
would just set the GPIO pin and return. It would stay set until youstopone()
which would clear it.