Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Spindle handler
- loadrt abs names=spindle-abs
- loadrt pid names=velocity-pid position-pid
- loadrt mux2 names=mode-switch-mux
- loadrt or2 names=orient-enable-or
- loadrt orient names=orient
- loadrt not names=orient-not
- #NOTE that this HAL file uses "names=" for all functions. The means that, for example
- #the orient comp pins are orient.position rather than orient.0.position.
- #Just in acse you were wondering.
- addf orient servo-thread
- addf orient-enable-or servo-thread
- addf orient-not servo-thread
- addf mode-switch-mux servo-thread
- addf velocity-pid servo-thread
- addf position-pid servo-thread
- addf spindle-abs servo-thread
- #Adjust this value to align the spindle encoder index to the toolchanger orientation
- setp orient.angle 45
- #A block of things to configure for a specific hardware setup
- net spindle-cmd-final hm2_5i25.0.7i77.0.0.analogout.04
- net spindle-fwd hm2_5i25.0.7i77.0.0.digout00
- net spindle-rev hm2_5i25.0.7i77.0.0.digout01
- net spindle-pos-fb hm2_5i25.0.encoder.04.position
- net spindle-speed-rps-fb hm2_5i25.0.encoder.04.velocity
- #Normal spindly stuffs
- net spindle-speed-rps-fb motion.spindle-speed-in
- net spindle-pos-fb motion.spindle-revs
- # Two ways to make orient happen
- net orient-from-M19 motion.spindle-orient align-enable-or.in1
- # net the orient-for-tool signal to something from your toolchanger, possibly even tool-change-req
- net orient-for-tool align-enable-or.in0
- net orient-enable orient-enable-or.out orient.enable
- net orient-enable mode-switch-mux.sel position-pid.enable orient-not.in
- #A PID shouln't be left running when it isn't active, they take time to settle
- net vel-enable velocity-pid.enable orient-not.out
- #spindle speed commands can come from either the velocity pid or the orient pid
- net velocity-mode-cmd velocity-pid.out mode-switch-mux.in0
- net position-mode-cmd position-pid.out mode-switch-mux.in1
- #For simplicity the velocity PID is set up as inactive, just passing a scaled
- #value. I have assumed 10V = 5000rpm But this example works in RPS
- setp velocity-pid.FF0 0.12
- setp velocity-pid.Pgain 0
- setp velocity-pid.Igain 0
- setp velocity-pid.Dgain 0
- net spindle-speed-cmd motion.spindle-speed-out-rps velocity-pid.command
- net spindle-speed-rps-fb velocity-pid.feedback
- #The postion PID needs more work. I can't even guess the numbers needed
- setp velocity-pid.FF0 0
- setp velocity-pid.Pgain 0.01
- setp velocity-pid.Igain 0.001
- setp velocity-pid.Dgain 0
- net spindle-pos-cmd orient.position position-pid.command
- net spindle-pos-fb position-pid.feedback
- #Output stage
- net raw-spindle mode-switch-mux.out spindle-abs.in
- net spindle-cmd-final spindle-abs.out
- net spindle-fwd spindle-abs.is-positive
- net spindle-rev spindle-abs.is-negative
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement