-
Notifications
You must be signed in to change notification settings - Fork 0
/
homingSequence.pde
104 lines (74 loc) · 1.84 KB
/
homingSequence.pde
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
String[] homingSequencePT1 = {
"G90 G0 Z-12.5\n",
"G28.2 A0\n",
"G91 G0 A30\n",
"$di1fn=2\n",
"G91 G0 A1\n",
"G91 G1 A-30 F250\n",
};
String[] homingSequencePT2 = {
"~\n",
"G91 G0 A0\n",
"G90 G0 A",
"G28.3 A0\n",
"G90 G0 Z0 A20\n"
};
void letsHome(char theAxis) {
isHoming = true;
isHomed = false;
switch (theAxis) {
case 'a':
// home A (bend) axis only
// assumes all other axes are homed
for (int k=0; k<homingSequencePT1.length; k++) {
dataQueue.add(homingSequencePT1[k]);
}
break;
case 'x':
// home X (feed) axis only
dataQueue.add("G28.2 X0\n");
break;
case 'z':
// home Z (duck) axis only
dataQueue.add("G28.2 Z0\n");
break;
case '*':
// home all axes
// Add the first chunk of the homing sequence to the queue
dataQueue.add("G28.2 Z0 X0\n");
for (int k=0; k<homingSequencePT1.length; k++) {
dataQueue.add(homingSequencePT1[k]);
}
break;
default:
break;
}
}
void homePT2(float posA) {
// isHoming=true;
// append the result of $posA to the second line
homingSequencePT2[2] += str(posA/2);
homingSequencePT2[2] += "\n";
println("GOT THIS POS: " + homingSequencePT2[2]);
// add the chunk to the queue
for (int i=1; i<homingSequencePT2.length; i++) {
dataQueue.add(homingSequencePT2[i]);
}
}
/* Old useless homing
dataQueue.add("G90\n");
dataQueue.add("G0 Z-9\n");
dataQueue.add("G28.2 A0\n");
dataQueue.add("G1 A30 F5000\n");
dataQueue.add("$di1mo=2\n");
dataQueue.add("G1 A-30 F500\n");
dataQueue.add("%\n");
dataQueue.add("$posa\n");
// here you listen for the response
// divide the position / 2
//move there:
dataQueue.add("g90 g0 a___"); // where ___ is the position you calculated
dataQueue.add("G28.3 A0\n");
dataQueue.add("G0 Z0\n");
dataQueue.add("$fi1fn=0\n");
*/