-
Notifications
You must be signed in to change notification settings - Fork 1
/
sim_spindle_encoder.hal
39 lines (29 loc) · 1.19 KB
/
sim_spindle_encoder.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
# simulated spindle encoder (for spindle-synced moves)
loadrt sim_spindle names=sim_spindle
setp sim_spindle.scale 0.01666667
loadrt limit2 names=limit_speed
loadrt lowpass names=spindle_mass
loadrt near names=near_speed
# this limit doesnt make any sense to me:
setp limit_speed.maxv 5000.0 # rpm/second
# encoder reset control
# hook up motion controller's sync output
net spindle-index-enable motion.spindle-index-enable <=> sim_spindle.index-enable
# report our revolution count to the motion controller
net spindle-pos sim_spindle.position-fb => motion.spindle-revs
# simulate spindle mass
setp spindle_mass.gain .07
# spindle speed control
net spindle-speed-cmd motion.spindle-speed-out => limit_speed.in
net spindle-speed-limited limit_speed.out => sim_spindle.velocity-cmd spindle_mass.in
# for spindle velocity estimate
net spindle-rpm-filtered spindle_mass.out motion.spindle-speed-in near_speed.in2
# at-speed detection
setp near_speed.scale 1.1
setp near_speed.difference 10
net spindle-speed-cmd => near_speed.in1
net spindle-at-speed near_speed.out motion.spindle-at-speed
addf limit_speed servo-thread
addf spindle_mass servo-thread
addf near_speed servo-thread
addf sim_spindle servo-thread