-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom.hal
More file actions
516 lines (427 loc) · 25.3 KB
/
custom.hal
File metadata and controls
516 lines (427 loc) · 25.3 KB
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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# Include your custom HAL commands here
# This file will not be overwritten when you run PNCconf again
#
#
# in INI file section [RS274NGC] we need
# USER_M_PATH = /home/aprs/linuxcnc/configs/Optimat/mcodes
# Loadrt goes here so we can find them to increase counts as needed
loadrt xor2 count=1
loadrt and2 count=5
loadrt carousel pockets=6 encoding=binary num_sense=3 dir=2
loadrt conv_float_s32
loadrt toggle count=3
loadrt mux4 count=1
loadrt not count=1
loadrt comp count=2
loadrt conv_u32_float count=1
# alias hardware pin names to descriptive names
# router hardware
# optimat_output is an output from LinuxCNC / MESA to the router
alias pin hm2_5i25.0.7i77.0.0.output-00 optimat_o_optimat_watchdog
alias pin hm2_5i25.0.7i77.0.0.output-01 optimat_o_vacuum_pump # M100 (on) / M101 (off)
alias pin hm2_5i25.0.7i77.0.0.output-02 optimat_o_spindle_chiller # M102 (on) / M103 (off)
alias pin hm2_5i25.0.7i77.0.0.output-03 optimat_o_dust_collector # M104 (on) / M105 (off)
alias pin hm2_5i25.0.7i77.0.0.output-04 optimat_o_vacuum_right
alias pin hm2_5i25.0.7i77.0.0.output-05 optimat_o_vacuum_left
alias pin hm2_5i25.0.7i77.0.0.output-06 optimat_o_stopper_right
alias pin hm2_5i25.0.7i77.0.0.output-07 optimat_o_stopper_left
alias pin hm2_5i25.0.7i77.0.0.output-08 optimat_o_motor_drilling_unit
alias pin hm2_5i25.0.7i77.0.0.output-09 optimat_o_horizontal_y_spindle_1_down # needs units_up to retract
alias pin hm2_5i25.0.7i77.0.0.output-10 optimat_o_horizontal_x_spindle_1_down # needs units_up to retract and outer most (east)
alias pin hm2_5i25.0.7i77.0.0.output-11 optimat_o_horizontal_x_spindle_2_down # needs units_up to retract
alias pin hm2_5i25.0.7i76.0.3.output-00 optimat_o_groove_saw_down # does not need units_up
alias pin hm2_5i25.0.7i76.0.3.output-01 optimat_o_units_up
alias pin hm2_5i25.0.7i76.0.3.output-02 optimat_o_forced_lubrication_on
alias pin hm2_5i25.0.7i76.0.3.output-03 optimat_o_forced_lubrication_air
alias pin hm2_5i25.0.7i76.0.3.output-04 optimat_o_spindle_1 # spindles don't need units up to retract
alias pin hm2_5i25.0.7i76.0.3.output-05 optimat_o_spindle_2
alias pin hm2_5i25.0.7i76.0.3.output-06 optimat_o_spindle_3
alias pin hm2_5i25.0.7i76.0.3.output-07 optimat_o_spindle_4
alias pin hm2_5i25.0.7i76.0.3.output-08 optimat_o_spindle_5
alias pin hm2_5i25.0.7i76.0.3.output-09 optimat_o_spindle_6
alias pin hm2_5i25.0.7i76.0.3.output-10 optimat_o_spindle_7 # leaks!
alias pin hm2_5i25.0.7i76.0.3.output-11 optimat_o_spindle_8
# alias pin hm2_5i25.0.7i76.0.3.output-12 optimat_o_
# alias pin hm2_5i25.0.7i76.0.3.output-13 optimat_o_
# alias pin hm2_5i25.0.7i76.0.3.output-14 optimat_o_
alias pin hm2_5i25.0.7i76.0.3.output-15 optimat_o_laser_engraver_pwm
alias pin hm2_5i25.0.7i66.0.2.output-00 optimat_o_spindle_9
alias pin hm2_5i25.0.7i66.0.2.output-01 optimat_o_spindle_10 # sticky
alias pin hm2_5i25.0.7i66.0.2.output-02 optimat_o_spindle_11 # connected to solenoid, but pneumatic tube is capped?
alias pin hm2_5i25.0.7i66.0.2.output-03 optimat_o_laser_down # laser down solenoid. Added 2026-02-01
alias pin hm2_5i25.0.7i66.0.2.output-04 optimat_o_laser_assist # M110 (on) / M111 (off)
# alias pin hm2_5i25.0.7i66.0.2.output-05 optimat_o_ # available output
# alias pin hm2_5i25.0.7i66.0.2.output-06 optimat_o_ # available output
alias pin hm2_5i25.0.7i66.0.2.output-07 optimat_o_router_1_clamping
alias pin hm2_5i25.0.7i66.0.2.output-08 optimat_o_motor_router_1
# alias pin hm2_5i25.0.7i66.0.2.output-09 optimat_o_ # available output
alias pin hm2_5i25.0.7i66.0.2.output-10 optimat_o_keb_rotation_forward
alias pin hm2_5i25.0.7i66.0.2.output-11 optimat_o_keb_rotation_reverse
alias pin hm2_5i25.0.7i66.0.2.output-12 optimat_o_keb_parameter_set_1
alias pin hm2_5i25.0.7i66.0.2.output-13 optimat_o_keb_parameter_set_2
alias pin hm2_5i25.0.7i66.0.2.output-14 optimat_o_keb_parameter_set_4
alias pin hm2_5i25.0.7i66.0.2.output-15 optimat_o_laser_crosshair
alias pin hm2_5i25.0.7i66.0.2.output-16 optimat_o_router_1_down
alias pin hm2_5i25.0.7i66.0.2.output-17 optimat_o_mist_coolant
alias pin hm2_5i25.0.7i66.0.2.output-18 optimat_o_tool_magazine_turn_right
alias pin hm2_5i25.0.7i66.0.2.output-19 optimat_o_tool_magazine_turn_left
alias pin hm2_5i25.0.7i66.0.2.output-20 optimat_o_tool_magazine_down
alias pin hm2_5i25.0.7i66.0.2.output-21 optimat_o_tool_magazine_up
alias pin hm2_5i25.0.7i66.0.2.output-22 optimat_o_tool_magazine_changing_position
alias pin hm2_5i25.0.7i66.0.2.output-23 optimat_o_tool_magazine_basic_position
# optimat_input is an input to LinuxCNC / MESA from the router
# 7i77 board
alias pin hm2_5i25.0.7i77.0.0.input-01-not optimat_i_motor_cb
alias pin hm2_5i25.0.7i77.0.0.input-02 optimat_i_compressed_air
alias pin hm2_5i25.0.7i77.0.0.input-02-not optimat_i_compressed_air_down
alias pin hm2_5i25.0.7i77.0.0.input-03 optimat_i_vacuum
alias pin hm2_5i25.0.7i77.0.0.input-04 optimat_i_run_signal
alias pin hm2_5i25.0.7i77.0.0.input-05 optimat_i_coolant_flow
alias pin hm2_5i25.0.7i77.0.0.input-06-not optimat_i_coolant_thermal_overload
# input-07 unused safety device center # unused
# input-08 unused safety device right # unused
# input-09 unused safety device left # unused
alias pin hm2_5i25.0.7i77.0.0.input-10 optimat_i_range_right
alias pin hm2_5i25.0.7i77.0.0.input-11 optimat_i_range_left
alias pin hm2_5i25.0.7i77.0.0.input-12 optimat_i_start_right
alias pin hm2_5i25.0.7i77.0.0.input-13 optimat_i_start_left
alias pin hm2_5i25.0.7i77.0.0.input-14 optimat_i_foot_switch_right
alias pin hm2_5i25.0.7i77.0.0.input-15 optimat_i_foot_switch_left
alias pin hm2_5i25.0.7i77.0.0.input-16 optimat_i_horz_y_1_on_top
alias pin hm2_5i25.0.7i77.0.0.input-17 optimat_i_horz_x_1_on_top
alias pin hm2_5i25.0.7i77.0.0.input-18 optimat_i_horz_x_2_on_top
alias pin hm2_5i25.0.7i77.0.0.input-19 optimat_i_groove_saw_on_top
alias pin hm2_5i25.0.7i77.0.0.input-20 optimat_i_router_1_on_bottom
alias pin hm2_5i25.0.7i77.0.0.input-21 optimat_i_router_1_on_top
# alias pin hm2_5i25.0.7i77.0.0.input-22 optimat_i_router_2_on_bottom # unused
# alias pin hm2_5i25.0.7i77.0.0.input-23 optimat_i_router_2_on_top # unused
alias pin hm2_5i25.0.7i77.0.0.input-24 optimat_i_router_standstill
alias pin hm2_5i25.0.7i77.0.0.input-25 optimat_i_router_nominal_speed
# alias pin hm2_5i25.0.7i77.0.0.input-26-not optimat_i_x_axis_home # picked up else
# alias pin hm2_5i25.0.7i77.0.0.input-27-not optimat_i_y_axis_home # picked up else
# alias pin hm2_5i25.0.7i77.0.0.input-28-not optimat_i_z_axis_home # picked up else
# alias pin hm2_5i25.0.7i77.0.0.input-29 optimat_i_ (unused)
# alias pin hm2_5i25.0.7i77.0.0.input-30 optimat_i_ (unused)
alias pin hm2_5i25.0.7i77.0.0.input-31 optimat_i_tool_change_button
# 7i76 board
alias pin hm2_5i25.0.7i76.0.3.input-00 optimat_i_router_1_tool_clamp_closed
alias pin hm2_5i25.0.7i76.0.3.input-01 optimat_i_router_1_tool_clamp_open
alias pin hm2_5i25.0.7i76.0.3.input-02 optimat_i_router_1_without_tool
alias pin hm2_5i25.0.7i76.0.3.input-03 optimat_i_router_1_standstill
alias pin hm2_5i25.0.7i76.0.3.input-04 optimat_i_tool_magazine_on_bottom
alias pin hm2_5i25.0.7i76.0.3.input-05 optimat_i_tool_magazine_on_top
alias pin hm2_5i25.0.7i76.0.3.input-06 optimat_i_tool_magazine_changing_position
alias pin hm2_5i25.0.7i76.0.3.input-07 optimat_i_tool_magazine_basic_position
# alias pin hm2_5i25.0.7i76.0.3.input-08 # unused
alias pin hm2_5i25.0.7i76.0.3.input-09 optimat_i_tool_magazine_counter_pulse
alias pin hm2_5i25.0.7i76.0.3.input-10 optimat_i_tool_magazine_position_bit_1
alias pin hm2_5i25.0.7i76.0.3.input-11 optimat_i_tool_magazine_position_bit_2
alias pin hm2_5i25.0.7i76.0.3.input-12 optimat_i_tool_magazine_position_bit_4
# alias pin hm2_5i25.0.7i76.0.3.input-13 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-14 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-15 # unused
alias pin hm2_5i25.0.7i76.0.3.input-16 optimat_i_toolsetter # TS-27R tool length setter
alias pin hm2_5i25.0.7i76.0.3.input-17 optimat_i_probe # 3D spindle probe
# alias pin hm2_5i25.0.7i76.0.3.input-18 # unused (can be encoder in MODE 2)
# alias pin hm2_5i25.0.7i76.0.3.input-19 # unused (can be encoder in MODE 2)
# alias pin hm2_5i25.0.7i76.0.3.input-20 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-21 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-22 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-23 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-24 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-25 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-26 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-27 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-28 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-29 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-30 # unused
# alias pin hm2_5i25.0.7i76.0.3.input-31 # unused
# hmi_output is an output from LinuxCNC / MESA to the HMI / pendant
alias pin hm2_5i25.0.7i66.0.4.output-00 hmi_o_pendant_led
alias pin hm2_5i25.0.7i66.0.4.output-01 hmi_o_panel_feed_hold_led
alias pin hm2_5i25.0.7i66.0.4.output-02 hmi_o_panel_cycle_start_led
alias pin hm2_5i25.0.7i66.0.4.output-03 hmi_o_stacklight_red
alias pin hm2_5i25.0.7i66.0.4.output-04 hmi_o_stacklight_orange
alias pin hm2_5i25.0.7i66.0.4.output-05 hmi_o_stacklight_green
# alias pin hm2_5i25.0.7i66.0.4.output-06 hmi_o_
# alias pin hm2_5i25.0.7i66.0.4.output-07 hmi_o_
# hmi_input is an input to LinuxCNC / MESA from the HMI / pendant
alias pin hm2_5i25.0.7i66.0.4.input-00 hmi_i_panel_ro_a # was hmi_i_pendant_jog_x1
alias pin hm2_5i25.0.7i66.0.4.input-01 hmi_i_pendant_jog_x10
alias pin hm2_5i25.0.7i66.0.4.input-02 hmi_i_pendant_jog_x100
alias pin hm2_5i25.0.7i66.0.4.input-03 hmi_i_pendant_jog_axis_x
alias pin hm2_5i25.0.7i66.0.4.input-04 hmi_i_pendant_jog_axis_y
alias pin hm2_5i25.0.7i66.0.4.input-05 hmi_i_pendant_jog_axis_z
alias pin hm2_5i25.0.7i66.0.4.input-06 hmi_i_pendant_jog_axis_4
alias pin hm2_5i25.0.7i66.0.4.input-07 hmi_i_panel_feed_hold_button
alias pin hm2_5i25.0.7i66.0.4.input-08 hmi_i_panel_cycle_start_button
alias pin hm2_5i25.0.7i66.0.4.input-09 hmi_i_panel_fo_a
alias pin hm2_5i25.0.7i66.0.4.input-10 hmi_i_panel_fo_b
alias pin hm2_5i25.0.7i66.0.4.input-11 hmi_i_panel_fo_e
alias pin hm2_5i25.0.7i66.0.4.input-12 hmi_i_panel_fo_f
alias pin hm2_5i25.0.7i66.0.4.input-13 hmi_i_panel_ro_b
alias pin hm2_5i25.0.7i66.0.4.input-14 hmi_i_panel_ro_e
alias pin hm2_5i25.0.7i66.0.4.input-15 hmi_i_panel_ro_f
# net connect our stuff
# net coolant-flood => optimat_o_laser_crosshair
# mist coolant (air blast) is on only if it turned on and tool unclamp not active
addf xor2.0 servo-thread
addf and2.0 servo-thread
net coolant-mist-xor2-in0 xor2.0.in0 <= iocontrol.0.coolant-mist
net optimat_s_router_1_clamping optimat_o_router_1_clamping => xor2.0.in1
# net coolant-mist optimat_o_mist_coolant <= xor2.0.out
net coolant-mist-xor2-in0 => and2.0.in0
net coolant-mist-and2-in1 and2.0.in1 <= xor2.0.out
net coolant-mist optimat_o_mist_coolant <= and2.0.out
# net both-on parport.0.pin-14-out <= and2.0.out
# just connect without xor
# net coolant-mist => optimat_o_mist_coolant
# for GladeVCP
net air_up <= optimat_i_compressed_air
net air_down <= optimat_i_compressed_air_down
# net router_1_down <= optimat_i_router_1_on_bottom
# net router_1_down <= optimat_i_motor_cb
net vacuum_up <= optimat_i_vacuum
# for gmoccapy messages
net cb_trip <= optimat_i_motor_cb
# inhibit laser engraver when at unsafe height (relative)
#addf comp.0 servo-thread
# setp comp.0.in1 0.375 # okay to have engraver on below this (relative) z height
# setp comp.0.hyst 0.005 # hysteresis
# net engraver-height-current comp.0.in0 <= halui.axis.z.pos-relative
# engraver tool (T8) must be the active tool and height must be safe
# addf conv-u32-float.0 servo-thread
# net tool_number_u32 <= halui.tool.number => conv-u32-float.0.in
# net tool_number_float <= conv-u32-float.0.out
# addf comp.1 servo-thread
# setp comp.1.in0 8 # engraver tool number
# setp comp.1.hyst 0.0001 # floating point is never equal
# net tool_number_float => comp.1.in1
# addf and2.3 servo-thread
# net engrave-safe-height <= comp.0.out => and2.3.in0
# net engrave-safe-selected <= motion.digital-out-21 => and2.3.in1
# net engrave-signal <= and2.3.out
# make sure comp.1.equal and engrave_signal are both true, if so we turn on optimat_o_laser_engraver_pwm
# addf and2.4 servo-thread
# net engrave-signal => and2.4.in0
# net engrave-tool-match => comp.1.equal => and2.4.in1
# net engrave_pwm <= optimat_o_laser_engraver_pwm <= and2.4.out
# disable safe
# net engrave_pwm <= optimat_o_laser_engraver_pwm
# net tool-release => optimat_o_router_1_clamping
# net tool-release <= optimat_i_tool_change_button
# stacklight on HMI
# red stacklight is tied to gmoccapy.error
net stacklight-orange <= halui.program.is-paused
net stacklight-orange => hmi_o_stacklight_orange
net stacklight-orange => hmi_o_panel_feed_hold_led
net stacklight-green <= halui.program.is-running
net stacklight-green => hmi_o_stacklight_green
net stacklight-green => hmi_o_panel_cycle_start_led
# feed rate override (calculation done elsewhere, apparently)
net fo-incr-a <= hmi_i_panel_fo_a
net fo-incr-b <= hmi_i_panel_fo_b
net fo-incr-c <= hmi_i_panel_fo_e
net fo-incr-d <= hmi_i_panel_fo_f
# rapid override
net ro-incr-a <= hmi_i_panel_ro_a
net ro-incr-b <= hmi_i_panel_ro_b
net ro-incr-c <= hmi_i_panel_ro_e
net ro-incr-d <= hmi_i_panel_ro_f
# program controls
net run-signal <= hmi_i_panel_cycle_start_button
net run-signal => halui.program.run
net pause-signal <= hmi_i_panel_feed_hold_button
net pause-signal => halui.program.pause
# --- JOINT-SELECT ---
# net joint-select-a <= hmi_i_pendant_jog_axis_x
# net joint-select-b <= hmi_i_pendant_jog_axis_y
# net joint-select-c <= hmi_i_pendant_jog_axis_z
# net joint-select-d <= hmi_i_pendant_jog_axis_4
# spindle control
# for now we will just keep the contactor to router_1 on
# TODO need to accomodate drilling motor when tool >= 16 and <= 30
#
# for main spindle we need
# setp optimat_o_motor_router_1 true
# net spindle-enable spindle.0.on => optimat_o_keb_parameter_set_4
#
# what do we need for motor drilling unit
net spindle-cw spindle.0.forward => optimat_o_keb_rotation_forward
net spindle-ccw spindle.0.reverse => optimat_o_keb_rotation_reverse
# this should inhibit feed moves until the spindle has reached speed
# net spindle-at-speed <= optimat_i_router_nominal_speed
# tool changer carousel
net carousel-strobe optimat_i_tool_magazine_counter_pulse => carousel.0.strobe
net carousel-bit-1 optimat_i_tool_magazine_position_bit_1 => carousel.0.sense-0
net carousel-bit-2 optimat_i_tool_magazine_position_bit_2 => carousel.0.sense-1
net carousel-bit-4 optimat_i_tool_magazine_position_bit_4 => carousel.0.sense-2
net carousel-motor-fwd optimat_o_tool_magazine_turn_left => carousel.0.motor-fwd
net carousel-motor-rev optimat_o_tool_magazine_turn_right => carousel.0.motor-rev
addf carousel.0 servo-thread
# get requested tool carousel number from analog m code and convert it to s32 for carousel
addf conv-float-s32.0 servo-thread
net carousel-pos-req motion.analog-out-00 conv-float-s32.0.in
net carousel-pos-s32 conv-float-s32.0.out carousel.0.pocket-number
# send current tool carousel position from s32 from carousel to float for analog m code
# loadrt conv_s32_float n=1
# addf conv-s32-float.0 servo-thread
# net carousel-pos-current carousel.0.current-position conv-s32-float.0.in
# net carousel-pos-current-float conv-s32-float.0.out motion.analog-in-00
# make tool change work
net tool-prep-loop iocontrol.0.tool-prepare iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change iocontrol.0.tool-changed
# IO for M6x codes
net tool-change-router-clamp-closed optimat_i_router_1_tool_clamp_closed => motion.digital-in-00
net tool-change-router-clamp-open optimat_i_router_1_tool_clamp_open => motion.digital-in-01
net tool-change-router-without-tool optimat_i_router_1_without_tool => motion.digital-in-02
net tool-change-router-standstill optimat_i_router_1_standstill => motion.digital-in-03
net tool-change-router-on-bottom optimat_i_router_1_on_bottom => motion.digital-in-04
net tool-change-router-on-top optimat_i_router_1_on_top => motion.digital-in-05
net tool-change-mag-on-bottom optimat_i_tool_magazine_on_bottom => motion.digital-in-06
net tool-change-mag-on-top optimat_i_tool_magazine_on_top => motion.digital-in-07
net tool-change-mag-on-changing optimat_i_tool_magazine_changing_position => motion.digital-in-08
net tool-change-mag-on-basic optimat_i_tool_magazine_basic_position => motion.digital-in-09
net tool-change-carousel-ready carousel.0.ready => motion.digital-in-10
net tool-change-carousel-active carousel.0.active => motion.digital-in-11
net tool-change-mag-down optimat_o_tool_magazine_down => motion.digital-out-00
net tool-change-mag-up optimat_o_tool_magazine_up => motion.digital-out-01
net tool-change-mag-changing optimat_o_tool_magazine_changing_position => motion.digital-out-02
net tool-change-mag-basic optimat_o_tool_magazine_basic_position => motion.digital-out-03
# net tool-change-release optimat_o_router_1_clamping => motion.digital-out-04
net optimat_s_router_1_clamping => motion.digital-out-04
net tool-change-router-down optimat_o_router_1_down => motion.digital-out-05
net tool-change-units-up optimat_o_units_up => motion.digital-out-06
net tool-change-carousel-enable carousel.0.enable => motion.digital-out-07
net tool-change-groove-saw optimat_o_groove_saw_down => motion.digital-out-08
net tool-change-spindle-1-down optimat_o_spindle_1 => motion.digital-out-09
net tool-change-spindle-2-down optimat_o_spindle_2 => motion.digital-out-10
net tool-change-spindle-3-down optimat_o_spindle_3 => motion.digital-out-11
net tool-change-spindle-4-down optimat_o_spindle_4 => motion.digital-out-12
net tool-change-spindle-5-down optimat_o_spindle_5 => motion.digital-out-13
net tool-change-spindle-6-down optimat_o_spindle_6 => motion.digital-out-14
net tool-change-spindle-7-down optimat_o_spindle_7 => motion.digital-out-15
net tool-change-spindle-8-down optimat_o_spindle_8 => motion.digital-out-16
net tool-change-spindle-9-down optimat_o_spindle_9 => motion.digital-out-17
net tool-change-spindle-10-down optimat_o_spindle_10 => motion.digital-out-18
net tool-change-spindle-11-down optimat_o_spindle_11 => motion.digital-out-19
net tool-change-laser-crosshair optimat_o_laser_crosshair => motion.digital-out-20
# net tool-change-laser-engraver optimat_o_laser_engraver_pwm => motion.digital-out-21 # this should go into and and that compares it with halui.axis.z.pos-relative
net tool-change-horiz-y-1 optimat_o_horizontal_y_spindle_1_down => motion.digital-out-22
net tool-change-horiz-x-1 optimat_o_horizontal_x_spindle_1_down => motion.digital-out-23
net tool-change-horiz-x-2 optimat_o_horizontal_x_spindle_2_down => motion.digital-out-24
net tool-change-motor-router optimat_o_motor_router_1 => motion.digital-out-25
net tool-change-motor-drilling optimat_o_motor_drilling_unit => motion.digital-out-26
net tool-change-motor-keb-param-1 optimat_o_keb_parameter_set_1 => motion.digital-out-27
net tool-change-motor-keb-param-2 optimat_o_keb_parameter_set_2 => motion.digital-out-28
net tool-change-motor-keb-param-4 optimat_o_keb_parameter_set_4 => motion.digital-out-29
net lube-forced-on optimat_o_forced_lubrication_on => motion.digital-out-30 # meter spring pushed grease for 10 seconds
net lube-air-on optimat_o_forced_lubrication_air => motion.digital-out-31 # blows what is in the tube
net tool-change-laser-down optimat_o_laser_down => motion.digital-out-32
# toggles for {stoppers, tool carousel down/up}
# left foot pedal
net toggle-stoppers-left-pedal optimat_i_foot_switch_left => toggle.0.in
net toggle-stoppers-left toggle.0.out => optimat_o_stopper_left
addf toggle.0 servo-thread
# right foot pedal
net toggle-stoppers-right-pedal optimat_i_foot_switch_right => toggle.1.in
net toggle-stoppers-right toggle.1.out => optimat_o_stopper_right
addf toggle.1 servo-thread
# -20S1 button on tool changer to drop/raise carosel using the one-shot halui.mdi-commands
net toggle-magazine-button optimat_i_tool_change_button => toggle.2.in
net toggle-magazine-state <= toggle.2.out
# MDI command 0 should be triggered when !TOGGLE AND BUTTON
net toggle-magazine-state => not.0.in
net toggle-magazine-state-not <= not.0.out
net toggle-magazine-state-not => and2.1.in0
net toggle-magazine-button => and2.1.in1
net mdi-magazine-down and2.1.out => halui.mdi-command-00
# MDI command 1 should be trigged when TOGGLE AND BUTTON
net toggle-magazine-state => and2.2.in0
net toggle-magazine-button => and2.2.in1
net mdi-magazine-up and2.2.out => halui.mdi-command-01
addf toggle.2 servo-thread
addf not.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
# jog pendant
addf mux4.0 servo-thread
# For velocity mode, set to 1
# In velocity mode the axis stops when the dial is stopped
# even if that means the commanded motion is not completed,
# For position mode (the default), set to 0
# In position mode the axis will move exactly jog-scale
# units for each count, regardless of how long that might take,
setp axis.x.jog-vel-mode 0
setp axis.y.jog-vel-mode 0
setp axis.z.jog-vel-mode 0
# This sets the scale that will be used based on the input to the mux4
setp mux4.0.in0 0.000025 # encoder outputs 4x counts, so this equals 0.0001
setp mux4.0.in1 0.000250 # encoder outputs 4x counts, so this equals 0.0010
setp mux4.0.in2 0.002500 # encoder outputs 4x counts, so this equals 0.0100
# The inputs to the mux4 component
# x1 input really not needed. If not x10 and not x100 then it must be x1
net scale1 mux4.0.sel0 <= hmi_i_pendant_jog_x10
net scale2 mux4.0.sel1 <= hmi_i_pendant_jog_x100
# The output from the mux4 is sent to each axis jog scale
net mpg-scale <= mux4.0.out
net mpg-scale => axis.x.jog-scale
net mpg-scale => axis.y.jog-scale
net mpg-scale => axis.z.jog-scale
# The Axis select inputs
net mpg-x axis.x.jog-enable <= hmi_i_pendant_jog_axis_x
net mpg-y axis.y.jog-enable <= hmi_i_pendant_jog_axis_y
net mpg-z axis.z.jog-enable <= hmi_i_pendant_jog_axis_z
net mpg-a axis.a.jog-enable <= hmi_i_pendant_jog_axis_4
# using the spindle encoder on the 7i76 card we need to specify 7 encoders when doing hostmot
# loadrt hm2_pci config="num_encoders=7
# because using the spindle encoder, it outputs 4x counts per click on hand wheel. Increments
# are scaled by 4x above.
# The encoder output counts to the axis. Only the selected axis will move.
net encoder-counts <= hm2_5i25.0.encoder.06.count
net encoder-counts => axis.x.jog-counts
net encoder-counts => axis.y.jog-counts
net encoder-counts => axis.z.jog-counts
net encoder-counts => axis.a.jog-counts
# second spindle is laser engraver PWM
# addf pwmgen.update servo-thread
# addf pwmgen.make-pulses servo-thread
# net laser-speed-cmd spindle.1.speed-out => pwmgen.0.value
# net laser-on spindle.1.on => pwmgen.0.enable # this should be P21 enable AND spindle.1.on
# net laser-pwm pwmgen.0.pwm => optimat_o_laser_engraver_pwm
# Set the spindle's top speed in RPM
# setp pwmgen.0.scale 100
# laser engraver
# software PWM
loadrt pwmgen output_type=0
addf pwmgen.update servo-thread
addf pwmgen.make-pulses servo-thread # should be base-thread
setp pwmgen.0.enable TRUE
setp pwmgen.0.scale 65535
# based on https://forum.linuxcnc.org/47-hal-examples/54073-laser-power-scaling-based-on-speed-and-direction
loadrt lincurve personality=2
loadrt aprs_laserreg # for some reason the component gets renamed to aprs-laserreg (ie changes _ to -)
addf lincurve.0 servo-thread
addf aprs-laserreg.0 servo-thread
# Laser power mapping (0-100 -> 0-65535)
setp lincurve.0.x-val-00 0
setp lincurve.0.y-val-00 0
setp lincurve.0.x-val-01 100
setp lincurve.0.y-val-01 65535
net laser-requested-speed motion.requested-vel => aprs-laserreg.0.reqspd
net laser-current-speed motion.current-vel => aprs-laserreg.0.curspd
net laser-velx joint.0.vel-cmd => aprs-laserreg.0.velx
net laser-vely joint.1.vel-cmd => aprs-laserreg.0.vely
net laser-velz joint.2.vel-cmd => aprs-laserreg.0.velz
setp aprs-laserreg.0.share 1.0
net laser-percent spindle.1.speed-out => aprs-laserreg.0.inpower
net laser-regulated-percent aprs-laserreg.0.outpower => lincurve.0.in
net laser-65535 lincurve.0.out => pwmgen.0.value
net laser-pwm pwmgen.0.pwm => optimat_o_laser_engraver_pwm
# second spindle we will always consider to be at speed
net laser-at-speed => spindle.1.at-speed
sets laser-at-speed true
# better set the main spindle at speed now for debugging
sets spindle-at-speed true
# probing
net probe_in <= optimat_i_probe