hal
The following shows the connections for my MPG and selector switches in my hal file. My MPG has connections to A and B but not /A and /B.
Because the hostmot2 encoder does not have a counter mode you get 4 pulses per click. I set the scale to 1/4 of the desired value to get the result I wanted. This cold have been done also with a software encoder and just used one of the GPIO inputs.
# load real time components loadrt mux4 names=mpg-scale # MPG Jog Speeds addf mpg-scale servo-thread # MPG encoder feedback setp hm2_[HOSTMOT2](BOARD).0.encoder.03.counter-mode 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.filter 1 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-invert 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask 0 setp hm2_[HOSTMOT2](BOARD).0.encoder.03.index-mask-invert 0 # Send the jog counts to each axis, only the one selected will move net mpg-count hm2_5i20.0.encoder.03.count net mpg-count => axis.0.jog-counts net mpg-count => axis.2.jog-counts # Set up the scale factors for the scale selector switch # 0.0001 per click of the MPG setp mpg-scale.in0 .000025 # 0.001 per click of the MPG setp mpg-scale.in1 .00025 # 0.01 per click of the MPG setp mpg-scale.in2 .0025 # a single input controls the selection of an axis net mpg-x axis.0.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.054.in_not net mpg-z axis.2.jog-enable <= hm2_[HOSTMOT2](BOARD).0.gpio.052.in_not # MPG Scale # set the MPG scale based on the inputs from the selector switch net pos2 mpg-scale.sel0 <= hm2_[HOSTMOT2](BOARD).0.gpio.037.in_not net pos3 mpg-scale.sel1 <= hm2_[HOSTMOT2](BOARD).0.gpio.035.in_not # Set the jog scale for each axis net axis-mpg-jog-scale axis.0.jog-scale <= mpg-scale.out net axis-mpg-jog-scale axis.2.jog-scale <= mpg-scale.out