[Home]Simple Remote Pendant

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

Difference (from prior major revision) (no other diffs)

Changed: 75c75
net remote-speed-slow or2.0.in0 input.0.btn-trigger
net remote-speed-slow or2.0.in0 input.0.btn-joystick

Changed: 114c114
Big John T
Big John T

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. I placed all the code in my postgui.hal file except the first line.That one was put in my main .hal file. This way the pins have been created by the time you get to the postgui.hal file and everything works. If your adding functions like or2 etc and you all ready have some in use just adjust the count and reference number to suit your configuration.

1. Step 1 Find out if your joypad is compatible

2. Step 2 Identify your joypad

 less /proc/bus/input/devices

 I: Bus=0003 Vendor=046d Product=c216 Version=0300
 N: Name="Logitech Logitech Dual Action"
 P: Phys=usb-0000:00:03.2-2/input0
 S: Sysfs=/class/input/input3
 H: Handlers=event3 js0
 B: EV=b
 B: KEY=fff 0 0 0 0 0 0 0 0 0
 B: ABS=30027

3. Step 3 Add the hal_input

 # for remote joypad
 loadusr -W hal_input -KRAL Dual

 HALUI = halui

In my case the joypad was named "Logitech Logitech Dual Action". Pick one of the names that is unique and use it.

If for example you have a Logitech mouse you won't want to use "Logitech" as the name for the hal_input.

Also, if you put TWO names in the line after the "-KRAL" you will get two copies of the input and you don't want that.

4. Step 4 Check the pin names of your device

5. Step 5 Set up the Jog Speed

 Add the following line to your postgui.hal file and use a number that makes sense for your machine. 
 The number is units per minute. If you use this line skip the rest of this section. 
 If you use the rest of this section skip this line!

 setp halui.jog-speed 10

 This feature makes the joypad safer to use as you must press a button before
 the joystick will move the machine. This is my preferred way to use it.

 In your postgui.hal file add the following lines

 loadrt or2 count=2
 loadrt mux4 count=1

 addf or2.0 servo-thread
 addf or2.1 servo-thread
 addf mux4.0 servo-thread

 # set the jog speed for the joypad again use numbers that make sense for your machine
 setp mux4.0.in0 0 # this one must be 0 to prevent motion unless a button is pressed
 setp mux4.0.in1 25
 setp mux4.0.in2 100
 setp mux4.0.in3 200

 # the following does the magic of setting the jog speeds
 net remote-speed-slow or2.0.in0 input.0.btn-joystick
 net remote-speed-medium or2.1.in0 input.0.btn-thumb
 net remote-speed-fast or2.0.in1 or2.1.in1 input.0.btn-thumb2

 net joy-speed-1 mux4.0.sel0 <= or2.0.out
 net joy-speed-2 mux4.0.sel1 <= or2.1.out
 net joy-speed-final halui.jog-speed <= mux4.0.out

6. Step 6 Set up the Axis

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

7. Reverse any Axis that go in the wrong direction

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

8. Step 7 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. Once it starts moving you can release the number, but as soon as you stop you have to press the number again before any movement will happen.

This is the joypad I used


If your system won't recognize the joypad you might have to look at hal_input man page and perhaps modify the permissions to access the device. Prepared a one line file as per the description in the man page.

 SUBSYSTEM=="input", mode="0660", group="plugdev" 

Name the file 51-plugdev.rules and save it in /etc/udev/rules.d

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 March 1, 2013 6:55 am by Jthornton (diff)
Published under a Creative Commons License