# Jog Pendant # =========== # Copied from the example in the manual then reworked for my pendant. # The Mesa cards don't need the base-thread so I have to fudge one for the encoder # This ticks at 1mSec to sample the quadrature inputs from the MPG wheel loadrt threads name1=base-thread period1=1000000 loadrt encoder names=mpgencoder addf encoder.capture-position servo-thread # read the quadrature inputs addf encoder.update-counters base-thread # calculate the outputs # If your MPG outputs one quadrature signal per click set x4 to 1 # If your MPG puts out 1 full pulse cycle per click set x4 to 0 setp mpgencoder.x4-mode 0 # For velocity mode, set to 1 # In velocity mode the axis stops when the dial is stopped # even if that means the commanded motion is not completed, # For position mode (the default), set to 0 # In position mode the axis will move exactly jog-scale # units for each count, regardless of how long that might take, setp axis.x.jog-vel-mode 0 setp axis.y.jog-vel-mode 0 setp axis.z.jog-vel-mode 0 # select the scale factor # I did use a frig on a mux16 component but it was a lot of clanging about to # accomplish a trivial operation for a computer. Hence I wrote sel3.comp which # chooses one of three inputs depending on the active enable bit. loadrt sel3 count=0 addf sel3.0 servo-thread # Supply the selections setp sel3.0.in0 0.001 setp sel3.0.in1 0.01 setp sel3.0.in2 0.1 net mpg-x1 hm2_7i95.0.inmux.00.input-20 => sel3.0.en0 net mpg-x10 hm2_7i95.0.inmux.00.input-21 => sel3.0.en1 net mpg-x100 hm2_7i95.0.inmux.00.input-22 => sel3.0.en2 net mpg-scale <= sel3.0.out # Send the selected scale to all the axes net mpg-scale => axis.x.jog-scale net mpg-scale => axis.y.jog-scale net mpg-scale => axis.z.jog-scale # The MPG inputs net mpg-a mpgencoder.phase-A <= hm2_7i95.0.inmux.00.input-00 net mpg-b mpgencoder.phase-B <= hm2_7i95.0.inmux.00.input-01 # Select the axis to jog net mpg-x axis.x.jog-enable <= hm2_7i95.0.inmux.00.input-16 net mpg-y axis.y.jog-enable <= hm2_7i95.0.inmux.00.input-17 net mpg-z axis.z.jog-enable <= hm2_7i95.0.inmux.00.input-18 # Send the encoder output counts to all the axes. Only the selected axis will move. net mpg-encoder-counts <= mpgencoder.counts net mpg-encoder-counts => axis.x.jog-counts net mpg-encoder-counts => axis.y.jog-counts net mpg-encoder-counts => axis.z.jog-counts # the MPG led address (used in spindle.hal) # hm2_7i95.0.ssr.00.out-03 ################################################################################ # Now Nigel's spindle control as 'axis 4' ################################################################################ # this is all based about a custom component to encapsulate what was turning # into pages and pages of HAL down into a few lines of C. # # When you select axis4 and move the dial it sets 'subvert' which latches # both the current rpm and the MPG couter. It then uses changes in the MPG # to increment and decrement its latched value which it exposes on ??? # in the spindle.hal I decide if the PWM is driven by the actual code # requested rpm or this value based on the 'subvert flag. loadrt sstep count=1 addf sstep.0 servo-thread net mpg-rpm spindle.0.speed-out sstep.0.rpm # official spindle speed (float) net mpg-encoder-counts sstep.0.mpg # current mpg counts net mpg-axis4 hm2_7i95.0.inmux.00.input-19 sstep.0.axis4 # MPG button && Axis4 net mpg-x1 sstep.0.x1 # step size switch net mpg-x10 sstep.0.x10 net mpg-x100 sstep.0.x100 setp sstep.0.max-rpm 1500 setp sstep.0.hold-time 10 # hold button time to dropout # sstep.0.out-rpm # mpg requested rpm see spindle.hal # sstep.0.subvert # subvert mode output # turning the dial may start, stop or reverse things so have controls net mpg-fwd sstep.0.fwd halui.spindle.0.forward net mpg-rev sstep.0.rev halui.spindle.0.reverse net mpg-stop sstep.0.stop halui.spindle.0.stop