[Home]Simple Remote Pendant

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Showing revision 42

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

upload:LogitechF310.jpg

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 .ini or .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.

upload:joystick_simple_remote_pendant.zip

The easiest way to succeed is to unzip these files into your configuration directory. Now look at the [HAL] section of your .ini file.

[HAL]
HALUI = halui
HALFILE = test.hal
HALFILE = custom.hal
POSTGUI_HALFILE = postgui_call_list.hal

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

 source joypad_jog_speed.hal
 source joypad_xyz_postgui.hal

or for an xz lathe:

 source joypad_jog_speed.hal
 source joypad_xyz_postgui.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

Step 1 Add the hal_input

 # for remote joypad
 loadusr -W hal_input -KRAL Dual

 HALUI = halui
 <b>TWOPASS = on<\b>

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. 

upload:joystick_jog_speed.jpg

 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.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

upload:joystick_analog.JPG

2.8 and later:

 net joy-x-jog <= input.0.abs-x-position  => halui.axis.x.analog halui.joint.0.analog 
 net joy-y-jog <= input.0.abs-y-position  => halui.axis.y.analog halui.joint.1.analog 
 net joy-z-jog <= input.0.abs-rz-position => halui.axis.z.analog halui.joint.2.analog 

Older than 2.8:

 net joy-x-jog <= input.0.abs-x-position  => halui.jog.0.analog 
 net joy-y-jog <= input.0.abs-y-position  => halui.jog.1.analog 
 net joy-z-jog <= input.0.abs-rz-position => halui.jog.2.analog 

 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

upload:LogitechF310.jpg

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 | View current revision
Edited February 22, 2021 9:36 pm by JTrantow (diff)
Search:
Published under a Creative Commons License