LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

In some situations, it is nice to have a hardware control knob to override the spindle rotational speed. This is similar to that control feature found on Bridgeport Interact TNC's amongst others.

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;


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.

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited January 21, 2012 12:58 pm by CNCDreamer (diff)
Published under a Creative Commons License