-
Notifications
You must be signed in to change notification settings - Fork 3
/
PocketNC.hal~
397 lines (287 loc) · 12.1 KB
/
PocketNC.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
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
# #######################################
#
# HAL file for BeagleBone + BeBoPr cape with 4 steppers
#
# Derived from example hm2-stepper config
#
# ########################################
# Launch the setup script to make sure hardware setup looks good
loadusr -w /home/linuxcnc/linuxcnc/configs/ARM/BeagleBone/PocketNC/setup.bridge.sh
# ###################################
# Core EMC/HAL Loads
# ###################################
# kinematics
loadrt trivkins
# motion controller, get name and thread periods from ini file
loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
# load low-level drivers
#loadrt hal_bb_gpio output_pins=107,126,217,218,224,226 input_pins=108,110,114,117,118
loadrt hal_bb_gpio output_pins=107,126,211,212,218,224,226 input_pins=108,109,110,114,117,118,122
loadrt [PRUCONF](DRIVER) [PRUCONF](CONFIG)
loadrt pid num_chan=2
loadrt limit1 count=2
# Spindle math
loadrt abs names=abs
# Python user-mode HAL module to read ADC value and generate a thermostat output for PWM
# t = Thermistor table (only epcos_B57560G1104 or 1 supported for now)
# a = analog input channel
loadusr -Wn Therm /home/linuxcnc/linuxcnc/configs/ARM/BeagleBone/BeBoPr-Bridge/ReadTemp.py -n Therm --num_chan 2 -t 1 1 -a 4 5
# ################################################
# THREADS
# ################################################
addf [PRUCONF](DRIVER).capture-position servo-thread
addf bb_gpio.read servo-thread
addf motion-command-handler servo-thread
addf motion-controller servo-thread
addf pid.0.do-pid-calcs servo-thread
addf pid.1.do-pid-calcs servo-thread
addf limit1.0 servo-thread
addf limit1.1 servo-thread
addf [PRUCONF](DRIVER).update servo-thread
addf bb_gpio.write servo-thread
addf abs servo-thread
# ######################################################
# Axis-of-motion Specific Configs (not the GUI)
# ######################################################
# ################
# X [0] Axis
# ################
# axis enable chain
newsig emcmot.00.enable bit
sets emcmot.00.enable FALSE
net emcmot.00.enable <= axis.0.amp-enable-out
net emcmot.00.enable => [PRUCONF](DRIVER).stepgen.00.enable
# position command and feedback
net emcmot.00.pos-cmd <= axis.0.motor-pos-cmd
net emcmot.00.pos-cmd => [PRUCONF](DRIVER).stepgen.00.position-cmd
net motor.00.pos-fb <= [PRUCONF](DRIVER).stepgen.00.position-fb
net motor.00.pos-fb => axis.0.motor-pos-fb
# timing parameters
setp [PRUCONF](DRIVER).stepgen.00.dirsetup [AXIS_0]DIRSETUP
setp [PRUCONF](DRIVER).stepgen.00.dirhold [AXIS_0]DIRHOLD
setp [PRUCONF](DRIVER).stepgen.00.steplen [AXIS_0]STEPLEN
setp [PRUCONF](DRIVER).stepgen.00.stepspace [AXIS_0]STEPSPACE
setp [PRUCONF](DRIVER).stepgen.00.position-scale [AXIS_0]SCALE
setp [PRUCONF](DRIVER).stepgen.00.maxvel [AXIS_0]STEPGEN_MAX_VEL
setp [PRUCONF](DRIVER).stepgen.00.maxaccel [AXIS_0]STEPGEN_MAX_ACC
#setp [PRUCONF](DRIVER).stepgen.00.step_type 0
# P8.43 PRU1.out2
setp [PRUCONF](DRIVER).stepgen.00.steppin 0x4C
# P8.44 PRU1.out4
setp [PRUCONF](DRIVER).stepgen.00.dirpin 0x4D
# ################
# Y [1] Axis
# ################
# axis enable chain
newsig emcmot.01.enable bit
sets emcmot.01.enable FALSE
net emcmot.01.enable <= axis.1.amp-enable-out
net emcmot.01.enable => [PRUCONF](DRIVER).stepgen.01.enable
# position command and feedback
net emcmot.01.pos-cmd <= axis.1.motor-pos-cmd
net emcmot.01.pos-cmd => [PRUCONF](DRIVER).stepgen.01.position-cmd
net motor.01.pos-fb <= [PRUCONF](DRIVER).stepgen.01.position-fb
net motor.01.pos-fb => axis.1.motor-pos-fb
# timing parameters
setp [PRUCONF](DRIVER).stepgen.01.dirsetup [AXIS_1]DIRSETUP
setp [PRUCONF](DRIVER).stepgen.01.dirhold [AXIS_1]DIRHOLD
setp [PRUCONF](DRIVER).stepgen.01.steplen [AXIS_1]STEPLEN
setp [PRUCONF](DRIVER).stepgen.01.stepspace [AXIS_1]STEPSPACE
setp [PRUCONF](DRIVER).stepgen.01.position-scale [AXIS_1]SCALE
setp [PRUCONF](DRIVER).stepgen.01.maxvel [AXIS_1]STEPGEN_MAX_VEL
setp [PRUCONF](DRIVER).stepgen.01.maxaccel [AXIS_1]STEPGEN_MAX_ACC
#setp [PRUCONF](DRIVER).stepgen.01.step_type 0
# P8.42 PRU1.out5
setp [PRUCONF](DRIVER).stepgen.01.steppin 0x4E
# P8.39 PRU1.out6
setp [PRUCONF](DRIVER).stepgen.01.dirpin 0x4F
# ################
# Z [2] Axis
# ################
# axis enable chain
newsig emcmot.02.enable bit
sets emcmot.02.enable FALSE
net emcmot.02.enable <= axis.2.amp-enable-out
net emcmot.02.enable => [PRUCONF](DRIVER).stepgen.02.enable
# position command and feedback
net emcmot.02.pos-cmd <= axis.2.motor-pos-cmd
net emcmot.02.pos-cmd => [PRUCONF](DRIVER).stepgen.02.position-cmd
net motor.02.pos-fb <= [PRUCONF](DRIVER).stepgen.02.position-fb
net motor.02.pos-fb => axis.2.motor-pos-fb
# timing parameters
setp [PRUCONF](DRIVER).stepgen.02.dirsetup [AXIS_2]DIRSETUP
setp [PRUCONF](DRIVER).stepgen.02.dirhold [AXIS_2]DIRHOLD
setp [PRUCONF](DRIVER).stepgen.02.steplen [AXIS_2]STEPLEN
setp [PRUCONF](DRIVER).stepgen.02.stepspace [AXIS_2]STEPSPACE
setp [PRUCONF](DRIVER).stepgen.02.position-scale [AXIS_2]SCALE
setp [PRUCONF](DRIVER).stepgen.02.maxvel [AXIS_2]STEPGEN_MAX_VEL
setp [PRUCONF](DRIVER).stepgen.02.maxaccel [AXIS_2]STEPGEN_MAX_ACC
#setp [PRUCONF](DRIVER).stepgen.02.step_type 0
# P8.27 PRU1.out8
setp [PRUCONF](DRIVER).stepgen.02.steppin 0x50
# P8.29 PRU1.out9
setp [PRUCONF](DRIVER).stepgen.02.dirpin 0x51
# ################
# A [3] Axis (Extruder)
# ################
# axis enable chain
newsig emcmot.03.enable bit
sets emcmot.03.enable FALSE
net emcmot.03.enable <= axis.3.amp-enable-out
net emcmot.03.enable => [PRUCONF](DRIVER).stepgen.03.enable
# position command and feedback
net emcmot.03.pos-cmd <= axis.3.motor-pos-cmd
net emcmot.03.pos-cmd => [PRUCONF](DRIVER).stepgen.03.position-cmd
net motor.03.pos-fb <= [PRUCONF](DRIVER).stepgen.03.position-fb
net motor.03.pos-fb => axis.3.motor-pos-fb
# timing parameters
setp [PRUCONF](DRIVER).stepgen.03.dirsetup [AXIS_3]DIRSETUP
setp [PRUCONF](DRIVER).stepgen.03.dirhold [AXIS_3]DIRHOLD
setp [PRUCONF](DRIVER).stepgen.03.steplen [AXIS_3]STEPLEN
setp [PRUCONF](DRIVER).stepgen.03.stepspace [AXIS_3]STEPSPACE
setp [PRUCONF](DRIVER).stepgen.03.position-scale [AXIS_3]SCALE
setp [PRUCONF](DRIVER).stepgen.03.maxvel [AXIS_3]STEPGEN_MAX_VEL
setp [PRUCONF](DRIVER).stepgen.03.maxaccel [AXIS_3]STEPGEN_MAX_ACC
#setp [PRUCONF](DRIVER).stepgen.03.step_type 0
# P8.30 GPIO2.25
setp [PRUCONF](DRIVER).stepgen.03.steppin 0x22
# P8.21 GPIO1.30
setp [PRUCONF](DRIVER).stepgen.03.dirpin 0x23
# ################
# B [4] Axis
# ################
# axis enable chain
newsig emcmot.04.enable bit
sets emcmot.04.enable FALSE
net emcmot.04.enable <= axis.4.amp-enable-out
net emcmot.04.enable => [PRUCONF](DRIVER).stepgen.04.enable
# position command and feedback
net emcmot.04.pos-cmd <= axis.4.motor-pos-cmd
net emcmot.04.pos-cmd => [PRUCONF](DRIVER).stepgen.04.position-cmd
net motor.04.pos-fb <= [PRUCONF](DRIVER).stepgen.04.position-fb
net motor.04.pos-fb => axis.4.motor-pos-fb
# timing parameters
setp [PRUCONF](DRIVER).stepgen.04.dirsetup [AXIS_4]DIRSETUP
setp [PRUCONF](DRIVER).stepgen.04.dirhold [AXIS_4]DIRHOLD
setp [PRUCONF](DRIVER).stepgen.04.steplen [AXIS_4]STEPLEN
setp [PRUCONF](DRIVER).stepgen.04.stepspace [AXIS_4]STEPSPACE
setp [PRUCONF](DRIVER).stepgen.04.position-scale [AXIS_4]SCALE
setp [PRUCONF](DRIVER).stepgen.04.maxvel [AXIS_4]STEPGEN_MAX_VEL
setp [PRUCONF](DRIVER).stepgen.04.maxaccel [AXIS_4]STEPGEN_MAX_ACC
#setp [PRUCONF](DRIVER).stepgen.04.step_type 0
# P8.30 GPIO2.25
setp [PRUCONF](DRIVER).stepgen.04.steppin 0x24
# P8.21 GPIO1.30
setp [PRUCONF](DRIVER).stepgen.04.dirpin 0x25
# ##################################################
# Standard I/O - EStop, Enables, Limit Switches, Etc
# ##################################################
# create a signal for the estop loopback
net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
# create signals for tool loading loopback
net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared
net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed
# Axis enable signals
#net emcmot.00.enable => bb_gpio.p9.out-18
#setp bb_gpio.p9.out-18.invert 1
#net emcmot.01.enable => bb_gpio.p9.out-17
#setp bb_gpio.p9.out-17.invert 1
#net emcmot.02.enable => bb_gpio.p9.out-26
#setp bb_gpio.p9.out-26.invert 1
#net emcmot.04.enable => bb_gpio.p9.out-24
#setp bb_gpio.p9.out-24.invert 1
#Home and Limit switches
net XmaxAndHome <= bb_gpio.p8.in-09
net XmaxAndHome => axis.0.pos-lim-sw-in axis.0.home-sw-in
net Xmin <= bb_gpio.p8.in-08
net Xmin => axis.0.neg-lim-sw-in
net YmaxAndHome <= bb_gpio.p8.in-14
net YmaxAndHome => axis.1.pos-lim-sw-in axis.1.home-sw-in
net Ymin <= bb_gpio.p8.in-10
net Ymin => axis.1.neg-lim-sw-in
net ZmaxAndHome <= bb_gpio.p8.in-18
net ZmaxAndHome => axis.2.pos-lim-sw-in axis.2.home-sw-in
net Zmin <= bb_gpio.p8.in-17
net Zmin => axis.2.neg-lim-sw-in
# Machine power (BeBoPr Enable)
# Enable tied to system Reset_n line (P9.10)
net estop-loop => bb_gpio.p8.out-07
setp bb_gpio.p8.out-07.invert 1
#Spindle
net spindleEnable <= motion.spindle-on
net spindleEnable => bb_gpio.p9.out-24
net spindleDirection <= motion.spindle-forward
net spindleDirection => bb_gpio.p9.out-11
net requiredSpindleLabel <= motion.spindle-reverse
# spindleSpeed is on p8.13
net abs.0.in <= motion.spindle-speed-out-rps
net abs.0.out => hal_pru_generic.pwmgen.00.out.00.value
#net spindleAtSpeed <= bb_gpio.p8.in-22
#net spindleAtSpeed => motion.spindle-at-speed
# ##################################################
# PWM and Temperature Signals
# ##################################################
# Define signals to use elsewhere (ie: M1xx codes)
# If you change any names here, lots of things will break!
newsig e0.temp.set float
newsig e0.temp.meas float
newsig bed.temp.set float
newsig bed.temp.meas float
setp hal_pru_generic.pwmgen.00.pwm_period 10000000
# J2 E0 Heater PRU1.out1
setp hal_pru_generic.pwmgen.00.out.00.pin 0x37
setp hal_pru_generic.pwmgen.00.out.00.enable 1
#setp hal_pru_generic.pwmgen.00.out.00.value 0.0
# J3 E1 Heater PRU1.out0
setp hal_pru_generic.pwmgen.00.out.01.pin 0x36
setp hal_pru_generic.pwmgen.00.out.01.enable 1
setp hal_pru_generic.pwmgen.00.out.01.value 0.0
# J4 Bed Heater GPIO2.16
setp hal_pru_generic.pwmgen.00.out.02.pin 0x52
setp hal_pru_generic.pwmgen.00.out.02.enable 1
setp hal_pru_generic.pwmgen.00.out.02.value 0.0
# PID for Extruder 0 temperature control
net e0.temp.meas <= Therm.temp0
net e0.temp.meas => pid.0.feedback
sets e0.temp.set 0
net e0.temp.set => pid.0.command
net e0.heater <= pid.0.output
net e0.heater => limit1.0.in
net e0.heaterl <= limit1.0.out
#net e0.heaterl => hal_pru_generic.pwmgen.00.out.00.value
# Limit heater PWM to positive values
# PWM mimics hm2 implementation, which generates output for negative values
setp limit1.0.min 0
# PID for Bed temperature control
net bed.temp.meas <= Therm.temp1
net bed.temp.meas => pid.1.feedback
sets bed.temp.set 0
net bed.temp.set => pid.1.command
net bed.heater <= pid.1.output
net bed.heater => limit1.1.in
net bed.heaterl <= limit1.1.out
net bed.heaterl => hal_pru_generic.pwmgen.00.out.02.value
# Limit heater PWM to positive values
# PWM mimics hm2 implementation, which generates output for negative values
setp limit1.1.min 0
# PID Parameters for adjusting temperature control
# Extruder
#setp pid.0.FF0 0
#setp pid.0.FF1 0
#setp pid.0.FF2 0
setp pid.0.Pgain 0.30
setp pid.0.Igain 0.00001
setp pid.0.Dgain 0.9375
setp pid.0.maxerrorI 1.0
setp pid.0.bias 0.5
setp pid.0.enable 1
# Bed
#setp pid.1.FF0 0
#setp pid.1.FF1 0
#setp pid.1.FF2 0
setp pid.1.Pgain 1
setp pid.1.Igain 0.0
setp pid.1.Dgain 0.0
setp pid.1.maxerrorI 1.0
setp pid.1.bias 0.5
setp pid.1.enable 1