-
Notifications
You must be signed in to change notification settings - Fork 2
/
hot_wire_guillotine.py
168 lines (147 loc) · 6.25 KB
/
hot_wire_guillotine.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
class Guillotine:
def __init__(self, app , queueCmd):
self.app = app
self.queueCmd = queueCmd
def calculateMove(self , factor):
axis = self.app.gCodeLetters.text()
if self.app.rbGuillotineVertical.isChecked() : # "Vertical":
move = axis[1] + str(factor * self.app.gVDist.value()) + axis[3] + str(factor * self.app.gVDist.value())
elif self.app.rbGuillotineHorizontal.isChecked() : # "Horizontal":
move = axis[0] + str(factor * self.app.gHDist.value()) + axis[2] + str(factor * self.app.gHDist.value())
else:
move = axis[1] + str(factor * self.app.gVDist.value()) + axis[0] + str(factor * self.app.gHDist.value()) + (
axis[3] + str(factor * self.app.gVDist.value()) + axis[2] + str(factor * self.app.gHDist.value()) )
return move
def goForward(self):
command = ["G21" , "G91", "G94"] # mm incremental normal feed rate
if self.app.rbGuillotineForward.isChecked() or self.app.rbGuillotineBoth.isChecked(): # "Forward" or "Both":
command.append("M3")
command.append("S" + str( int(self.app.gHeating.value()) ) )
command.append( "G04P" + str(self.app.tPreHeat.value() ) )
command.append("F" +str(60 * self.app.gCuttingSpeed.value() ))
command.append( "G01")
else:
command.append( "G00")
command.append( self.calculateMove(1))
if self.app.rbGuillotineForward.isChecked() or self.app.rbGuillotineBoth.isChecked(): # "Forward" or "Both":
command.append( "G04P" + str(self.app.tPostHeat.value() ) )
command.append("M5")
print("\n".join(command))
self.app.tGrbl.stream("\n".join(command))
def goBackward(self):
command = ["G21" , "G91", "G94"] # mm incremental normal feed rate
if self.app.rbGuillotineBackward.isChecked() or self.app.rbGuillotineBoth.isChecked(): # "Backward" or "Both":
command.append("M3")
command.append("S" + str( int(self.app.gHeating.value()) ) )
command.append( "G04P" + str(self.app.tPreHeat.value() ) )
command.append("F"+str(60 * self.app.gCuttingSpeed.value() ))
command.append( "G01")
else:
command.append( "G00")
command.append( self.calculateMove(-1))
if self.app.rbGuillotineForward.isChecked() or self.app.rbGuillotineBoth.isChecked(): # "Forward" or "Both":
command.append( "G04P" + str(self.app.tPostHeat.value() ) )
command.append("M5")
print("\n".join(command))
self.app.tGrbl.stream("\n".join(command))
def startHeat(self):
command = ["S" + str( int(self.app.gHeating.value()) ) , "M3"]
self.app.tGrbl.stream("\n".join(command))
def stopHeat(self):
command = ["S0" ,"M5"]
self.app.tGrbl.stream("\n".join(command))
def moveUp(self):
self.move("Up")
def moveDown(self):
self.move("Down")
def moveForward(self):
self.move("Forward")
def moveBack(self):
self.move("Back")
def move(self, dir):
command = ["G21" , "G91" , "G94"] # mm incremental normal feed rate
axis = self.app.gCodeLetters.text()
axisIdx = 0
dirPos = 1
if dir == "Up":
axisIdx = 1
elif dir == "Down":
axisIdx = 1
dirPos = -1
elif dir == "Back":
dirPos = -1
if self.app.rbMoveLeftAxis.isChecked(): #"Left"
command.append("G00 "+ axis[axisIdx]+ str(dirPos * self.app.gMoveDist.get() ) )
elif self.app.rbMoveRightAxis.isChecked(): # "Right":
command.append("G00 "+ axis[axisIdx+2]+ str(dirPos * self.app.gMoveDist.get() ) )
else: # both axis
command.append("G00 "+ axis[axisIdx]+ str(dirPos * self.app.gMoveDist.value() ) +
axis[axisIdx+2]+ str(dirPos * self.app.gMoveDist.value() ) )
print("\n".join(command))
self.app.tGrbl.stream("\n".join(command))
def connect(self):
self.queueCmd.put("Connect")
def disconnect(self):
self.queueCmd.put("Disconnect")
"""
def updateBtnState(self):
grblStatus= self.app.grblStatus.text()
if grblStatus == "Not connected" or grblStatus == "Connection lost":
state = False
oppositeState = True
else:
state = True
oppositeState = False
self.app.pbMoveGuillotineForward.setEnabled(state)
self.app.pbMoveGuillotineForward.setEnabled(state)
self.app.pbMoveCancel.setEnabled(state)
self.app.pbConnect.setEnabled(oppositeState)
self.app.pbDisconnect.setEnabled(state)
self.app.pbReset.setEnabled(state)
self.app.pbUnlock.setEnabled(state)
self.app.pbHome.setEnabled(state)
self.app.pbSetPosition.setEnabled(state)
self.app.pbGoToPosition.setEnabled(state)
self.app.pbStartHeating.setEnabled(state)
self.app.pbStopHeating.setEnabled(state)
self.app.pbMoveUp.setEnabled(state)
self.app.pbMoveBack.setEnabled(state)
self.app.pbMoveForward.setEnabled(state)
self.app.pbMoveDown.setEnabled(state)
self.app.pbCut.setEnabled(state)
self.app.pbCutCancel.setEnabled(state)
self.app.pbSaveGcode.setEnabled(state)
"""
"""
def my_callback(eventstring, *data):
args = []
for d in data:
args.append(str(d))
print("MY CALLBACK: event={} data={}".format(eventstring.ljust(30), ", ".join(args)))
# Now, do something interesting with these callbacks
"""
"""
Add a connect button:
Greate Gerbil instance
Configure Com and baudrate
Add a disconnect button:
Disconnect
Add a button reset GRBL
Add a button unlock GRBL
Display a value Disconnected or GRBL status
When Arming:
generate the string for moving up
set a heating flag on ON/OFF depending on GUI
Check that connected and GRBL status
Send GRBL command : mm, relatif
If heating:
Calculate heating (for the speed)
Send heating and pause
Send G01 command with feedrate
pause
else
send G00 command
When Cutting
idem with negative value
set heating flag on OFF
"""