forked from jedediah/hacklab-engraver
-
Notifications
You must be signed in to change notification settings - Fork 1
/
hacklab-engraver3.hal
246 lines (196 loc) · 8.09 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
234
235
236
237
238
239
240
241
242
243
244
245
246
# 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-laser-zaxis
loadrt not names=not-mask-ffw,not-mask-not-empty,not-jogger,not-amused,not-machinetoggle
loadrt xor2 names=xor2-mask-test
loadrt and2 names=and2-mask-forward,and2-laser-gmask,and2-laser-final,and2-jogger,and2-machineoff,and2-machineon
loadrt or2 names=or2-mask-command-done,or2-mask-not-ffw,or2-mask-read,or2-laser-gcode,or2-laser-fine
loadrt encoder num_chan=1
# 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-spindle && (mask-test || mask-reset)) || !(laser-spindle || 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-spindle => 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-spindle => 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-gmask <= 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-gmask mask-thread
net mask-beam => and2-laser-gmask.in0
net mask-not-empty => and2-laser-gmask.in1
net laser-gmask <= and2-laser-gmask.out
addf streamer.0 mask-thread
#######################################################################
# Laser on/off logic
# coarse laser control, wired to spindle on/off (M3/M5), not realtime
net laser-spindle <= motion.spindle-on
# fine laser control, wired to digital output 0 (M62 P0/M63 P0), realtime
net laser-digital <= motion.digital-out-00
# Z axis laser control. Laser on iff motion controller's
# commanded Z position is < 0
addf comp-laser-zaxis servo-thread
net motion-zpos-joint axis.2.joint-pos-cmd => comp-laser-zaxis.in0
setp comp-laser-zaxis.in1 0
net laser-zaxis <= comp-laser-zaxis.out
# Loopback the Z motion controller so it always thinks
# that it's exactly where it wants to be
net motion-zpos-motor axis.2.motor-pos-cmd => axis.2.motor-pos-fb
# Generate fake jog to "retract" the Z axis automatically
# when spindle is off and Z < 0
addf not-jogger servo-thread
net jogger-pulse not-jogger.out => not-jogger.in
addf encoder.update-counters servo-thread
addf encoder.capture-position servo-thread
setp encoder.0.counter-mode 1
net jogger-pulse => encoder.0.phase-A
net jogger-counts encoder.0.counts => axis.2.jog-counts
addf not-amused servo-thread
setp axis.2.jog-scale 0.001
net laser-spindle => not-amused.in
addf and2-jogger servo-thread
net this-sucks not-amused.out => and2-jogger.in0
net laser-zaxis => and2-jogger.in1
net blow-me and2-jogger.out => axis.2.jog-enable
# laser-final <= laser-spindle & (laser-digital | laser-zaxis | laser-gmask)
addf or2-laser-gcode mask-thread
net laser-digital => or2-laser-gcode.in0
net laser-zaxis => 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-gmask => 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-spindle => and2-laser-final.in1
net laser-final <= and2-laser-final.out
# laser-final => PPT 1
net laser-final => parport.0.pin-01-out
##################################################
# Motion
# Wire stepmotor signals to PPT pins
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
# Send X amp enable to PPT 14. This signal actually controls
# _all_ motors on the machine.
net xenable => parport.0.pin-14-out
# Get limit switch signals from PPT 10,12
net home-x parport.0.pin-10-in => axis.0.home-sw-in
net home-y parport.0.pin-12-in => axis.1.home-sw-in
net home-w parport.0.pin-13-in => axis.8.home-sw-in
# Get E-stop signal from PPT 15
net estop-ext parport.0.pin-15-in => iocontrol.0.emc-enable-in
# X stepgen
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
# Y stepgen
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
# W stepgen
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
# Send charge pump signal to PPT 17
net charge-pump charge-pump.out => parport.0.pin-17-out
setp parport.0.pin-17-out-reset 1
setp charge-pump.enable 1
##################################################
# Other Logics
loadusr linuxcncrsh