This repository was archived by the owner on Dec 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStepper_Move_Step.py
More file actions
89 lines (70 loc) · 1.86 KB
/
Stepper_Move_Step.py
File metadata and controls
89 lines (70 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
from time import sleep
import RPi.GPIO as GPIO
DIR = 20 #Direction GPIO Pin
STEP = 21 #Step GPIO Pin
CW = 1 #Clockwise Rotation
CCW = 0 #Counterclockwise Rotation
SPR = 400 # Steps per Revolution
#numSteps = 2 #This number is the number of photos and the number of steps to stop.
def moveStep(numSteps):
print("moviendo stepper...")
GPIO.setmode(GPIO.BCM)
GPIO.setup(DIR,GPIO.OUT)
GPIO.setup(STEP,GPIO.OUT)
GPIO.output(DIR, CW)
MODE = (14, 15, 18) #Microsteo Resolution GPIO Pins
GPIO.setup(MODE, GPIO.OUT)
RESOLUTION = {'Full' : (0, 0, 0),
'Half' : (1, 0, 0),
'1/4' : (0, 1, 0),
'1/8' : (1, 1, 0),
'1/16' : (0, 0, 1),
'1/32' : (1, 0, 1),}
GPIO.output(MODE,RESOLUTION['1/32'])
step_count = SPR * 32
delay = .0208 / 32
for x in range(int(step_count/numSteps)):
GPIO.output(STEP, GPIO.HIGH)
sleep(delay)
GPIO.output(STEP, GPIO.LOW)
sleep(delay)
sleep(.5)
GPIO.cleanup()
def moveAll():
GPIO.setmode(GPIO.BCM)
GPIO.setup(DIR,GPIO.OUT)
GPIO.setup(STEP,GPIO.OUT)
GPIO.output(DIR, CW)
MODE = (14, 15, 18) #Microsteo Resolution GPIO Pins
GPIO.setup(MODE, GPIO.OUT)
RESOLUTION = {'Full' : (0, 0, 0),
'Half' : (1, 0, 0),
'1/4' : (0, 1, 0),
'1/8' : (1, 1, 0),
'1/16' : (0, 0, 1),
'1/32' : (1, 0, 1),}
GPIO.output(MODE,RESOLUTION['1/32'])
GPIO.output(DIR,CCW)
step_count = SPR * 32
delay = .0208 / 32
for x in range(int(step_count)):
GPIO.output(STEP, GPIO.HIGH)
sleep(delay)
GPIO.output(STEP, GPIO.LOW)
sleep(delay)
sleep(.5)
GPIO.cleanup()
#moveStep(numSteps)
"""for x in range(step_count):
GPIO.output(STEP, GPIO.HIGH)
sleep(delay)
GPIO.output(STEP, GPIO.LOW)
sleep(delay)
sleep(.5)
GPIO.output(DIR,CCW)
for x in range(step_count):
GPIO.output(STEP, GPIO.HIGH)
sleep(delay)
GPIO.output(STEP,GPIO.LOW)
sleep(delay)"""
#GPIO.cleanup()