-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
50 lines (44 loc) · 1.32 KB
/
test.py
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
import RPi.GPIO as GPIO
import time
from HR8825 import HR8825
try:
Motor1 = HR8825(dir_pin=13, step_pin=19, enable_pin=12, mode_pins=(16, 17, 20))
Motor2 = HR8825(dir_pin=24, step_pin=18, enable_pin=4, mode_pins=(21, 22, 27))
"""
# 1.8 degree: nema23, nema14
# softward Control :
# 'fullstep': A cycle = 200 steps
# 'halfstep': A cycle = 200 * 2 steps
# '1/4step': A cycle = 200 * 4 steps
# '1/8step': A cycle = 200 * 8 steps
# '1/16step': A cycle = 200 * 16 steps
# '1/32step': A cycle = 200 * 32 steps
"""
Motor1.SetMicroStep('softward','fullstep')
Motor1.TurnStep(Dir='forward', steps=200, stepdelay = 0.005)
time.sleep(0.5)
Motor1.TurnStep(Dir='backward', steps=400, stepdelay = 0.005)
Motor1.Stop()
"""
# 28BJY-48:
# softward Control :
# 'fullstep': A cycle = 2048 steps
# 'halfstep': A cycle = 2048 * 2 steps
# '1/4step': A cycle = 2048 * 4 steps
# '1/8step': A cycle = 2048 * 8 steps
# '1/16step': A cycle = 2048 * 16 steps
# '1/32step': A cycle = 2048 * 32 steps
"""
Motor2.SetMicroStep('hardward' ,'halfstep')
Motor2.TurnStep(Dir='forward', steps=2048, stepdelay=0.002)
time.sleep(0.5)
Motor2.TurnStep(Dir='backward', steps=2048, stepdelay=0.002)
Motor2.Stop()
Motor1.Stop()
Motor2.Stop()
except:
# GPIO.cleanup()
print("\nMotor stop")
Motor1.Stop()
Motor2.Stop()
exit()