-
Notifications
You must be signed in to change notification settings - Fork 3
/
hacklab-engraver3.hal
233 lines (190 loc) · 7.8 KB
/
hacklab-engraver3.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
# Generated by stepconf at Sun Mar 8 21:32:59 2009
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt threads name1=mask-thread period1=100000
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD traj_period_nsec=[EMCMOT]SERVO_PERIOD key=[EMCMOT]SHMEM_KEY num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg=0x378
setp parport.0.reset-time 100000
loadrt stepgen step_type=0,0,0,0
loadrt charge_pump
# Boring components that emc makes me load explicitly because it is a cunt
loadrt comp names=comp-mask-lte,comp-discrete-z
loadrt not names=not-mask-ffw,not-mask-not-empty
loadrt xor2 names=xor2-mask-test
loadrt and2 names=and2-mask-forward,and2-laser-mask,and2-laser-final
loadrt or2 names=or2-mask-command-done,or2-mask-not-ffw,or2-mask-read,or2-laser-gcode,or2-laser-fine
# Fast thread for generating signals
addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread
addf charge-pump base-thread
# Slow thread for logic (more logic components are added further down)
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
###################################################################################
# Raster Mask - stream in laser on/off commands behind AXIS's back
# Input stream format: reset beam xop xarg
# reset: 0=mask command 1=reset (begin mask sequence with "1 0 0 0", every other command starts with 0)
# beam: 0=off 1=on
# xop: X axis comparison operation 0=less-or-equal 1=greater
# xarg: X axis comparison operand
loadrt streamer depth=256 cfg="bbbf"
net mask-reset <= streamer.0.pin.0
net mask-beam <= streamer.0.pin.1
net mask-xop <= streamer.0.pin.2
net mask-xarg <= streamer.0.pin.3
net mask-empty <= streamer.0.empty
net mask-read => streamer.0.enable
# hardware reported X axis position
net motion-xpos-fb <= axis.0.joint-pos-fb
# mask-lte <= motion-xpos-fb < mask-xarg
addf comp-mask-lte mask-thread
net motion-xpos-fb => comp-mask-lte.in0
net mask-xarg => comp-mask-lte.in1
net mask-lte <= comp-mask-lte.out
# mask-test <= mask-xop ^ mask-lte
addf xor2-mask-test mask-thread
net mask-xop => xor2-mask-test.in0
net mask-lte => xor2-mask-test.in1
net mask-test <= xor2-mask-test.out
# if job is running, read only if test is true or reset
# if job is not running, read until reset
# mask-read <= (laser-coarse && (mask-test || mask-reset)) || !(laser-coarse || mask-reset)
addf or2-mask-command-done mask-thread
net mask-test => or2-mask-command-done.in0
net mask-reset => or2-mask-command-done.in1
net mask-command-done <= or2-mask-command-done.out
addf and2-mask-forward mask-thread
net laser-coarse => and2-mask-forward.in0
net mask-command-done => and2-mask-forward.in1
net mask-forward <= and2-mask-forward.out
addf or2-mask-not-ffw mask-thread
net laser-coarse => or2-mask-not-ffw.in0
net mask-reset => or2-mask-not-ffw.in1
net mask-not-ffw <= or2-mask-not-ffw.out
addf not-mask-ffw mask-thread
net mask-not-ffw => not-mask-ffw.in
net mask-ffw <= not-mask-ffw.out
addf or2-mask-read mask-thread
net mask-forward => or2-mask-read.in0
net mask-ffw => or2-mask-read.in1
net mask-read <= or2-mask-read.out
# laser-mask <= mask-not-empty && mask-beam
addf not-mask-not-empty mask-thread
net mask-empty => not-mask-not-empty.in
net mask-not-empty <= not-mask-not-empty.out
addf and2-laser-mask mask-thread
net mask-beam => and2-laser-mask.in0
net mask-not-empty => and2-laser-mask.in1
net laser-mask <= and2-laser-mask.out
addf streamer.0 mask-thread
# Raster Mask - end
#######################################################################
# coarse laser control, wired to spindle on/off (M3/M5), not realtime
net laser-coarse <= motion.spindle-on
# fine laser control, wired to digital output 0 (M62 P0/M63 P0), realtime
net laser-gate <= motion.digital-out-00
# legacy laser control, wired to Z < 0, can be used instead of M62/M63
addf comp-discrete-z servo-thread
net motion-zpos-fb <= axis.2.joint-pos-fb
net motion-zpos-fb => comp-discrete-z.in0
setp comp-discrete-z.in1 0
net discrete-z <= comp-discrete-z.out
# laser-final <= laser-coarse & (laser-gate | discrete-z | laser-mask)
addf or2-laser-gcode mask-thread
net laser-gate => or2-laser-gcode.in0
net discrete-z => or2-laser-gcode.in1
net laser-gcode <= or2-laser-gcode.out
addf or2-laser-fine mask-thread
net laser-gcode => or2-laser-fine.in0
net laser-mask => or2-laser-fine.in1
net laser-fine <= or2-laser-fine.out
addf and2-laser-final mask-thread
net laser-fine => and2-laser-final.in0
net laser-coarse => and2-laser-final.in1
net laser-final <= and2-laser-final.out
# laser-final => hardware
net laser-final => parport.0.pin-01-out
# make Z and W axes always homed
#setp axis.2.homed 1 # Z
#setp axis.8.homed 1 # W
net xdir => parport.0.pin-02-out
net xstep => parport.0.pin-03-out
setp parport.0.pin-03-out-reset 1
net ydir => parport.0.pin-04-out
net ystep => parport.0.pin-05-out
setp parport.0.pin-05-out-reset 1
net wdir => parport.0.pin-06-out
net wstep => parport.0.pin-07-out
setp parport.0.pin-07-out-reset 1
# invert ydir
#setp parport.0.pin-04-out-invert 1
net xenable => parport.0.pin-14-out
net home-x <= parport.0.pin-10-in
net home-y <= parport.0.pin-12-in
net estop-ext <= parport.0.pin-15-in
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 15200
setp stepgen.0.stepspace 15200
setp stepgen.0.dirhold 15200
setp stepgen.0.dirsetup 15200
setp stepgen.0.maxaccel [AXIS_0]STEPGEN_MAXACCEL
net xpos-cmd axis.0.motor-pos-cmd => stepgen.0.position-cmd
net xpos-fb stepgen.0.position-fb => axis.0.motor-pos-fb
net xstep <= stepgen.0.step
net xdir <= stepgen.0.dir
net xenable axis.0.amp-enable-out => stepgen.0.enable
net home-x => axis.0.home-sw-in
setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 15200
setp stepgen.1.stepspace 15200
setp stepgen.1.dirhold 15200
setp stepgen.1.dirsetup 15200
setp stepgen.1.maxaccel [AXIS_1]STEPGEN_MAXACCEL
net ypos-cmd axis.1.motor-pos-cmd => stepgen.1.position-cmd
net ypos-fb stepgen.1.position-fb => axis.1.motor-pos-fb
net ystep <= stepgen.1.step
net ydir <= stepgen.1.dir
net yenable axis.1.amp-enable-out => stepgen.1.enable
net home-y => axis.1.home-sw-in
setp stepgen.2.position-scale [AXIS_2]SCALE
setp stepgen.2.steplen 1
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 15200
setp stepgen.2.dirsetup 15200
setp stepgen.2.maxaccel [AXIS_2]STEPGEN_MAXACCEL
net zpos-cmd axis.2.motor-pos-cmd => stepgen.2.position-cmd
net zpos-fb stepgen.2.position-fb => axis.2.motor-pos-fb
net zstep <= stepgen.2.step
net zdir <= stepgen.2.dir
net zenable axis.2.amp-enable-out => stepgen.2.enable
net home-z => axis.2.home-sw-in
setp stepgen.3.position-scale [AXIS_8]SCALE
setp stepgen.3.steplen 1
setp stepgen.3.stepspace 0
setp stepgen.3.dirhold 15200
setp stepgen.3.dirsetup 15200
setp stepgen.3.maxaccel [AXIS_8]STEPGEN_MAXACCEL
net wpos-cmd axis.8.motor-pos-cmd => stepgen.3.position-cmd
net wpos-fb stepgen.3.position-fb => axis.8.motor-pos-fb
net wstep <= stepgen.3.step
net wdir <= stepgen.3.dir
net wenable axis.8.amp-enable-out => stepgen.3.enable
net home-w => axis.8.home-sw-in
net estop-out <= iocontrol.0.user-enable-out
net estop-ext => iocontrol.0.emc-enable-in
loadusr -W hal_manualtoolchange
net tool-change iocontrol.0.tool-change => hal_manualtoolchange.change
net tool-changed 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
# connect the charge pump signal to an output
net charge-pump <= charge-pump.out
setp parport.0.pin-17-out-reset 1
net charge-pump => parport.0.pin-17-out
setp charge-pump.enable 1