### This code goes in your main .hal file ############# Spindle Encoder ############# # add scale and lowpass, these will be used in custom_postgui.hal loadrt scale count=1 loadrt lowpass count=1 # add the encoder to HAL and attach it to threads. loadrt encoder num_chan=1 addf encoder.update-counters base-thread addf encoder.capture-position servo-thread # set the HAL encoder to 60 pulses per revolution. setp encoder.0.position-scale 60 # set the HAL encoder to non-quadrature simple counting using A only. setp encoder.0.counter-mode true #setp encoder.0.counter-mode 1 - alternative line # connect the HAL encoder outputs to LinuxCNC. net spindle-position encoder.0.position => motion.spindle-revs net spindle-velocity encoder.0.velocity => motion.spindle-speed-in net spindle-index-enable encoder.0.index-enable <=> motion.spindle-index-enable # connect the HAL encoder inputs to the real encoder. net spindle-phase-a encoder.0.phase-A <= parport.0.pin-13-in net spindle-phase-b encoder.0.phase-B net spindle-index encoder.0.phase-Z <= parport.0.pin-12-in ############# End Spindle Encoder #############