[Home]Simple Remote Pendant

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Simple Remote Pendant using a $10-20 joypad with halui and hal_input

After studing Manfredi's and Paul's joypad examples and after some hints from Alex Joni I was able to add a jog function to a joypad with little coding. The axis jog at a proportional speed to how far you push the stick and it is super easy to set up.

Some of this information was out of date as of version 2.8:

  1. halui.jog-speed has moved to halui.axis.jog-speed and halui.joint.jog-speed.
  2. halui.jog.L.analog has moved to halui.axis.L.analog and halui.joint.N.analog where L is the axis letter and N is the joint number.
  3. The Linux syntax for udev rules may have changed. The new syntax looks like ATTR{idProduct}=="c216", ATTR{idVendor}=="046d", MODE="0660", GROUP="plugdev"

Use [Here] to learn how to identify your hal_input joypad and identify the available pins.

Logitech F310 Specific Absolute Axes and Button Pins

This is the joypad I used:

NOTE: LinuxCNC 2.9 renames btn-joystick to btn_trigger.


The Logitech F310 supports 6 absolute axes and twelve buttons. See http://linuxcnc.org/docs/html/man/man1/hal_input.1.html for the full pin names for these axes and buttons.

Axes Names

Button Names

Shortcut to success

This wiki page shows how to connect joypad jogging for an xyz machine. HAL analog jog is slightly different for an xz lathe. To make things easier, I have attached three files. If you add these two of these files to your postgui list, you don't need to make any changes to your main configuration .hal. The first file is joystick_jog_speed.hal. The second file is determined by whether you want an xyz mill or xz lathe configuration. Keeping all your joypad .hal in separate files helps keep track of changes and allows you to simply remove the joypad from a configuration is it's not available.


The easiest way to succeed is to unzip these files into your configuration directory. Now look at the [HAL] section of your .ini file. Make sure you have the TWOPASS and HALUI lines.

HALUI = halui
HALFILE = my-mill.hal # Use the name of your configuration.
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal

Open up the filename assigned by POSTGUI_HALFILE and add the following two lines for an xyz machine

 source joypad_jog_speed.hal
 source joypad_xyz.hal

or for an xz lathe:

 source joypad_jog_speed.hal
 source joypad_xz.hal

With a Logitech F310 and these changes you should be able to skip to Step 4 and begin enjoying your remote pendant jogging. If you have a different device, you may want to review the [Here] and follow through the steps modifying the files from the zip.

Enjoy JTrantow (Special Thanks to John Gee for double-checking my changes.)

Step 1 Add the hal_input

 # for remote joypad
 loadusr -W hal_input -KRAL Dual

 HALUI = halui

Step 2 Using Joypad buttons to select the jog speed

 This feature makes the joypad safer to use as you must press one of three buttons before the joystick will move the machine. 


 Open joypad_jog_speed.hal. 

You can change the jog speeds from {0.0, 1.0, 10.0, 100.0} to values relevant for your machine. The first value of 0.0 is used when no buttons are pressed. Don't change this. You can change the buttons that select the jog-speed by changing the net lines with input.0.btn-joystick/btn-thumb/btn-thumb2.

 loadrt or2 names=joy_or2_sel0,joy_or2_sel1
 loadrt mux4 names=joy_mux4

 addf joy_or2_sel0 servo-thread
 addf joy_or2_sel1 servo-thread
 addf joy_mux4 servo-thread

 # Set the jog speed for the joypad speed selection. Use numbers that make sense for your machine.
 setp joy_mux4.in0 0.0   # Setting this input to 0 prevents motion unless one of the other buttons is pressed.
 setp joy_mux4.in1 1.0   # Max jog speed when first speed select button is pressed.
 setp joy_mux4.in2 10.0  # Max jog speed when second speed select button is pressed.
 setp joy_mux4.in3 100.0 # Max jog speed when third speed select button is pressed.

 # The following lines do the magic of setting the jog speed selection. You must hold at least one of the buttons while jogging.
 net slow   <= joy_or2_sel0.in0 => input.0.btn-joystick                # Button for selecting first jog speed.
 net medium <= joy_or2_sel1.in0 => input.0.btn-thumb                   # Button for selecting second jog speed.
 net fast   <= joy_or2_sel0.in1 joy_or2_sel1.in1 => input.0.btn-thumb2 # Button for selecting third jog speed.

 net joy-speed-sel0 <= joy_or2_sel0.out  => joy_mux4.sel0
 net joy-speed-sel1 <= joy_or2_sel1.out  => joy_mux4.sel1

2.9 and later

 net slow   <= joy_or2_sel0.in0 => input.0.btn-trigger                # Button for selecting first jog speed.

2.8 and later:

 net jog-speed      <= joy_mux4.out => halui.axis.jog-speed halui.joint.jog-speed

Older than 2.8:

 net joy-speed-final <= mux4.0.out => halui.jog-speed 

Step 3 Set up the analog jogs


This step connects the joypad to both the halui axis and joint pins. This allows jogging in joint mode before the axis are homed.

 # To avoid any startup problems and machine turning off transients, mux/sample-hold the analog signals to avoid sending a jog command.
 loadrt mux2 names=mux2_x,mux2_y,mux2_z 

 addf mux2_x servo-thread
 addf mux2_y servo-thread
 addf mux2_z servo-thread

 # Use a mux as a sample hold so analog jogs don't change when machine is off.
 net machine-is-on <= halui.machine.is-on => mux2_x.sel mux2_y.sel mux2_z.sel  # Control the mux with the machine on/off state.

 net jog-x-pre <= input.0.abs-x-position => mux2_x.in1
 net jog-y-pre <= input.0.abs-y-position => mux2_y.in1
 net jog-z-pre <= input.0.abs-rz-position => mux2_z.in1 # rz feels more natural.

 net jog-x-analog <= mux2_x.out => mux2_x.in0 halui.joint.0.analog halui.axis.x.analog 
 net jog-y-analog <= mux2_y.out => mux2_y.in0 halui.joint.1.analog halui.axis.y.analog 
 net jog-z-analog <= mux2_z.out => mux2_z.in0 halui.joint.2.analog halui.axis.z.analog 

 * To reverse the direction of an axis add the following, in my case both Y and Z were backwards.

 setp input.0.abs-y-scale -127.5
 setp input.0.abs-rz-scale -127.5

Step 4 Using the Joypad to jog your machine.

1 You must have the manual control tab selected for halui jog to work. It will not work when the MDI tab is selected

2 You must press and hold a number button then move the joystick to get movement.

This is the joypad I used


The Logitech F310 supports 6 absolute axes and twelve buttons. See http://linuxcnc.org/docs/html/man/man1/hal_input.1.html for the full pin names for these axes and buttons.

Axes Pin Names

Button Pin Names

Enjoy Big John T

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited February 22, 2022 5:51 pm by JTrantow (diff)
Published under a Creative Commons License