-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMiniLathe.hal
238 lines (186 loc) · 8.88 KB
/
MiniLathe.hal
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# Generated by PNCconf at Sat Oct 21 15:16:27 2017
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
loadrt tp
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES tp=tp kins=trivkins
loadrt probe_parport
loadrt hostmot2
loadrt hm2_eth board_ip="192.168.1.121" config="num_encoders=1 num_pwmgens=0 num_stepgens=3 sserial_port_0=00xxxx"
loadrt pid names=pid.s
loadrt near
loadrt estop_latch
setp hm2_7i76e.0.watchdog.timeout_ns 10000000
addf hm2_7i76e.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf hm2_7i76e.0.write servo-thread
addf hm2_7i76e.0.pet_watchdog servo-thread
addf estop_latch.0 servo-thread
# external output signals
#net spindle-cw => hm2_7i76e.0.7i76.0.0.output-00
# external input signals
net x-home-sw <= hm2_7i76e.0.7i76.0.0.input-00
net z-home-sw <= hm2_7i76e.0.7i76.0.0.input-01
#hm2_7i76e.0.7i76.0.0.input-02
#net estop-out <= hm2_7i76e.0.7i76.0.0.input-03
#*******************
# AXIS X
#*******************
# Step Gen signals/setup
setp hm2_7i76e.0.stepgen.00.dirsetup [AXIS_0]DIRSETUP
setp hm2_7i76e.0.stepgen.00.dirhold [AXIS_0]DIRHOLD
setp hm2_7i76e.0.stepgen.00.steplen [AXIS_0]STEPLEN
setp hm2_7i76e.0.stepgen.00.stepspace [AXIS_0]STEPSPACE
setp hm2_7i76e.0.stepgen.00.position-scale [AXIS_0]STEP_SCALE
setp hm2_7i76e.0.stepgen.00.step_type 0
setp hm2_7i76e.0.stepgen.00.control-type 0
setp hm2_7i76e.0.stepgen.00.maxaccel [AXIS_0]STEPGEN_MAXACCEL
setp hm2_7i76e.0.stepgen.00.maxvel [AXIS_0]STEPGEN_MAXVEL
net x-pos-fb axis.0.motor-pos-fb <= hm2_7i76e.0.stepgen.00.position-fb
net x-pos-cmd axis.0.motor-pos-cmd => hm2_7i76e.0.stepgen.00.position-cmd
net x-enable axis.0.amp-enable-out => hm2_7i76e.0.stepgen.00.enable
# ---setup home / limit switch signals---
net x-home-sw => axis.0.home-sw-in
net x-neg-limit => axis.0.neg-lim-sw-in
net x-pos-limit => axis.0.pos-lim-sw-in
#*******************
# AXIS Z
#*******************
# Step Gen signals/setup
setp hm2_7i76e.0.stepgen.01.dirsetup [AXIS_2]DIRSETUP
setp hm2_7i76e.0.stepgen.01.dirhold [AXIS_2]DIRHOLD
setp hm2_7i76e.0.stepgen.01.steplen [AXIS_2]STEPLEN
setp hm2_7i76e.0.stepgen.01.stepspace [AXIS_2]STEPSPACE
setp hm2_7i76e.0.stepgen.01.position-scale [AXIS_2]STEP_SCALE
setp hm2_7i76e.0.stepgen.01.step_type 0
setp hm2_7i76e.0.stepgen.01.control-type 0
setp hm2_7i76e.0.stepgen.01.maxaccel [AXIS_2]STEPGEN_MAXACCEL
setp hm2_7i76e.0.stepgen.01.maxvel [AXIS_2]STEPGEN_MAXVEL
net z-pos-fb axis.2.motor-pos-fb <= hm2_7i76e.0.stepgen.01.position-fb
net z-pos-cmd axis.2.motor-pos-cmd => hm2_7i76e.0.stepgen.01.position-cmd
net z-enable axis.2.amp-enable-out => hm2_7i76e.0.stepgen.01.enable
# ---setup home / limit switch signals---
net z-home-sw => axis.2.home-sw-in
net z-neg-limit => axis.2.neg-lim-sw-in
net z-pos-limit => axis.2.pos-lim-sw-in
#*******************
# SPINDLE S
#*******************
setp pid.s.Pgain [SPINDLE_9]P
setp pid.s.Igain [SPINDLE_9]I
setp pid.s.Dgain [SPINDLE_9]D
setp pid.s.bias [SPINDLE_9]BIAS
setp pid.s.FF0 [SPINDLE_9]FF0
setp pid.s.FF1 [SPINDLE_9]FF1
setp pid.s.FF2 [SPINDLE_9]FF2
setp pid.s.deadband [SPINDLE_9]DEADBAND
setp pid.s.maxoutput [SPINDLE_9]MAX_OUTPUT
setp pid.s.error-previous-target true
net spindle-index-enable <=> pid.s.index-enable
net spindle-enable => pid.s.enable
net spindle-vel-cmd-rpm => pid.s.command
net spindle-vel-fb-rpm => pid.s.feedback
net spindle-output <= pid.s.output
# ---Encoder feedback signals/setup---
setp hm2_7i76e.0.encoder.00.counter-mode 0
setp hm2_7i76e.0.encoder.00.filter 1
setp hm2_7i76e.0.encoder.00.index-invert 0
setp hm2_7i76e.0.encoder.00.index-mask 0
setp hm2_7i76e.0.encoder.00.index-mask-invert 0
setp hm2_7i76e.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE
net spindle-revs <= hm2_7i76e.0.encoder.00.position
net spindle-vel-fb-rps <= hm2_7i76e.0.encoder.00.velocity
net spindle-index-enable <=> hm2_7i76e.0.encoder.00.index-enable
# ---setup spindle control signals---
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
net spindle-vel-cmd-rpm <= motion.spindle-speed-out
net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs hm2_7i76e.0.7i76.0.0.spinout
net spindle-enable <= motion.spindle-on hm2_7i76e.0.7i76.0.0.spinena
net spindle-cw <= motion.spindle-forward hm2_7i76e.0.7i76.0.0.output-00
net spindle-ccw <= motion.spindle-reverse
net spindle-brake <= motion.spindle-brake
net spindle-revs => motion.spindle-revs
net spindle-at-speed => motion.spindle-at-speed
net spindle-vel-fb-rps => motion.spindle-speed-in
net spindle-index-enable <=> motion.spindle-index-enable
# ---Setup spindle at speed signals---
net spindle-vel-cmd-rps => near.0.in1
net spindle-vel-fb-rps => near.0.in2
net spindle-at-speed <= near.0.out
setp near.0.scale 1.000000
setp near.0.difference 3.333333
############
setp hm2_7i76e.0.7i76.0.0.spinout-scalemax 5000
setp hm2_7i76e.0.7i76.0.0.spinout-maxlim 5000
setp hm2_7i76e.0.7i76.0.0.spinout-minlim 0
#setp hm2_7i76e.0.encoder.00.counter-mode 0
#setp hm2_7i76e.0.encoder.00.filter 1
#setp hm2_7i76e.0.encoder.00.index-invert 0
#setp hm2_7i76e.0.encoder.00.index-mask 0
#setp hm2_7i76e.0.encoder.00.index-mask-invert 0
#setp hm2_7i76e.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE
#net spindle-revs <= hm2_7i76e.0.encoder.00.position
#net spindle-vel-fb-rps <= hm2_7i76e.0.encoder.00.velocity
#net spindle-index-enable <=> hm2_7i76e.0.encoder.00.index-enable
# ---setup spindle control signals---
#net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
#net spindle-vel-cmd-rps-abs <= motion.spindle-speed-out-rps-abs
#net spindle-vel-cmd <= motion.spindle-speed-out
#net spindle-vel-cmd-rpm-abs <= motion.spindle-speed-out-abs hm2_7i76e.0.7i76.0.0.spinout
#net spindle-on <= motion.spindle-on hm2_7i76e.0.7i76.0.0.spinena
#net spindle-cw <= motion.spindle-forward
#net spindle-ccw <= motion.spindle-reverse
#net spindle-brake <= motion.spindle-brake
#net spindle-revs => motion.spindle-revs
#net spindle-at-speed => motion.spindle-at-speed
#net spindle-vel-fb => motion.spindle-speed-in
#net spindle-index-enable <=> motion.spindle-index-enable
# ---Setup spindle at speed signals---
#sets spindle-at-speed true
#******************************
# connect miscellaneous signals
#******************************
# ---HALUI signals---
net joint-select-a halui.joint.0.select
net x-is-homed halui.joint.0.is-homed
net jog-x-pos halui.jog.0.plus
net jog-x-neg halui.jog.0.minus
net jog-x-analog halui.jog.0.analog
net joint-select-c halui.joint.2.select
net z-is-homed halui.joint.2.is-homed
net jog-z-pos halui.jog.2.plus
net jog-z-neg halui.jog.2.minus
net jog-z-analog halui.jog.2.analog
net jog-selected-pos halui.jog.selected.plus
net jog-selected-neg halui.jog.selected.minus
net spindle-manual-cw halui.spindle.forward
net spindle-manual-ccw halui.spindle.reverse
net spindle-manual-stop halui.spindle.stop
net machine-is-on halui.machine.is-on
net jog-speed halui.jog-speed
net MDI-mode halui.mode.is-mdi
# ---coolant signals---
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-flood <= iocontrol.0.coolant-flood
# ---probe signal---
net probe-in => motion.probe-input
# ---motion control signals---
net in-position <= motion.in-position
net machine-is-enabled <= motion.motion-enabled
# ---digital in / out signals---
# estop
net estop-loopout iocontrol.0.emc-enable-in <= estop_latch.0.ok-out
net estop-loopin iocontrol.0.user-enable-out => estop_latch.0.ok-in
net estop-reset iocontrol.0.user-request-enable => estop_latch.0.reset
net remote-estop estop_latch.0.fault-in <= hm2_7i76e.0.7i76.0.0.input-03
# ---estop signals---
#net estop-out <= iocontrol.0.user-enable-out
#net estop-out => iocontrol.0.emc-enable-in
# ---manual tool change signals---
loadusr -W hal_manualtoolchange
net tool-change-request iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-change-confirmed iocontrol.0.tool-changed <= hal_manualtoolchange.changed
net tool-number iocontrol.0.tool-prep-number => hal_manualtoolchange.number
net tool-prepare-loopback iocontrol.0.tool-prepare => iocontrol.0.tool-prepared