You should modify the halui.spindle-override.scale value to suite your encoder, 0.001 will give a slower update of the spindle speed than 0.1 for example. Once EMC2 is running, you can use the HAL-Meter to check the values increment and decrement appropriately. If they do, but in the wrong way compared to the direction of the control knob on the encoder, simply swap the phases around, A becomes B and B becomes A. |
You should modify the halui.spindle-override.scale value to suite your encoder, 0.001 will give a slower update of the spindle speed than 0.1 for example. Once LinuxCNC is running, you can use the HAL-Meter to check the values increment and decrement appropriately. If they do, but in the wrong way compared to the direction of the control knob on the encoder, simply swap the phases around, A becomes B and B becomes A. |
The first step is to make / get a hardware encoder, for my machine, I found a 16ppr quadrature encoder, not too expensive or precision. The A and B phase outputs from the cheap encoders have to be tied to +5v via a resistor of a few K ohms, the encoder then effectively shorts the A and B phase output pins to ground, generating pulses.
In my custom_postgui.hal file, I have added;
net tweekwheel-b encoder.2.phase-A <= parport.2.pin-03-in-not net tweekwheel-a encoder.2.phase-B <= parport.2.pin-02-in-not
The inputs are inverted with the -not because they are held at +5v, this isn't actually required though. Attach the relevant input pins to the encoder phase A and B - parport 2 pins 2 and 3 in my case. You'll also need to increment the value in the line "loadrt encoder num_chan=n" so there is one additional encoder loaded.
The next step is to tie the encoder to the appropriate halui control;
setp halui.spindle-override.scale 0.01 net tweekwheel-counts encoder.2.counts halui.spindle-override.counts
You should modify the halui.spindle-override.scale value to suite your encoder, 0.001 will give a slower update of the spindle speed than 0.1 for example. Once LinuxCNC is running, you can use the HAL-Meter to check the values increment and decrement appropriately. If they do, but in the wrong way compared to the direction of the control knob on the encoder, simply swap the phases around, A becomes B and B becomes A.
Once this is done, edit the ini file (my-mill.ini for example) and add in the following under the display section;
[DISPLAY] MIN_SPINDLE_OVERRIDE = 0.5 MAX_SPINDLE_OVERRIDE = 2
The above lines are needed on version 2.2.8 and they will allow the spindle speed to be adjusted from 50% to 200% of the commanded value.