-
Notifications
You must be signed in to change notification settings - Fork 2
/
shopbot-config-1.hal
355 lines (260 loc) · 12.2 KB
/
shopbot-config-1.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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
###EMC2.4.2 Configuration for Shopbot-Ultra, developed at Boulder Engineering Studio, July 2010
# ###################################
# BEGIN Core EMC/HAL Loads
# ###################################
# This machine uses Gantry kinematics.
# Joint 1 and joint 3 are motors on either side of the gantry, driving the gantry along the Y axis
# Joint 0 is a motor on the gantry, driving the spindle sled side to side on the gantry along the X axis
# Joint 2 is a motor on the spindle sled, driving the spindle along the Z axis
loadrt [KINS]KINEMATICS coordinates=xyzy kinstype=BOTH
#autoconverted gantrykins coordinates=xyzy
# Load the realtime portion of classic ladder
loadrt classicladder_rt numRungs=12 numBits=20 numWords=4 numTimers=5 numMonostables=2 numPhysInputs=16 numPhysOutputs=16 numArithmExpr=4 numSections=4
# Loader the userspace portion of Classic Ladder to silently load the program
loadusr classicladder --modmaster --nogui shopbot-ladder-1.clp
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS
# hostmot2 driver
loadrt hostmot2
# load low-level driver
loadrt hm2_pci config="firmware=hm2/5i23/SVST2_4_7I47.BIT num_encoders=4 num_pwmgens=2 num_stepgens=4"
setp hm2_5i23.0.pwmgen.pwm_frequency 100000
setp hm2_5i23.0.pwmgen.pdm_frequency 100000
#
# build servo thread
#
addf hm2_5i23.0.read servo-thread
# linuxcnc 2.7 pets the watchdog in hm2_write
#addf hm2_5i23.0.pet_watchdog servo-thread
addf conv-s32-float.0 servo-thread
addf conv-s32-float.1 servo-thread
addf conv-s32-float.2 servo-thread
addf conv-s32-float.3 servo-thread
addf conv-s32-float.4 servo-thread
addf conv-s32-float.5 servo-thread
addf conv-s32-float.6 servo-thread
addf conv-s32-float.7 servo-thread
addf sum2.0 servo-thread
addf sum2.1 servo-thread
addf sum2.2 servo-thread
addf sum2.3 servo-thread
addf toggle.0 servo-thread
addf toggle.1 servo-thread
addf toggle.4 servo-thread
addf toggle.5 servo-thread
addf toggle.6 servo-thread
addf and2.zero-all servo-thread
addf and2.zero-x servo-thread
addf and2.zero-y servo-thread
addf and2.zero-z servo-thread
addf and2.zero-plate servo-thread
addf or2.spindle-fan-power servo-thread
addf classicladder.0.refresh servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
# these two take the spindle speed command from motion and cook it for the arduino
addf scale.spindle-speed servo-thread
addf abs.spindle-speed servo-thread
addf hm2_5i23.0.write servo-thread
# ################################################
# External Output Signals
# ################################################
#Contactor control for Stepper power
net contactor-stepper-control <= joint.0.amp-enable-out
net contactor-stepper-control => hm2_5i23.0.gpio.044.out
net contactor-stepper-control => hm2_5i23.0.stepgen.01.enable
setp hm2_5i23.0.gpio.044.is_output 1
setp hm2_5i23.0.gpio.044.is_opendrain 1
setp hm2_5i23.0.gpio.044.invert_output 1
#setp hm2_5i23.0.gpio.044.out 1
#Contactor control for Spindle power
#net contactor-spindle-control <= joint.1.amp-enable-out
#net contactor-spindle-control => hm2_5i23.0.gpio.046.out
setp hm2_5i23.0.gpio.046.is_output 1
setp hm2_5i23.0.gpio.046.is_opendrain 1
setp hm2_5i23.0.gpio.046.invert_output 1
#Spindle Power Enable
net spindle-power-enable-control => hm2_5i23.0.gpio.046.out
#Spindle Fan Control
net spindle-fan-control => hm2_5i23.0.gpio.047.out
setp hm2_5i23.0.gpio.047.is_output 1
setp hm2_5i23.0.gpio.047.is_opendrain 1
setp hm2_5i23.0.gpio.047.invert_output 1
#Spindle Forward / Reverse Control
#net spindle-forward-control => hm2_5i23.0.gpio.041.out
setp hm2_5i23.0.gpio.041.is_output 1
setp hm2_5i23.0.gpio.041.is_opendrain 1
setp hm2_5i23.0.gpio.041.invert_output 1
#net spindle-reverse-control => hm2_5i23.0.gpio.043.out
setp hm2_5i23.0.gpio.043.is_output 1
setp hm2_5i23.0.gpio.043.is_opendrain 1
setp hm2_5i23.0.gpio.043.invert_output 1
#Mist Coolant Control
#net mist-control => hm2_5i23.0.gpio.043.out
#setp hm2_5i23.0.gpio.043.is_output 1
#Stepper Driver Digital I/O
net alarm-clear-x => hm2_5i23.0.gpio.054.out
setp hm2_5i23.0.gpio.054.is_output 1
net alarm-clear-y1 => hm2_5i23.0.gpio.050.out
setp hm2_5i23.0.gpio.050.is_output 1
net alarm-clear-z => hm2_5i23.0.gpio.058.out
setp hm2_5i23.0.gpio.058.is_output 1
net alarm-clear-y2 => hm2_5i23.0.gpio.062.out
setp hm2_5i23.0.gpio.056.is_output 1
net stepper-windings-off-x => hm2_5i23.0.gpio.055.out
setp hm2_5i23.0.gpio.055.is_output 1
net stepper-windings-off-y1 => hm2_5i23.0.gpio.051.out
setp hm2_5i23.0.gpio.051.is_output 1
net stepper-windings-off-z => hm2_5i23.0.gpio.059.out
setp hm2_5i23.0.gpio.059.is_output 1
net stepper-windings-off-y2 => hm2_5i23.0.gpio.063.out
setp hm2_5i23.0.gpio.063.is_output 1
# ################################################
# External Input Signals
# ################################################
#Contactor status for Stepper and Spindle power
net contactor-stepper-status <= hm2_5i23.0.gpio.064.in
net contactor-spindle-status <= hm2_5i23.0.gpio.066.in
# Control Pendant
# One of the two control pendants has two extra momentary buttons (in
# addition to the latching red estop button).
# The green button doesn't seem to be wired up...
net pendant-green-button <= hm2_5i23.0.gpio.065.in_not
net pendant-blue-button <= hm2_5i23.0.gpio.067.in_not
#Spindle Key Switch
net spindle-key-switch <= hm2_5i23.0.gpio.038.in_not
#net spindle-key-switch => classicladder.0.in-05
#Zero Plate
#net probe-in <= hm2_5i23.0.gpio.068.in_not
#
# Prox limit/home sensors
#
net prox-x <= hm2_5i23.0.gpio.026.in_not
net prox-x => joint.0.home-sw-in joint.0.neg-lim-sw-in joint.0.pos-lim-sw-in
net prox-y1 <= hm2_5i23.0.gpio.024.in_not
net prox-y1 => joint.1.home-sw-in joint.1.neg-lim-sw-in joint.1.pos-lim-sw-in
net prox-z <= hm2_5i23.0.gpio.028.in_not
net prox-z => joint.2.home-sw-in joint.2.pos-lim-sw-in joint.2.neg-lim-sw-in
net prox-y2 <= hm2_5i23.0.gpio.030.in_not
net prox-y2 => joint.3.home-sw-in joint.3.neg-lim-sw-in joint.3.pos-lim-sw-in
#Stepper Driver Digital I/O #run all of these into estop chain
net alarm-x <= hm2_5i23.0.gpio.052.in
net alarm-y1 <= hm2_5i23.0.gpio.048.in
net alarm-z <= hm2_5i23.0.gpio.056.in
net alarm-y2 <= hm2_5i23.0.gpio.060.in
#net alarm-x1 => classicladder.0.in-05
#net alarm-y => classicladder.0.in-06
#net alarm-z => classicladder.0.in-07
#net alarm-x2 => classicladder.0.in-08
# ######################################################
# Axis-of-motion Specific Configs (not the GUI)
# ######################################################
# axis enable chain
#net axis-enable-chain-x joint.0.amp-enable-out => hm2_5i23.0.stepgen.01.enable
net axis-enable-chain-y1 joint.1.amp-enable-out => hm2_5i23.0.stepgen.00.enable
net axis-enable-chain-z joint.2.amp-enable-out => hm2_5i23.0.stepgen.02.enable
net axis-enable-chain-y2 joint.3.amp-enable-out => hm2_5i23.0.stepgen.03.enable
# encoder feedback signals
setp hm2_5i23.0.encoder.01.scale [JOINT_0]INPUT_SCALE
net x-encoder-pos <= hm2_5i23.0.encoder.01.position
net x-encoder-pos => joint.0.motor-pos-fb
net x-encoder-count <= hm2_5i23.0.encoder.01.count
setp hm2_5i23.0.encoder.00.scale [JOINT_1]INPUT_SCALE
net y1-encoder-pos <= hm2_5i23.0.encoder.00.position
net y1-encoder-pos => joint.1.motor-pos-fb
net y1-encoder-count <= hm2_5i23.0.encoder.00.count
setp hm2_5i23.0.encoder.02.scale [JOINT_2]INPUT_SCALE
net z-encoder-pos <= hm2_5i23.0.encoder.02.position
net z-encoder-pos => joint.2.motor-pos-fb
net z-encoder-count <= hm2_5i23.0.encoder.02.count
setp hm2_5i23.0.encoder.03.scale [JOINT_3]INPUT_SCALE
net y2-encoder-pos <= hm2_5i23.0.encoder.03.position
net y2-encoder-pos => joint.3.motor-pos-fb
net y2-encoder-count <= hm2_5i23.0.encoder.03.count
# position command
net x.pos-cmd joint.0.motor-pos-cmd => hm2_5i23.0.stepgen.01.position-cmd
net y1.pos-cmd joint.1.motor-pos-cmd => hm2_5i23.0.stepgen.00.position-cmd
net z.pos-cmd joint.2.motor-pos-cmd => hm2_5i23.0.stepgen.02.position-cmd
net y2.pos-cmd joint.3.motor-pos-cmd => hm2_5i23.0.stepgen.03.position-cmd
#Axis Jogging Settings
setp joint.0.jog-vel-mode 1
setp joint.1.jog-vel-mode 1
setp joint.2.jog-vel-mode 1
setp joint.3.jog-vel-mode 1
# Stepgen parameters
setp hm2_5i23.0.stepgen.01.dirsetup [JOINT_0]DIRSETUP
setp hm2_5i23.0.stepgen.01.dirhold [JOINT_0]DIRHOLD
setp hm2_5i23.0.stepgen.01.steplen [JOINT_0]STEPLEN
setp hm2_5i23.0.stepgen.01.stepspace [JOINT_0]STEPSPACE
setp hm2_5i23.0.stepgen.01.position-scale [JOINT_0]OUTPUT_SCALE
setp hm2_5i23.0.stepgen.00.dirsetup [JOINT_1]DIRSETUP
setp hm2_5i23.0.stepgen.00.dirhold [JOINT_1]DIRHOLD
setp hm2_5i23.0.stepgen.00.steplen [JOINT_1]STEPLEN
setp hm2_5i23.0.stepgen.00.stepspace [JOINT_1]STEPSPACE
setp hm2_5i23.0.stepgen.00.position-scale [JOINT_1]OUTPUT_SCALE
setp hm2_5i23.0.stepgen.02.dirsetup [JOINT_2]DIRSETUP
setp hm2_5i23.0.stepgen.02.dirhold [JOINT_2]DIRHOLD
setp hm2_5i23.0.stepgen.02.steplen [JOINT_2]STEPLEN
setp hm2_5i23.0.stepgen.02.stepspace [JOINT_2]STEPSPACE
setp hm2_5i23.0.stepgen.02.position-scale [JOINT_2]OUTPUT_SCALE
setp hm2_5i23.0.stepgen.03.dirsetup [JOINT_3]DIRSETUP
setp hm2_5i23.0.stepgen.03.dirhold [JOINT_3]DIRHOLD
setp hm2_5i23.0.stepgen.03.steplen [JOINT_3]STEPLEN
setp hm2_5i23.0.stepgen.03.stepspace [JOINT_3]STEPSPACE
setp hm2_5i23.0.stepgen.03.position-scale [JOINT_3]OUTPUT_SCALE
# step_type=0 means Step & Direction
setp hm2_5i23.0.stepgen.00.step_type 0
setp hm2_5i23.0.stepgen.01.step_type 0
setp hm2_5i23.0.stepgen.02.step_type 0
setp hm2_5i23.0.stepgen.03.step_type 0
# let the trajectory planner choose accel and vel
setp hm2_5i23.0.stepgen.00.maxaccel 0
setp hm2_5i23.0.stepgen.01.maxaccel 0
setp hm2_5i23.0.stepgen.02.maxaccel 0
setp hm2_5i23.0.stepgen.03.maxaccel 0
setp hm2_5i23.0.stepgen.00.maxvel 0
setp hm2_5i23.0.stepgen.01.maxvel 0
setp hm2_5i23.0.stepgen.02.maxvel 0
setp hm2_5i23.0.stepgen.03.maxvel 0
# ######################################################
# E-Stop related
# ######################################################
# this is the momentary "enable request" signal *from* linuxcnc
# it means: "the user just now decided they want the machine to come out of estop"
# it's a positive-edge-detector of the iocontrol.0.user-enable-out pin (used below)
net estop-user-request-enable <= iocontrol.0.user-request-enable
net estop-user-request-enable => classicladder.0.in-00
# Control Pendant E-Stop
# there are two pendants, and each has a latching estop button
# if either estop button is pressed, this pin is True
# if both estop buttons are released (not pressed), this pin is False
net estop-pendant-button <= hm2_5i23.0.gpio.037.in_not
net estop-pendant-button => classicladder.0.in-01
# the blue button on the pendant acts as another "enable request" signal from the user
# this is handy so they don't have to walk over to the computer and hit F1
net pendant-blue-button => classicladder.0.in-02
# this signal from linuxcnc is True if the user wants the machine to be enabled,
# and False if the user wants the machine to be in estop
net estop-user-enable <= iocontrol.0.user-enable-out
net estop-user-enable => classicladder.0.in-03
# this is the machine's estop feedback signal *to* linuxcnc
net estop-all-ok <= classicladder.0.out-00
net estop-all-ok => iocontrol.0.emc-enable-in
#
# spindle stuff
#
# Huanyang GT-series GT-7R5G-2
loadusr -W hy_gt_vfd --device /dev/ttyUSB0 --bits 8 --parity none --stopbits 1 --rate 38400 --target 1 --max-freq=300 --min-freq=1 --motor-max-speed=18000
net spindle-on <= spindle.0.on
net spindle-on => hy_gt_vfd.spindle-on
net spindle-forward <= spindle.0.forward
#net spindle-forward => hy_gt_vfd.spindle-forward
net spindle-reverse <= spindle.0.reverse
#net spindle-reverse => hy_gt_vfd.spindle-reverse
net spindle-speed-cmd <= spindle.0.speed-out
net spindle-speed-cmd => hy_gt_vfd.speed-cmd
net spindle-at-speed <= hy_gt_vfd.at-speed
net spindle-at-speed => spindle.0.at-speed
net spindle-speed-fb <= hy_gt_vfd.speed-fb
loadusr -Wn ontime-tracker.spindle ./ontime-tracker spindle
net spindle-on => ontime-tracker.spindle.on