-
Notifications
You must be signed in to change notification settings - Fork 23
/
2x_Laser.hal
executable file
·241 lines (200 loc) · 8.27 KB
/
2x_Laser.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
# Generated by stepconf at Sun Aug 28 12:50:09 2011
# If you make changes to this file, they will be
# overwritten when you run stepconf again
loadrt threads name1=laser-thread period1=[EMCMOT]BASE_PERIOD
loadrt trivkins
loadrt [EMCMOT]EMCMOT base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg="0x378 out"
setp parport.0.reset-time 1000
loadrt stepgen step_type=0,0,0
loadrt pwmgen output_type=0
addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
# need capture-position in laser-thread for raster engraving:
addf stepgen.capture-position laser-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
addf parport.0.reset base-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf pwmgen.update servo-thread
net laser-power-cmd <= motion.analog-out-00 => pwmgen.0.value
net laser-pwm <= pwmgen.0.pwm
# or tie pwmgen.0.enable to dout-00??
setp pwmgen.0.enable 1
# pwm-freq 0 means PDM (pulse density modulation)
setp pwmgen.0.pwm-freq 0
setp pwmgen.0.scale 1
setp pwmgen.0.offset 0
setp pwmgen.0.dither-pwm true
net dout-02 <= motion.digital-out-02
net din-02 => motion.digital-in-02
net laser-chiller => parport.0.pin-01-out
net xstep => parport.0.pin-02-out
setp parport.0.pin-02-out-reset 1
net xdir => parport.0.pin-03-out
setp parport.0.pin-03-out-invert 1
net ystep => parport.0.pin-04-out
setp parport.0.pin-04-out-reset 1
net ydir => parport.0.pin-05-out
setp parport.0.pin-05-out-invert 1
net ustep => parport.0.pin-06-out
setp parport.0.pin-06-out-reset 1
net udir => parport.0.pin-07-out
setp parport.0.pin-07-out-invert 1
net dout-02 => parport.0.pin-08-out
net laser-pwm => parport.0.pin-14-out
net xenable => parport.0.pin-16-out
net laser-final => parport.0.pin-17-out
net home-x <= parport.0.pin-10-in-not
net home-y <= parport.0.pin-11-in-not
net din-02 <= parport.0.pin-13-in
# based on Pololu drivers with Allegro drivers (1us ea hi/lo step, 200ns dir setup/hold)
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1000
setp stepgen.0.stepspace 0
setp stepgen.0.dirhold 200
setp stepgen.0.dirsetup 200
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 1000
setp stepgen.1.stepspace 0
setp stepgen.1.dirhold 200
setp stepgen.1.dirsetup 200
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_6]SCALE
setp stepgen.2.steplen 1000
setp stepgen.2.stepspace 0
setp stepgen.2.dirhold 200
setp stepgen.2.dirsetup 200
setp stepgen.2.maxaccel [AXIS_6]STEPGEN_MAXACCEL
net upos-cmd axis.6.motor-pos-cmd => stepgen.2.position-cmd
net upos-fb stepgen.2.position-fb => axis.6.motor-pos-fb
net ustep <= stepgen.2.step
net udir <= stepgen.2.dir
net uenable axis.6.amp-enable-out => stepgen.2.enable
net zpos-cmd-fb <= axis.2.motor-pos-cmd => axis.2.motor-pos-fb
net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in
net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
net tool-prepare-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
########################
# M3/M5, not realtime/coordinated but master on/off:
net laser-master <= motion.spindle-on
# M62/M63 coordinated or M64/M65 immediate firing:
net laser-dout <= motion.digital-out-00
########################
loadrt laserfreq
addf laserfreq.0.make-pulses laser-thread
addf laserfreq.0.update servo-thread
setp laserfreq.0.duration [LASER]PULSED_CUT_DURATION
setp laserfreq.0.min-off-duration [LASER]PULSED_CUT_CONTINUOUS
net current-vel motion.current-vel => laserfreq.0.velocity
net laser-freq motion.spindle-speed-out => laserfreq.0.pulse-per-unit
#net laser-dout => laserfreq.0.enable
setp laserfreq.0.enable 1
net laser-pulsed <= laserfreq.0.pulse
########################
# XXX configurable axis 0
# Compute motion-offset by observing how it affects the cmd so we can
# apply it manually to the fb. That allows us to use axis.0.position-fb
# directly (at base-thread rate) rather than waiting for servo-thread
# do do the same math and give us axis.N.joint-pos-fb
loadrt sum2 names=motion-offset-sub,motion-offset-apply
addf motion-offset-sub servo-thread
setp motion-offset-sub.gain1 -1
net xpos-jcmd axis.0.joint-pos-cmd => motion-offset-sub.in0
net xpos-cmd axis.0.motor-pos-cmd => motion-offset-sub.in1
net motion-offset <= motion-offset-sub.out
addf motion-offset-apply laser-thread
net xpos-fb => motion-offset-apply.in0
net motion-offset => motion-offset-apply.in1
net raster-pos-fb <= motion-offset-apply.out
loadrt comp names=raster-pos-gt-comp,laser-magic-z-comp
loadrt lut5 names=raster-read-lut,raster-fire-lut,laser-final-lut
loadrt streamer depth=256 cfg=bbf
# The order of addf determines the order of execution.
# Order these so that the inputs cascade correctly to the outputs:
addf raster-pos-gt-comp laser-thread
addf raster-read-lut laser-thread
addf streamer.0 laser-thread
addf raster-fire-lut laser-thread
addf laser-final-lut laser-thread
net raster-fire <= streamer.0.pin.0
net raster-rev <= streamer.0.pin.1
net raster-pos <= streamer.0.pin.2
net raster-empty <= streamer.0.empty
net raster-read => streamer.0.enable
# has the raster reached the target?
# raster-pos-gt := raster-pos-fb > raster-pos
net raster-pos => raster-pos-gt-comp.in0
net raster-pos-fb => raster-pos-gt-comp.in1
net raster-pos-gt <= raster-pos-gt-comp.out
# equation for reading the stream:
# 1) XXX you can't avoid reading when empty or the state never changes
# 2) flush (read all) when not running (M5 / laser-master off)
# 3) when the laser position passes the target position in the right direction
# raster-read := (~laser-master | (raster-pos-gt ^ raster-rev))
#setp raster-read-lut.function 0x15511551 (with raster-empty)
setp raster-read-lut.function 0x3ff33ff3
net raster-empty => raster-read-lut.in-0
net laser-master => raster-read-lut.in-1
net raster-pos-gt => raster-read-lut.in-2
net raster-rev => raster-read-lut.in-3
net raster-read <= raster-read-lut.out
# equation for firing the laser:
# 1) never fire when empty (underflow or job finished)
# 2) fire when raster-fire enabled
# laser-raster := ~raster-empty & raster-fire
setp raster-fire-lut.function 0x44444444
net raster-empty => raster-fire-lut.in-0
net raster-fire => raster-fire-lut.in-1
net laser-raster <= raster-fire-lut.out
########################
addf laser-magic-z-comp servo-thread
net zpos-fb <= axis.2.joint-pos-fb => laser-magic-z-comp.in0
setp laser-magic-z-comp.in1 0.0
net laser-magic-z <= laser-magic-z-comp.out
########################
# Final laser equation: When laser-master is enabled (M3) fire for
# raster or at pulse rate when cutting:
#
# laser-final <= laser-master &
# (laser-raster |
# ((laser-magic-z | laser-dout) & laser-pulsed))
setp laser-final-lut.function 0xfeaa0000
net laser-raster => laser-final-lut.in-0
net laser-dout => laser-final-lut.in-1
net laser-magic-z => laser-final-lut.in-2
net laser-pulsed => laser-final-lut.in-3
net laser-master => laser-final-lut.in-4
net laser-final <= laser-final-lut.out
########################
# chiller/assist-air control
loadrt oneshot names=laser-chiller-oneshot
loadrt or2 names=laser-chiller-or
addf laser-chiller-oneshot servo-thread
addf laser-chiller-or servo-thread
net laser-master => laser-chiller-oneshot.in
net laser-chiller-extra <= laser-chiller-oneshot.out
setp laser-chiller-oneshot.retriggerable 1
setp laser-chiller-oneshot.width [LASER]EXTRA_CHILLER_TIME
setp laser-chiller-oneshot.rising 0
setp laser-chiller-oneshot.falling 1
net laser-master => laser-chiller-or.in0
net laser-chiller-extra => laser-chiller-or.in1
net laser-chiller <= laser-chiller-or.out