-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_LinuxCNC_machine.hal
286 lines (218 loc) · 9.66 KB
/
my_LinuxCNC_machine.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
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# Generated by PNCconf at Thu Sep 27 11:24:54 2012
# If you make changes to this file, they will be
# overwritten when you run PNCconf again
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hostmot2
loadrt hm2_7i43 config="firmware=hm2/7i43-4/SVST4_4.BIT num_encoders=4 num_pwmgens=1 num_3pwmgens=0 num_stepgens=4 "
setp hm2_7i43.0.pwmgen.pwm_frequency 500
setp hm2_7i43.0.pwmgen.pdm_frequency 6000000
setp hm2_7i43.0.watchdog.timeout_ns 10000000
loadrt abs names=abs.spindle,abs.spindle.pwm
addf hm2_7i43.0.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf abs.spindle servo-thread
addf abs.spindle.pwm servo-thread
addf hm2_7i43.0.write servo-thread
addf hm2_7i43.0.pet_watchdog servo-thread
# external output signals
# external input signals
# --- BOTH-HOME-X ---
net both-home-x <= hm2_7i43.0.gpio.012.in
# --- BOTH-HOME-Y ---
net both-home-y <= hm2_7i43.0.gpio.013.in
# --- BOTH-HOME-Z ---
net both-home-z <= hm2_7i43.0.gpio.014.in
# --- HOME-A ---
#net home-a <= hm2_7i43.0.gpio.015.in
# --- PROBE-IN ---
net probe-in <= hm2_7i43.0.gpio.016.in_not
#*******************
# AXIS X
#*******************
# Step Gen signals/setup
setp hm2_7i43.0.stepgen.00.dirsetup [AXIS_0]DIRSETUP
setp hm2_7i43.0.stepgen.00.dirhold [AXIS_0]DIRHOLD
setp hm2_7i43.0.stepgen.00.steplen [AXIS_0]STEPLEN
setp hm2_7i43.0.stepgen.00.stepspace [AXIS_0]STEPSPACE
setp hm2_7i43.0.stepgen.00.position-scale [AXIS_0]STEP_SCALE
setp hm2_7i43.0.stepgen.00.step_type 0
setp hm2_7i43.0.stepgen.00.control-type 0
setp hm2_7i43.0.stepgen.00.maxaccel 1250.0
setp hm2_7i43.0.stepgen.00.maxvel 85
net x-pos-fb axis.0.motor-pos-fb <= hm2_7i43.0.stepgen.00.position-fb
net x-pos-cmd axis.0.motor-pos-cmd => hm2_7i43.0.stepgen.00.position-cmd
net x-enable axis.0.amp-enable-out => hm2_7i43.0.stepgen.00.enable
# ---setup home / limit switch signals---
net both-home-x => axis.0.home-sw-in
net both-home-x => axis.0.neg-lim-sw-in
net both-home-x => axis.0.pos-lim-sw-in
#*******************
# AXIS Y
#*******************
# Step Gen signals/setup
setp hm2_7i43.0.stepgen.01.dirsetup [AXIS_1]DIRSETUP
setp hm2_7i43.0.stepgen.01.dirhold [AXIS_1]DIRHOLD
setp hm2_7i43.0.stepgen.01.steplen [AXIS_1]STEPLEN
setp hm2_7i43.0.stepgen.01.stepspace [AXIS_1]STEPSPACE
setp hm2_7i43.0.stepgen.01.position-scale [AXIS_1]STEP_SCALE
setp hm2_7i43.0.stepgen.01.step_type 0
setp hm2_7i43.0.stepgen.01.control-type 0
setp hm2_7i43.0.stepgen.01.maxaccel 1250.0
setp hm2_7i43.0.stepgen.01.maxvel 85
net y-pos-fb axis.1.motor-pos-fb <= hm2_7i43.0.stepgen.01.position-fb
net y-pos-cmd axis.1.motor-pos-cmd => hm2_7i43.0.stepgen.01.position-cmd
net y-enable axis.1.amp-enable-out => hm2_7i43.0.stepgen.01.enable
# ---setup home / limit switch signals---
net both-home-y => axis.1.home-sw-in
net both-home-y => axis.1.neg-lim-sw-in
net both-home-y => axis.1.pos-lim-sw-in
#*******************
# AXIS Z
#*******************
# Step Gen signals/setup
setp hm2_7i43.0.stepgen.02.dirsetup [AXIS_2]DIRSETUP
setp hm2_7i43.0.stepgen.02.dirhold [AXIS_2]DIRHOLD
setp hm2_7i43.0.stepgen.02.steplen [AXIS_2]STEPLEN
setp hm2_7i43.0.stepgen.02.stepspace [AXIS_2]STEPSPACE
setp hm2_7i43.0.stepgen.02.position-scale [AXIS_2]STEP_SCALE
setp hm2_7i43.0.stepgen.02.step_type 0
setp hm2_7i43.0.stepgen.02.control-type 0
setp hm2_7i43.0.stepgen.02.maxaccel 1250.0
setp hm2_7i43.0.stepgen.02.maxvel 85
net z-pos-fb axis.2.motor-pos-fb <= hm2_7i43.0.stepgen.02.position-fb
net z-pos-cmd axis.2.motor-pos-cmd => hm2_7i43.0.stepgen.02.position-cmd
net z-enable axis.2.amp-enable-out => hm2_7i43.0.stepgen.02.enable
# ---setup home / limit switch signals---
net both-home-z => axis.2.home-sw-in
net both-home-z => axis.2.neg-lim-sw-in
net both-home-z => axis.2.pos-lim-sw-in
#*******************
# SPINDLE S
#*******************
setp hm2_7i43.0.encoder.00.scale 2000
setp hm2_7i43.0.encoder.00.index-invert 0
setp hm2_7i43.0.encoder.00.index-mask 0
setp hm2_7i43.0.encoder.00.index-mask-invert 0
setp hm2_7i43.0.encoder.00.counter-mode 0
net spindle-vel-fb1 hm2_7i43.0.encoder.00.velocity
# ---PWM Generator signals/setup---
setp hm2_7i43.0.pwmgen.00.output-type 1
setp hm2_7i43.0.pwmgen.00.scale [SPINDLE_9]OUTPUT_SCALE
loadrt scale names=spindle.pwm.scale,rps.spindle
addf spindle.pwm.scale servo-thread
setp spindle.pwm.scale.gain .6923
setp spindle.pwm.scale.offset 1090
loadrt value_mapper commanded="300,400,500,600,700,800,900,1000,2000,3000,4000" measured="318,434,522,617,780,890,1000,1100,2010,2880,3530"
addf value-mapper.0 servo-thread
net spindle-vel-cmd => abs.spindle.pwm.in
net spindle-vel-cmd-abs abs.spindle.pwm.out spindle.pwm.scale.in
net spindle-vel-cmd-scaled => spindle.pwm.scale.out value-mapper.0.in
net value-mapper-out => value-mapper.0.out
net value-mapper-out hm2_7i43.0.pwmgen.00.value
#loadrt cutneg
#addf cutneg.0 servo-thread
#net pid_output cutneg.0.in
#net pid_output_positive cutneg.0.out hm2_7i43.0.pwmgen.00.value
net spindle-enable => hm2_7i43.0.pwmgen.00.enable
# Initialize the PID
#loadrt at_pid num_chan=1
#addf pid.0.do-pid-calcs servo-thread
#setp pid.0.Pgain 0
#setp pid.0.Igain 1
#setp pid.0.Dgain 1
#setp pid.0.bias 1090
#setp pid.0.FF0 .5
#setp pid.0.maxoutput 4000
#net spindle-enable pid.0.enable
# Attach the pid to the scale, motion, and sum
#net absolute-spindle-vel pid.0.feedback
#net spindle-vel-cmd pid.0.command
#net pid_output pid.0.output
# ---setup spindle control signals---
addf rps.spindle servo-thread
setp rps.spindle.gain 60
net spindle-vel-fb1 rps.spindle.in
net spindle-vel-fb rps.spindle.out
setp hm2_7i43.0.encoder.00.index-mask 1
net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps
net spindle-vel-cmd <= motion.spindle-speed-out
net spindle-enable <= motion.spindle-on
net spindle-cw <= motion.spindle-forward
net spindle-ccw <= motion.spindle-reverse
net spindle-brake <= motion.spindle-brake
net spindle-revs => motion.spindle-revs hm2_7i43.0.encoder.00.position
net spindle-at-speed => motion.spindle-at-speed
net spindle-vel-fb => motion.spindle-speed-in
net spindle-index-enable <=> motion.spindle-index-enable
net spindle-index-enable <=> hm2_7i43.0.encoder.00.index-enable
# ---Setup spindle at speed signals---
sets spindle-at-speed true
# Use COMMANDED spindle velocity from LinuxCNC because no spindle encoder was specified
# COMMANDED velocity is signed so we use absolute component to remove sign
net spindle-vel-fb => abs.spindle.in
net absolute-spindle-vel <= abs.spindle.out
# Spindle control gpio
setp hm2_7i43.0.gpio.006.invert_output 1
setp hm2_7i43.0.gpio.006.is_output 1
setp hm2_7i43.0.gpio.008.invert_output 1
setp hm2_7i43.0.gpio.008.is_output 1
net spindle-enable hm2_7i43.0.gpio.006.out
net spindle-ccw hm2_7i43.0.gpio.008.out
#******************************
# 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-b halui.joint.1.select
net y-is-homed halui.joint.1.is-homed
net jog-y-pos halui.jog.1.plus
net jog-y-neg halui.jog.1.minus
net jog-y-analog halui.jog.1.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
# machine on signal
setp hm2_7i43.0.gpio.047.is_output 1
# aclive LOW
setp hm2_7i43.0.gpio.047.invert_output 1
#connect with MESA
net machine-is-on hm2_7i43.0.gpio.047.out
# ---coolant signals---
#flood relay
setp hm2_7i43.0.gpio.046.is_output 1
setp hm2_7i43.0.gpio.046.invert_output 1
net coolant-mist <= iocontrol.0.coolant-mist
net coolant-flood <= iocontrol.0.coolant-flood
#net coolant-flood hm2_7i43.0.gpio.046.out
# ---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 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