Setting up EMC2 for hobbing. As show in this video: http://www.youtube.com/user/blyndpew#p/a/f/0/ZhICrb0Tbn4 The hardware aspects are fairly clearly shown in the video, the only other things needed are a Pyvcp panel with a spinbox in it for tooth count (which should be wired to the invert.0.in pin in the posgui.hal file, and these some extra lines in the main HAL file: . presumes spindle encoder is encoder 00 and scale of -200 with A Axis amplifier enable is par port pin 9 and stepgen 3 is A axis loadrt invert count=1 # no divide in hal, so use invert and scale loadrt scale count=1 # scale is used to divide the spindle command by the gear ratio loadrt mux2 count=1 # the mux is used to store the offset as a sample-and-hold loadrt ddt count=1 # used for change detection in the gear ratio to reset the axes loadrt abs count=1 loadrt comp count=1 # convert non-zero to toggle a bit on change addf invert.0 servo-thread #mult and invert are used to divide by the gear ratio addf scale.0 servo-thread addf mux2.0 servo-thread addf ddt.0 servo-thread addf abs.0 servo-thread addf comp.0 servo-thread # A-Axis setp stepgen.03.step_type 0 setp stepgen.03.position-scale [AXIS_3]SCALE setp stepgen.03.steplen [AXIS_3]STEPLEN setp stepgen.03.stepspace [AXIS_3]STEPSPACE setp stepgen.03.dirhold [AXIS_3]DIRHOLD setp stepgen.03.dirsetup [AXIS_3]DIRSETUP setp stepgen.03.maxaccel [AXIS_3]STEPGEN_MAXACCEL setp encoder.00.scale -200 # Electronic gearing of stepgen position to encoder position net invratio invert.0.out => scale.0.gain ddt.0.in # the ratio is linked in the postgui.hal to invert.0.in net spindlepos encoder.00.position => scale.0.in net gearpos scale.0.out => stepgen.03.position-cmd net aenable axis.3.amp-enable-out => stepgen.03.enable => parport.0.pin-09-out # amplifier enable pin for axis 3 ( A axis) , set for parport pin 9 # Reset Logic. Zeroes the encoder and stores the current stepgen position as an offset. # This is to prevent the gear rotating on tooth-count changes (often quite interminably) net scale-change ddt.0.out => abs.0.in net abs-scale-change abs.0.out => comp.0.in1 setp comp.0.in0 0.01 # this is looking for changes in 1/teeth as the raw value is not available until postgui.hal has run net reset-spindles comp.0.out => encoder.00.reset mux2.0.sel # this bit toggles high on a ratio change net sample-hold mux2.0.out => mux2.0.in0 scale.0.offset # the mux is wired to itself as a floating point sample-and-hold net gear-spindle-position stepgen.03.position-fb => mux2.0.in1 # wire the stepgen position to the sample and hold, and thence to the scale --------------------------------------------------------------------------------