forked from bjj/2x_laser
-
Notifications
You must be signed in to change notification settings - Fork 8
/
2x_Laser.hal
executable file
·200 lines (168 loc) · 6.75 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
# 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=base-thread period1=[EMCMOT]BASE_PERIOD fp1=0 name2=charge-pump-thread period2=100000 fp2=0
loadrt trivkins
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
loadrt probe_parport
loadrt hal_parport cfg="0x378 out"
# setp parport.0.reset-time 1200
loadrt stepgen step_type=0,0,0
loadrt pwmgen output_type=0
loadrt charge_pump
loadrt laserraster linear_units=[TRAJ]LINEAR_UNITS axis_scale=[AXIS_0]SCALE axis_min_limit=[AXIS_0]MIN_LIMIT axis_max_limit=[AXIS_0]MAX_LIMIT
loadrt laserfreq
addf parport.0.read base-thread
addf stepgen.make-pulses base-thread
addf laserraster.0.make-pulses base-thread
addf laserfreq.0.make-pulses base-thread
addf pwmgen.make-pulses base-thread
addf parport.0.write base-thread
# addf parport.0.reset base-thread
addf stepgen.capture-position servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf stepgen.update-freq servo-thread
addf laserraster.0.update servo-thread
addf laserfreq.0.update servo-thread
addf pwmgen.update servo-thread
addf charge-pump charge-pump-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
# scale 0%=0.1 100%=0.6
setp pwmgen.0.max-dc 0.7
setp pwmgen.0.scale 200
setp pwmgen.0.offset 0.1
setp pwmgen.0.dither-pwm true
net coolant-mist <= iocontrol.0.coolant-mist
net estop-out <= iocontrol.0.user-enable-out
net estop-out => iocontrol.0.emc-enable-in
#net estop-out => 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 0
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 wstep => parport.0.pin-06-out
# setp parport.0.pin-06-out-reset 1
net wdir => parport.0.pin-07-out
setp parport.0.pin-07-out-invert 1
net xenable => parport.0.pin-08-out
setp parport.0.pin-08-out-invert 1
net laser-exhaust => parport.0.pin-01-out
net laser-pwm => parport.0.pin-14-out
net coolant-mist => parport.0.pin-16-out
net laser-final => parport.0.pin-17-out
net both-w <= parport.0.pin-12-in-not
net max-home-y <= parport.0.pin-13-in-not
net min-home-x <= parport.0.pin-15-in-not
# charge pump output on pin 9
net charge-pump-out-09 charge-pump.out => parport.0.pin-09-out
# Keling 4030 driver 1.2us step, 5us dir setup
setp stepgen.0.position-scale [AXIS_0]SCALE
setp stepgen.0.steplen 1200
setp stepgen.0.stepspace 1200
setp stepgen.0.dirhold 1000
setp stepgen.0.dirsetup 5000
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 min-home-x => axis.0.home-sw-in
net min-home-x => axis.0.neg-lim-sw-in
setp stepgen.1.position-scale [AXIS_1]SCALE
setp stepgen.1.steplen 1200
setp stepgen.1.stepspace 1200
setp stepgen.1.dirhold 1000
setp stepgen.1.dirsetup 5000
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 max-home-y => axis.1.home-sw-in
net max-home-y => axis.1.pos-lim-sw-in
setp stepgen.2.position-scale [AXIS_8]SCALE
setp stepgen.2.steplen 1200
setp stepgen.2.stepspace 1200
setp stepgen.2.dirhold 1000
setp stepgen.2.dirsetup 5000
setp stepgen.2.maxaccel [AXIS_8]STEPGEN_MAXACCEL
net wpos-cmd axis.8.motor-pos-cmd => stepgen.2.position-cmd
net wpos-fb stepgen.2.position-fb => axis.8.motor-pos-fb
net wstep <= stepgen.2.step
net wdir <= stepgen.2.dir
net wenable axis.8.amp-enable-out => stepgen.2.enable
#net both-w => axis.8.neg-lim-sw-in
#net both-w => axis.8.pos-lim-sw-in
net zpos-cmd-fb <= axis.2.motor-pos-cmd => axis.2.motor-pos-fb
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
########################
setp laserraster.0.enable 1
setp laserraster.0.laser-on-delay [LASER]TRIGGER_DELAY
net raster-data-index <= motion.analog-out-01 => laserraster.0.data-index
net raster-data-1 <= motion.analog-out-02 => laserraster.0.data-1
net xstep => laserraster.0.stepgen-step
net xdir => laserraster.0.stepgen-dir
net laser-raster <= laserraster.0.laser-on
########################
setp laserfreq.0.duration [LASER]PULSED_CUT_DURATION
net current-vel motion.current-vel => laserfreq.0.velocity
net laser-freq-speed motion.spindle-speed-out => laserfreq.0.pulse-per-unit
net laser-freq-trick-axis-rev motion.spindle-reverse
#net laser-dout => laserfreq.0.enable
setp laserfreq.0.enable 1
net laser-pulsed <= laserfreq.0.pulse
########################
loadrt comp names=laser-magic-z-comp
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.0001
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))
loadrt lut5 names=laser-final-lut
addf laser-final-lut base-thread
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
########################
# exhaust/assist-air control
loadrt oneshot names=laser-exhaust-oneshot
loadrt or2 names=laser-exhaust-or
addf laser-exhaust-oneshot servo-thread
addf laser-exhaust-or servo-thread
net laser-master => laser-exhaust-oneshot.in
net laser-exhaust-extra <= laser-exhaust-oneshot.out
setp laser-exhaust-oneshot.retriggerable 1
setp laser-exhaust-oneshot.width [LASER]EXTRA_EXHAUST_TIME
setp laser-exhaust-oneshot.rising 0
setp laser-exhaust-oneshot.falling 1
net laser-master => laser-exhaust-or.in0
net laser-exhaust-extra => laser-exhaust-or.in1
net laser-exhaust <= laser-exhaust-or.out