slawekw79
Posts: 31
Joined: Tue Dec 30, 2014 3:36 pm

time in stepper controlling script

Wed Jan 14, 2015 11:28 am

Hi
I made my first script and is running fine, but i'm confused with running time. In my code

Code: Select all

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)

ControlPin = (7,11,13,15)
 
for pin in ControlPin:
	GPIO.setup(pin,GPIO.OUT)
	GPIO.output(pin,0)

seq = [ [1,0,0,0],
	[1,1,0,0],
	[0,1,0,0],
	[0,1,1,0],
	[0,0,1,0],
	[0,0,1,1],
	[0,0,0,1],
	[1,0,0,1] ]
for i in range(50):
    for halfstep in range(8):
        for pin in range(4):
            GPIO.output(ControlPin[pin], seq[halfstep][pin])
        time.sleep(1)

GPIO.cleanup()
motor (200steps/rev) made 1 rev in 40 seconds. Can somebody explain me why is 40 not 50 sec.?

gregeric
Posts: 1509
Joined: Mon Nov 28, 2011 10:08 am

Re: time in stepper controlling script

Wed Jan 14, 2015 1:34 pm

As a python noob, I'd expect that to cycle through 50x8=400 half-steps, and given the indentation of the delay, take 400s (not 40) to do that one full rotation.

Return to “Python”