forked from pocketncmichelle/PocketNC_Config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PocketNC.hal
600 lines (475 loc) · 18.8 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
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# #######################################
#
# 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/machinekit/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 base_period_nsec=[EMCMOT]BASE_PERIOD servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES
# load low-level drivers
loadrt hal_bb_gpio output_pins=211,212,224,226 input_pins=107,108,109,110,114,117,118,119,122,126,127,128,133,135,141,142,143,144,213,216,217,218,222,129,130,241
loadrt [PRUCONF](DRIVER) [PRUCONF](CONFIG)
loadrt pid num_chan=5
loadrt limit1 count=2
# Spindle math
loadrt scale names=spindleScale
# Some 'glue' logic
#loadrt toggle names=pwrToggle,eStpToggle
#loadrt not names=pwrNot,eStpNot
loadrt toggle count=3
loadrt not count=5
loadrt and2 count=3
loadrt debounce cfg=1
loadrt xor2 count=2
loadrt oneshot count=5
#Encoders
loadrt encoder num_chan=5
# 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/machinekit/machinekit-dev/configs/ARM/BeagleBone/BeBoPr-Bridge/ReadTemp.py -n Therm --num_chan 2 -t 1 1 -a 4 5
# ################################################
# THREADS
# ################################################
addf encoder.update-counters base-thread
addf encoder.capture-position servo-thread
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 pid.2.do-pid-calcs servo-thread
addf pid.3.do-pid-calcs servo-thread
addf pid.4.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 spindleScale servo-thread
#addf pwrToggle servo-thread
#addf pwrNot servo-thread
#addf eStpToggle servo-thread
#addf eStpNot servo-thread
addf toggle.0 servo-thread
addf toggle.1 servo-thread
addf toggle.2 servo-thread
addf not.0 servo-thread
addf not.1 servo-thread
addf not.2 servo-thread
addf not.3 servo-thread
addf not.4 servo-thread
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf debounce.0 servo-thread
addf xor2.0 servo-thread
addf xor2.1 servo-thread
addf oneshot.0 servo-thread
addf oneshot.1 servo-thread
addf oneshot.2 servo-thread
addf oneshot.3 servo-thread
addf oneshot.4 servo-thread
# ######################################################
# Axis-of-motion Specific Configs (not the GUI)
# ######################################################
setp halui.home-all TRUE
# ################
# 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 pid.0.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
setp encoder.0.position-scale [AXIS_0]ENCODER_SCALE
net encoderXa bb_gpio.p8.in-27 => encoder.0.phase-A
net encoderXb bb_gpio.p8.in-28 => encoder.0.phase-B
# 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
# set PID loop gains from inifile
setp pid.0.Pgain [AXIS_0]P
setp pid.0.Igain [AXIS_0]I
setp pid.0.Dgain [AXIS_0]D
setp pid.0.bias [AXIS_0]BIAS
setp pid.0.FF0 [AXIS_0]FF0
setp pid.0.FF1 [AXIS_0]FF1
setp pid.0.FF2 [AXIS_0]FF2
setp pid.0.deadband [AXIS_0]DEADBAND
setp pid.0.maxoutput [AXIS_0]MAX_VELOCITY
setp pid.0.maxerror [AXIS_0]MAX_ERROR
# ################
# 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 pid.1.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
setp encoder.1.position-scale [AXIS_1]ENCODER_SCALE
net encoderYa bb_gpio.p8.in-29 => encoder.1.phase-A
net encoderYb bb_gpio.p8.in-30 => encoder.1.phase-B
# 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
# set PID loop gains from inifile
setp pid.1.Pgain [AXIS_1]P
setp pid.1.Igain [AXIS_1]I
setp pid.1.Dgain [AXIS_1]D
setp pid.1.bias [AXIS_1]BIAS
setp pid.1.FF0 [AXIS_1]FF0
setp pid.1.FF1 [AXIS_1]FF1
setp pid.1.FF2 [AXIS_1]FF2
setp pid.1.deadband [AXIS_1]DEADBAND
setp pid.1.maxoutput [AXIS_1]MAX_VELOCITY
setp pid.1.maxerror [AXIS_1]MAX_ERROR
# ################
# Z [2] Axis
# ################
# axis enable chain
newsig emcmot.02.enable bit
sets emcmot.02.enable FALSE
#setp encoder.2.index-enable TRUE
net emcmot.02.enable <= axis.2.amp-enable-out
#net emcmot.02.enable => [PRUCONF](DRIVER).stepgen.02.enable pid.2.enable oneshot.2.in
net emcmot.02.enable => [PRUCONF](DRIVER).stepgen.02.enable
# line 449 # net pid2status halui.machine.is-on => oneshot.2.in
net pid2reset <= oneshot.2.out-not
net pid2reset => pid.2.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 emcmot.02.pos-cmd <= axis.2.motor-pos-cmd
net emcmot.02.pos-cmd => pid.2.command
net pid2output pid.2.output => [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
net encoder2output <= encoder.2.position
net encoder2output => pid.2.feedback
setp encoder.2.position-scale [AXIS_2]ENCODER_SCALE
net encoderZa bb_gpio.p8.in-43 => encoder.2.phase-A
net encoderZb bb_gpio.p8.in-44 => encoder.2.phase-B
# 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
# set PID loop gains from inifile
setp pid.2.Pgain [AXIS_2]P
setp pid.2.Igain [AXIS_2]I
setp pid.2.Dgain [AXIS_2]D
setp pid.2.bias [AXIS_2]BIAS
setp pid.2.FF0 [AXIS_2]FF0
setp pid.2.FF1 [AXIS_2]FF1
setp pid.2.FF2 [AXIS_2]FF2
setp pid.2.deadband [AXIS_2]DEADBAND
setp pid.2.maxoutput [AXIS_2]MAX_PID_OUTPUT
setp pid.2.maxerror [AXIS_2]MAX_PID_ERROR
# ################
# A [3] Axis
# ################
# 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
setp encoder.3.position-scale [AXIS_3]ENCODER_SCALE
net encoderAa bb_gpio.p8.in-33 => encoder.3.phase-A
net encoderAb bb_gpio.p8.in-35 => encoder.3.phase-B
# 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
# P9.27 GPIO3.19
setp [PRUCONF](DRIVER).stepgen.03.steppin 0x93
# P9.28 GPIO3.17
setp [PRUCONF](DRIVER).stepgen.03.dirpin 0x91
# set PID loop gains from inifile
setp pid.3.Pgain [AXIS_2]P
setp pid.3.Igain [AXIS_2]I
setp pid.3.Dgain [AXIS_2]D
setp pid.3.bias [AXIS_2]BIAS
setp pid.3.FF0 [AXIS_2]FF0
setp pid.3.FF1 [AXIS_2]FF1
setp pid.3.FF2 [AXIS_2]FF2
setp pid.3.deadband [AXIS_2]DEADBAND
setp pid.3.maxoutput [AXIS_2]MAX_VELOCITY
setp pid.3.maxerror [AXIS_3]MAX_ERROR
# ################
# 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
setp encoder.4.position-scale [AXIS_4]ENCODER_SCALE
net encoderBa bb_gpio.p8.in-41 => encoder.4.phase-A
net encoderBb bb_gpio.p8.in-42 => encoder.4.phase-B
# 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
# P9.29 GPIO3.15
setp [PRUCONF](DRIVER).stepgen.04.steppin 0x8f
# P9.30 GPIO3.16
setp [PRUCONF](DRIVER).stepgen.04.dirpin 0x90
# set PID loop gains from inifile
setp pid.4.Pgain [AXIS_2]P
setp pid.4.Igain [AXIS_2]I
setp pid.4.Dgain [AXIS_2]D
setp pid.4.bias [AXIS_2]BIAS
setp pid.4.FF0 [AXIS_2]FF0
setp pid.4.FF1 [AXIS_2]FF1
setp pid.4.FF2 [AXIS_2]FF2
setp pid.4.deadband [AXIS_2]DEADBAND
setp pid.4.maxoutput [AXIS_2]MAX_VELOCITY
setp pid.4.maxerror [AXIS_4]MAX_ERROR
# ##################################################
# Standard I/O - EStop, Enables, Limit Switches, Etc
# ##################################################
# 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 #Spindle on.
#setp bb_gpio.p9.out-24.invert 1
### Home and Limit switches ###
# X axis
#net XmaxAndHome <= bb_gpio.p8.in-09
#net XmaxAndHome => axis.0.pos-lim-sw-in axis.0.home-sw-in
#setp bb_gpio.p8.in-09.invert 0
#net Xmin <= bb_gpio.p8.in-08
#net Xmin => axis.0.neg-lim-sw-in
#setp bb_gpio.p8.in-08.invert 1
# Y axis
#net YmaxAndHome <= bb_gpio.p8.in-14
#net YmaxAndHome => axis.1.pos-lim-sw-in axis.1.home-sw-in
#setp bb_gpio.p8.in-14.invert 0
#net Ymin <= bb_gpio.p8.in-10
#net Ymin => axis.1.neg-lim-sw-in
#setp bb_gpio.p8.in-10.invert 1
# Z axis
net ZmaxAndHome <= bb_gpio.p8.in-18
net ZmaxAndHome => axis.2.pos-lim-sw-in axis.2.home-sw-in
setp bb_gpio.p8.in-18.invert 1
#net Zmin <= bb_gpio.p8.in-17
#net Zmin => axis.2.neg-lim-sw-in
#setp bb_gpio.p8.in-17.invert 1
# A axis
#net AmaxAndHome <= bb_gpio.p9.in-16
#net AmaxAndHome => axis.3.pos-lim-sw-in axis.3.home-sw-in
#setp bb_gpio.p9.in-16.invert 0
#net Amin <= bb_gpio.p9.in-13
#net Amin => axis.3.neg-lim-sw-in
#setp bb_gpio.p9.in-13.invert 1
# B axis
#net BhomeAndIndex <= bb_gpio.p8.in-19
#net BhomeAndIndex => axis.4.home-sw-in
#setp bb_gpio.p8.in-19.invert 0
### Control Panel Buttons ###
# eStop
net estop-loop iocontrol.0.user-enable-out => iocontrol.0.emc-enable-in
net eStopToggle toggle.0.in <= bb_gpio.p8.in-07
setp toggle.0.debounce 2
setp bb_gpio.p8.in-07.invert 1
net eStopOn toggle.0.out => halui.estop.activate => not.0.in
net eStopOff not.0.out => halui.estop.reset
#net eStopDriversEnable halui.estop.is-activated => bb_gpio.p9.out-26
# Machine power
#net powerToggle toggle.1.in <= bb_gpio.p8.in-26
#setp toggle.1.debounce 2
#setp bb_gpio.p8.in-26.invert 0
net powerOn toggle.1.out => halui.machine.on => not.1.in => encoder.2.reset
net powerOff not.1.out => halui.machine.off
#net driversEnable halui.machine.is-on => not.2.in
#net driversEnableInvert not.2.out => bb_gpio.p9.out-26
net driversEnable halui.machine.is-on => bb_gpio.p9.out-12 oneshot.2.in
# Program start/resume
#net startResumeButton bb_gpio.p9.in-22 => and2.0.in0 => and2.1.in0
#net chkModeAuto halui.mode.is-auto => and2.0.in1 => and2.2.in0
#net chkModeManual halui.mode.is-manual => and2.1.in1
#net progResume and2.0.out => halui.program.resume
#net progStart and2.1.out => halui.mode.auto => halui.program.run
#setp bb_gpio.p9.in-22.invert 1
# Program step
#net powerToggle toggle.1.in <= bb_gpio.p8.in-26
#setp toggle.1.debounce 2
#setp bb_gpio.p8.in-26.invert 0
#net powerOn toggle.1.out => halui.machine.on => not.1.in
#net powerOff not.1.out => halui.machine.off
# Program pause
#net pauseButtonPin bb_gpio.p9.in-17 => halui.program.pause
#net waitForPaused halui.program.is-idle => and2.2.in1
#net switchToManual and2.2.out => halui.mode.manual
#setp bb_gpio.p9.in-17.invert 1
# Program stop
#net programStop halui.program.stop <= bb_gpio.p9.in-18
#setp bb_gpio.p9.in-18.invert 0
#setp toggle.1.debounce 2
#net powerOn toggle.1.out => halui.machine.on => not.1.in
#net powerOff not.1.out => halui.machine.off
# Program block delete
#net powerToggle toggle.1.in <= bb_gpio.p8.in-26
#setp toggle.1.debounce 2
#setp bb_gpio.p8.in-26.invert 0
#net powerOn toggle.1.out => halui.machine.on => not.1.in
#net powerOff not.1.out => halui.machine.off
# Program optional stop
#net powerToggle toggle.1.in <= bb_gpio.p8.in-26
#setp toggle.1.debounce 2
#setp bb_gpio.p8.in-26.invert 0
#net powerOn toggle.1.out => halui.machine.on => not.1.in
#net powerOff not.1.out => halui.machine.off
### 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 displaySpindleReverseButton <= motion.spindle-reverse
# spindleSpeed is on p8.13
setp spindleScale.gain 0.0075
setp spindleScale.offset 0.035
net spindleSpeedDummy motion.spindle-speed-out
net spindleSpeed motion.spindle-speed-out-rps => spindleScale.in
net spindlePwm spindleScale.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