For the princely sum of $6.50 I was able to get a jogging pendant going.
I bought a cheap imitation PS2 controller from ebay:
I then followed a LinuxCNC wiki guide: Simple Remote Pendant using a $10-20 joypad with halui and hal_input and the adding more controls to pendant page
Note: To get the more complex joypad code working (with incremental jog) I had to comment out "loadrt near" and "addf near.0 servo-thread" in my main .hal file. I believe these are there for the spindle speed sensor, added by stepconf. In custom_postgui.hal I then increased the count of 'near' and renumbered the "near.n" (in the code example from the 2nd LinuxCNC page) for my spindle sensor.
So far I've got it set up so:
The large shoulder buttons are estops.
The left small shoulder button clears estop with the first press, and activates machine power with the second press.
Left joystick jogs X and Z axis. Jog can be constant or incremental. Button #4 switches between. To jog I have to hold down either button 1, 2 or 3 and move the joystick. Each button gives a different speed (25mm/min, 100mm/min, 1200mm/min) in constant mode, or a different distance (0.01mm, 0.1mm, 1mm) in incremental mode.
The select button switches to manual mode (from MDI) as jogging is not allowed in MDI.
See the image below for the pin names of each of the buttons:
See below for my custom_postgui.hal
## 7xCNC custom_postgui.hal file
## customised for generic PS2/dual shock controller from Ebay
## Based on:
## http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant
## http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Adding_More_Controls_To_Simple_Remote_Pendant
## need linuxcnc 2.5 or better
loadrt or2 count=5
loadrt toggle count=1
loadrt near count=7
loadrt and2 count=6
loadrt mux2 count=3
loadrt mux4 count=2
addf or2.0 servo-thread
addf or2.1 servo-thread
addf or2.2 servo-thread
addf or2.3 servo-thread
addf toggle.0 servo-thread
addf mux2.0 servo-thread
addf mux2.1 servo-thread
addf mux2.2 servo-thread
addf mux4.0 servo-thread
addf mux4.1 servo-thread
addf near.0 servo-thread
addf near.1 servo-thread
addf near.2 servo-thread
addf near.3 servo-thread
addf near.4 servo-thread
addf near.5 servo-thread
addf near.6 servo-thread
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread
addf and2.5 servo-thread
## use near for incremental jog moves, must push stick all the way for movement and to avoid unexpected movement by not
## pushing stick straight, sensitivity can be adjusted
setp near.0.in1 1
setp near.1.in1 1
setp near.2.in1 1
setp near.3.in1 -1
setp near.4.in1 -1
setp near.5.in1 -1
# 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 1200
## set the size of incremental moves
setp mux4.1.in0 0
setp mux4.1.in1 .01
setp mux4.1.in2 .1
setp mux4.1.in3 1
## add for toggle to toggle between continuous and incremental jog
net jog-inc toggle.0.in <= input.0.btn-top
# the following does the magic of setting the jog speeds
net remote-speed-slow or2.0.in0 or2.2.in0 input.0.btn-joystick
net remote-speed-medium or2.1.in0 or2.3.in0 input.0.btn-thumb
net remote-speed-fast or2.0.in1 or2.1.in1 or2.2.in1 or2.3.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
net jog-size-1 mux4.1.sel0 <= or2.2.out
net jog-size-2 mux4.1.sel1 <= or2.3.out
net jog-size-final halui.jog.0.increment halui.jog.1.increment halui.jog.2.increment <= mux4.1.out
setp mux2.0.in1 0
setp mux2.1.in1 0
setp mux2.2.in1 0
## hook up the joysticks
net joy-x-sig mux2.0.in0 near.0.in2 near.3.in2 <= input.0.abs-y-position
#net joy-y-sig mux2.1.in0 near.1.in2 near.4.in2 <= input.0.abs-y-position
net joy-z-sig mux2.2.in0 near.2.in2 near.5.in2 <= input.0.abs-x-position
## send signal to analog jog if not in incremental jog mode
net joy-x-jog halui.jog.0.analog <= mux2.0.out
net joy-y-jog halui.jog.1.analog <= mux2.1.out
net joy-z-jog halui.jog.2.analog <= mux2.2.out
## toggle from continuous to incremental jogs
net joginc and2.0.in1 and2.1.in1 and2.2.in1 and2.3.in1 and2.4.in1 and2.5.in1 mux2.0.sel mux2.1.sel mux2.2.sel <= toggle.0.out
## if toggle is set for incremental and joystick is 1 or -1 make an incremental move
## hook up near outputs to and2. inputs
net jogincx and2.0.in0 <= near.0.out
net jogincy and2.1.in0 <= near.1.out
net jogincz and2.2.in0 <= near.2.out
net jogincxn and2.3.in0 <= near.3.out
net jogincyn and2.4.in0 <= near.4.out
net joginczn and2.5.in0 <= near.5.out
## and2 outputs to halui incremental jog
net jogincx_final halui.jog.0.increment-plus <= and2.0.out
net jogincy_final halui.jog.1.increment-plus <= and2.1.out
net jogincz_final halui.jog.2.increment-plus <= and2.2.out
net jogincxn_final halui.jog.0.increment-minus <= and2.3.out
net jogincyn_final halui.jog.1.increment-minus <= and2.4.out
net joginczn_final halui.jog.2.increment-minus <= and2.5.out
# estop
net pgm-estop-0 input.0.btn-base or2.4.in0
net pgm-estop-1 input.0.btn-base2 or2.4.in1
net pgm-estop or2.4.out halui.estop.activate
net pgm-estop-2 input.0.btn-top2 halui.estop.reset halui.machine.on
# **** Setup of spindle speed display using pyvcp -START ****
# **** Use ACTUAL spindle velocity from spindle encoder
# **** spindle-velocity bounces around so we filter it with lowpass
# **** spindle-velocity is signed so we use absolute component to remove sign
# **** ACTUAL velocity is in RPS not RPM so we scale it.
setp scale.0.gain 60
setp lowpass.0.gain 0.010000
net spindle-velocity => lowpass.0.in
net spindle-fb-filtered-rps lowpass.0.out => abs.0.in
net spindle-fb-filtered-abs-rps abs.0.out => scale.0.in
net spindle-fb-filtered-abs-rpm scale.0.out => pyvcp.spindle-speed
# **** set up spindle at speed indicator ****
net spindle-cmd => near.6.in1
net spindle-velocity => near.6.in2
net spindle-at-speed <= near.6.out
setp near.6.scale 1.500000
net spindle-at-speed => pyvcp.spindle-at-speed-led
#-- central buttons activate manual mode and restart the program
net mode-manual input.0.btn-base3 axisui.set-manual-mode
## net pgm-resume input.0.btn-base4 halui.program.resume (NOT WORKING)
For my router I have a generic X-Box controlled from Ebay.
It uses different button names (easily found using Halmeter). The big problem is that some of the axes moved opposite to the desired direction.
The linuxcnc wiki had some guides:
wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant
wiki.linuxcnc.org/cgi-bin/wiki.pl?Adding...imple_Remote_Pendant
I tried the solution included in the article which successfully inverted the movement, but lost the different speeds, and didn't work for incremental either.
So I fiddled and found a way to change it.
For continuous (paragraph of code before and after added for contex):
## hook up the joysticks net joy-x-sig mux2.0.in0 near.0.in2 near.3.in2 <= input.0.abs-x-position net joy-y-sig mux2.1.in0 near.1.in2 near.4.in2 <= input.0.abs-y-position net joy-z-sig mux2.2.in0 near.2.in2 near.5.in2 <= input.0.abs-hat0y-position ## reverse x, y & z using scale as needed ## renumber if you have scale elsewhere in .hal files (e.g. spindle stuff) loadrt scale count=3 addf scale.0 servo-thread addf scale.1 servo-thread addf scale.2 servo-thread ## link scale to mux output for x axis then set the gain to -1 ## x-axis is correct for me so gain = 1, doesn't invert net reverse-x scale.0.in <= mux2.0.out setp scale.0.gain 1 ## link scale to mux output for y axis then set the gain to -1 net reverse-y scale.1.in <= mux2.1.out setp scale.1.gain -1 ## link scale to mux output for z axis then set the gain to -1 net reverse-z scale.2.in <= mux2.2.out setp scale.2.gain -1 ## send signal to analog jog if not in incremental jog mode net joy-x-jog halui.jog.0.analog <= scale.0.out net joy-y-jog halui.jog.1.analog <= scale.1.out net joy-z-jog halui.jog.2.analog <= scale.2.out
To invert the incremental moves is easier:
## To change the direction of incremental move (e.g. if moves opposite to desired) just change the plus and minus portion of halui.jog.N.increment-(plus or minus)
## and2 outputs to halui incremental jog
net jogincx_final halui.jog.0.increment-plus <= and2.0.out
net jogincy_final halui.jog.1.increment-minus <= and2.1.out
net jogincz_final halui.jog.2.increment-minus <= and2.2.out
net jogincxn_final halui.jog.0.increment-minus <= and2.3.out
net jogincyn_final halui.jog.1.increment-plus <= and2.4.out
net joginczn_final halui.jog.2.increment-plus <= and2.5.out
## 7xCNC custom_postgui.hal file
## customised for generic X-Box controller from Ebay
## Based on:
## http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Simple_Remote_Pendant
## http://wiki.linuxcnc.org/cgi-bin/wiki.pl?Adding_More_Controls_To_Simple_Remote_Pendant
## need linuxcnc 2.5 or better
loadrt or2 count=5
loadrt mux4 count=2
loadrt toggle count=1
loadrt near count=7
loadrt and2 count=6
loadrt mux2 count=3
addf or2.0 servo-thread
addf or2.1 servo-thread
addf or2.2 servo-thread
addf or2.3 servo-thread
addf or2.4 servo-thread
addf mux4.0 servo-thread
addf mux4.1 servo-thread
addf toggle.0 servo-thread
addf mux2.0 servo-thread
addf mux2.1 servo-thread
addf mux2.2 servo-thread
addf near.0 servo-thread
addf near.1 servo-thread
addf near.2 servo-thread
addf near.3 servo-thread
addf near.4 servo-thread
addf near.5 servo-thread
addf near.6 servo-thread
addf and2.0 servo-thread
addf and2.1 servo-thread
addf and2.2 servo-thread
addf and2.3 servo-thread
addf and2.4 servo-thread
addf and2.5 servo-thread
## use near for incremental jog moves, must push stick all the way for movement and to avoid unexpected movement by not
## pushing stick straight, sensitivity can be adjusted
setp near.0.in1 1
setp near.1.in1 1
setp near.2.in1 1
setp near.3.in1 -1
setp near.4.in1 -1
setp near.5.in1 -1
# 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 2000
setp mux4.0.in3 5000
## set the size of incremental moves
setp mux4.1.in0 0
setp mux4.1.in1 .1
setp mux4.1.in2 1
setp mux4.1.in3 10
## add for toggle to toggle between continuous and incremental jog
net jog-inc toggle.0.in <= input.0.btn-thumbr
# the following does the magic of setting the jog speeds
net remote-speed-slow or2.0.in0 or2.2.in0 input.0.btn-y
net remote-speed-medium or2.1.in0 or2.3.in0 input.0.btn-b
net remote-speed-fast or2.0.in1 or2.1.in1 or2.2.in1 or2.3.in1 input.0.btn-a
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
net jog-size-1 mux4.1.sel0 <= or2.2.out
net jog-size-2 mux4.1.sel1 <= or2.3.out
net jog-size-final halui.jog.0.increment halui.jog.1.increment halui.jog.2.increment <= mux4.1.out
setp mux2.0.in1 0
setp mux2.1.in1 0
setp mux2.2.in1 0
## hook up the joysticks
net joy-x-sig mux2.0.in0 near.0.in2 near.3.in2 <= input.0.abs-x-position
net joy-y-sig mux2.1.in0 near.1.in2 near.4.in2 <= input.0.abs-y-position
net joy-z-sig mux2.2.in0 near.2.in2 near.5.in2 <= input.0.abs-hat0y-position
## reverse x, y & z using scale as needed
## renumber if you have scale elsewhere in .hal files (e.g. spindle stuff)
loadrt scale count=3
addf scale.0 servo-thread
addf scale.1 servo-thread
addf scale.2 servo-thread
## link scale to mux output for x axis then set the gain to -1
## x-axis is correct for me so gain = 1, doesn't invert
net reverse-x scale.0.in <= mux2.0.out
setp scale.0.gain 1
## link scale to mux output for y axis then set the gain to -1
net reverse-y scale.1.in <= mux2.1.out
setp scale.1.gain -1
## link scale to mux output for z axis then set the gain to -1
net reverse-z scale.2.in <= mux2.2.out
setp scale.2.gain -1
## send signal to analog jog if not in incremental jog mode
net joy-x-jog halui.jog.0.analog <= scale.0.out
net joy-y-jog halui.jog.1.analog <= scale.1.out
net joy-z-jog halui.jog.2.analog <= scale.2.out
## toggle from continuous to incremental jogs
net joginc and2.0.in1 and2.1.in1 and2.2.in1 and2.3.in1 and2.4.in1 and2.5.in1 mux2.0.sel mux2.1.sel mux2.2.sel <= toggle.0.out
## if toggle is set for incremental and joystick is 1 or -1 make an incremental move
## hook up near outputs to and2. inputs
net jogincx and2.0.in0 <= near.0.out
net jogincy and2.1.in0 <= near.1.out
net jogincz and2.2.in0 <= near.2.out
net jogincxn and2.3.in0 <= near.3.out
net jogincyn and2.4.in0 <= near.4.out
net joginczn and2.5.in0 <= near.5.out
## To change the direction of incremental move (e.g. if moves opposite to desired) just change the plus and minus portion of halui.jog.N.increment-(plus or minus)
## and2 outputs to halui incremental jog
net jogincx_final halui.jog.0.increment-plus <= and2.0.out
net jogincy_final halui.jog.1.increment-minus <= and2.1.out
net jogincz_final halui.jog.2.increment-minus <= and2.2.out
net jogincxn_final halui.jog.0.increment-minus <= and2.3.out
net jogincyn_final halui.jog.1.increment-plus <= and2.4.out
net joginczn_final halui.jog.2.increment-plus <= and2.5.out
# estop using either shoulder trigger to estop
# left small shoulder button resets estop, 2nd press turns power on to machine
net pgm-estop-0 input.0.abs-z-is-pos or2.4.in0
net pgm-estop-1 input.0.abs-rz-is-pos or2.4.in1
net pgm-estop or2.4.out halui.estop.activate
net pgm-estop-2 input.0.btn-tl halui.estop.reset halui.machine.on
#-- central buttons activate manual mode and restart the program
net mode-manual input.0.btn-thumbl axisui.set-manual-mode
net pgm-run input.0.btn-start halui.program.run