-
Notifications
You must be signed in to change notification settings - Fork 1
/
MotorInterface (G code).py
81 lines (68 loc) · 2.67 KB
/
MotorInterface (G code).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
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
import serial
from itom import *
import time
#step_size = float(input('Please input the step size in mm: '))
#step_number = int(input('Please input the number of steps: ') )
win = ui("motor.ui", ui.TYPEWINDOW, childOfMainWindow=True)
ser= serial.Serial('COM6', 115200)
def ManualMoveXF():
stepsize =win.stepsizelineEdit["text"]
stepnumber =win.stepnumberlineEdit["text"]
distance =float(stepsize)*float(stepnumber)
gcode = "G21G91X"+str(stepsize)+"F25 \r\n"
for i in range(int(stepnumber)):
ser.write(str.encode(gcode))
time.sleep(0.01)
print("Moved in x by",distance,"mm")
def ManualMoveXB():
stepsize =win.stepsizelineEdit["text"]
stepnumber =win.stepnumberlineEdit["text"]
gcode = "G21G91X"+str(stepsize)+"F25 \r\n"
distance =float(stepsize)*float(stepnumber)
for i in range(int(stepnumber)):
ser.write(str.encode(gcode))
time.sleep(0.01)
print("Moved in x by",distance,"mm")
def ManualMoveYF():
stepsize =win.stepsizelineEdit["text"]
stepnumber =win.stepnumberlineEdit["text"]
gcode = "G21G91Y"+str(stepsize)+"F25 \r\n"
distance =float(stepsize)*float(stepnumber)
for i in range(int(stepnumber)):
ser.write(str.encode(gcode))
time.sleep(0.01)
print("Moved in y by",distance,"mm")
def ManualMoveYB():
stepsize =win.stepsizelineEdit["text"]
stepnumber =win.stepnumberlineEdit["text"]
gcode = "G21G91Y"+str(stepsize)+"F25 \r\n"
distance =float(stepsize)*float(stepnumber)
for i in range(int(stepnumber)):
ser.write(str.encode(gcode))
time.sleep(0.01)
print("Moved in y by",distance,"mm")
def ManualMoveZF():
stepsize =win.stepsizelineEdit["text"]
stepnumber =win.stepnumberlineEdit["text"]
gcode = "G21G91Z"+str(stepsize)+"F25 \r\n"
distance =float(stepsize)*float(stepnumber)
for i in range(int(stepnumber)):
ser.write(str.encode(gcode))
time.sleep(0.01)
print("Moved in z by",distance,"mm")
def ManualMoveZB():
stepsize =win.stepsizelineEdit["text"]
stepnumber =win.stepnumberlineEdit["text"]
distance =float(stepsize)*float(stepnumber)
gcode = "G21G91Z-"+str(stepsize)+"F25 \r\n"
for i in range(int(stepnumber)):
ser.write(str.encode(gcode))
time.sleep(0.01)
print("Moved in z by",distance,"mm")
win.XFButton.connect("clicked()", ManualMoveXF)
win.XBButton.connect("clicked()", ManualMoveXB)
win.YFButton.connect("clicked()", ManualMoveYF)
win.YBButton.connect("clicked()", ManualMoveYB)
win.ZFButton.connect("clicked()", ManualMoveZF)
win.ZBButton.connect("clicked()", ManualMoveZB)
win.show(0)