Trying to get analog joystick to control jogging

  • peterdownunder
  • Away
  • Senior Member
  • Senior Member
More
05 May 2026 01:42 - 07 May 2026 05:41 #346164 by peterdownunder
Trying to get analog joystick to control jogging was created by peterdownunder
Trying to get analog jogging working on gmoccapy, linuxcnc 2.9.3 with mesa card.
Have followed a few separate threads and have com up with the following .starting with just the x-axis. The analog out from the mesa is approx 0 to 5v

 loadrt mux2 names=mux2_x,mux2_y,mux2_z
addf mux2_x servo-thread
addf mux2_y servo-thread
addf mux2_z servo-thread

loadrt and2 names=and-jog
addf and-jog servo-thread

loadrt deadzone names=deadzone-x
addf deadzone-x servo-thread

loadrt scale names=scale.x
addf scale.x servo-thread

setp scale.x.offset -1.00
setp scale.x.gain .416
net x-scale <= hm2_7i76e.0.7i76.0.0.analogin0 => scale.x.in
net gate-x-scale <= scale.x.out => mux2_x.in1 
net x-is-homed <= halui.joint.0.is-homed

net machine-is-on <= halui.machine.is-on => and-jog.in0
net x-is-homed => and-jog.in1 
net jog-allowed <= and-jog.out => mux2_x.sel

setp deadzone-x.threshold 0.1
net mux-x mux2_x.out => deadzone-x.in

net jog-x-analog deadzone-x.out => halui.joint.0.analog halui.axis.x.analog
setp halui.mode.manual 1
setp halui.joint.0.select 1

Am getting halui.joint.0.analog going from +1 to -1 ok and seems to be gated correctly if I unhome X.
Was getting
error: command [EMC_JOG_STOP] cannot be executed until the machine is out of E-Stop and turned on
when I didn't have the gating correct so it appears to be getting through to some extent 

I also seem to have a problem with deadzone as configured above. It is letting through values like .006 when threshold is .1. If I change it to .2 it seems to behave better.

But get no movement. Jogging using gmoccapy still works
Last edit: 07 May 2026 05:41 by peterdownunder.

Please Log in or Create an account to join the conversation.

  • peterdownunder
  • Away
  • Senior Member
  • Senior Member
More
20 May 2026 08:31 #346509 by peterdownunder
Replied by peterdownunder on topic Trying to get analog joystick to control jogging
No response.
So, is what I am trying to do possible.
I want to jog the machine in X-Y-Z using an analog joystick with gmoccapy as the frontend with the jog speed dynamic based on the joystick position.

Anticipate only allowing jogging when in the jog menu of gmoccapay.

Also of note when I am jogging using the jog buttons in gmoccapy and move the joystick the jogging stops. Is there a conflict between gmoccapy and the analog controls. 

Please Log in or Create an account to join the conversation.

More
20 May 2026 11:56 #346515 by tommylight
Replied by tommylight on topic Trying to get analog joystick to control jogging
It's a joystick, and those have been analog for the last 20 years or so, last digital joystick i had was 30 years ago.
In short, you are looking at the wrong thing, search for joystick, not for analog joystick, or xbox controller or PS2/3/4/5 controller, there are some here on the forum.
html.duckduckgo.com/html?q=linuxcnc%20joystick

Please Log in or Create an account to join the conversation.

  • peterdownunder
  • Away
  • Senior Member
  • Senior Member
More
21 May 2026 10:07 #346531 by peterdownunder
Replied by peterdownunder on topic Trying to get analog joystick to control jogging
That is what I have been looking up and where I got most of that config from.

I would have thought that once I got one or both of halui.joint.0.analog halui.axis.x.analog going from -1 to +1 that would be enough.

I have not actually seen a statement in the manual stating this.
I am assuming there is something else I am not setting.

There are a lot of pins relating to analog and jog and it is difficult to understand the interactions between them

Please Log in or Create an account to join the conversation.

  • spumco
  • Away
  • Platinum Member
  • Platinum Member
More
21 May 2026 10:42 #346532 by spumco
Maybe take another look at halui.joint.N.analog in the manual... looks like it's a jog-speed multiplier, not an absolute speed command.

And I didnt see where you set the jog speed pin to a particular value.  If my suspicion is correct, you're effectively multiplying the analog value x zero.

Try setting halui.joint.N.jog-speed to some value (same with axis) and see if that does it.
 
The following user(s) said Thank You: peterdownunder

Please Log in or Create an account to join the conversation.

  • peterdownunder
  • Away
  • Senior Member
  • Senior Member
More
21 May 2026 21:42 #346543 by peterdownunder
Replied by peterdownunder on topic Trying to get analog joystick to control jogging
Thanks for the hint.
From what I see i have to set halui.joint.jog-speed to some nominal value
Then net the analog value halui.joint.N.analog as I have done above

It also seems possible that I have to set either halui.joint.N.minus or halui.joint.N.plus to actually initiate the jogging

I will play with these options

Please Log in or Create an account to join the conversation.

  • spumco
  • Away
  • Platinum Member
  • Platinum Member
More
21 May 2026 22:12 #346544 by spumco
Dont forget to set halui.axis.N.jog-speed as well to the same value as joint.N.

joint.N.jog-speed is used before homing, and axis.N.jog-speed is used after.

It may get a little complicated in HAL, but there should be a component or other logic chain which triggers joint.N.plus when the joystick value is >0, and opposite for <0.

Maybe look at wcomp...  Perhaps two wcomp instances, one for plus and one for minus:
  • set the wcomp.0.min to just above 0
  • set the wcomp.1.max to just below 0
giving you (I think) an adjustable deadband if the joystick analog value flutters a bit at the center point.
The following user(s) said Thank You: peterdownunder

Please Log in or Create an account to join the conversation.

  • peterdownunder
  • Away
  • Senior Member
  • Senior Member
More
22 May 2026 09:45 #346557 by peterdownunder
Replied by peterdownunder on topic Trying to get analog joystick to control jogging
Thanks guys, got it working and after playing with parameters it feels quite workable.
The joystick is one of the ones with a button so may look at using it for fast/slow jog

Will post full file once finished
The following user(s) said Thank You: tommylight, spumco

Please Log in or Create an account to join the conversation.

  • peterdownunder
  • Away
  • Senior Member
  • Senior Member
More
25 May 2026 09:44 #346600 by peterdownunder
Replied by peterdownunder on topic Trying to get analog joystick to control jogging
Here is the full file

loadrt mux2 names=mux2_x,mux2_y,mux2_z
addf mux2_x servo-thread
addf mux2_y servo-thread
addf mux2_z servo-thread

loadrt wcomp names=plus_x_trigger,minus_x_trigger,plus_y_trigger,minus_y_trigger,plus_z_trigger,minus_z_trigger
addf plus_x_trigger servo-thread
addf minus_x_trigger servo-thread
addf plus_y_trigger servo-thread
addf minus_y_trigger servo-thread
addf plus_z_trigger servo-thread
addf minus_z_trigger servo-thread

# this is the deadzone for each axis to stop drift, also can make bigger to stop x/y axis moves easier without one triggering the other
setp plus_x_trigger.max 0.15
setp minus_x_trigger.min -0.15
setp plus_y_trigger.max 0.15
setp minus_y_trigger.min -0.15
setp plus_z_trigger.max 0.15
setp minus_z_trigger.min -0.15

loadrt lut5 names=jog_x_enable,jog_y_enable,jog_z_enable
addf jog_x_enable servo-thread
setp jog_x_enable.function 0x80
addf jog_y_enable servo-thread
setp jog_y_enable.function 0x80
addf jog_z_enable servo-thread
setp jog_z_enable.function 0x80

loadrt or2 names=or-x-jog,or-y-jog,or-z-jog
addf or-x-jog servo-thread
addf or-y-jog servo-thread
addf or-z-jog servo-thread

loadrt scale names=scale.x,scale.y,scale.z
addf scale.x servo-thread
addf scale.y servo-thread
addf scale.z servo-thread

# mine were 0-4.8v. Assuming a range of -1 to +1. 2/4.8=.416 z was way off balance and cannot see how to adjust so do it in sw
setp scale.x.offset -1.00
setp scale.x.gain .416
setp scale.y.offset -1.00
setp scale.y.gain .416
setp scale.z.offset -0.80
setp scale.z.gain .416

net x-scale <= hm2_7i76e.0.7i76.0.0.analogin0 => scale.x.in
net y-scale <= hm2_7i76e.0.7i76.0.0.analogin1 => scale.y.in
net z-scale <= hm2_7i76e.0.7i76.0.0.analogin2 => scale.z.in

# the mux is used to select 0 or the current value and is implementing the deadband. Cannot let the analog value through otherwise in interferes with jogging from ui
net gate-x-scale <= scale.x.out => plus_x_trigger.in minus_x_trigger.in mux2_x.in1
net gate-y-scale <= scale.y.out => plus_y_trigger.in minus_y_trigger.in mux2_y.in1
net gate-z-scale <= scale.z.out => plus_z_trigger.in minus_z_trigger.in mux2_z.in1

# may not be needed anymore
net x-is-homed <= halui.joint.0.is-homed => jog_x_enable.in-1
net y-is-homed <= halui.joint.1.is-homed => jog_y_enable.in-1
net z-is-homed <= halui.joint.2.is-homed => jog_z_enable.in-1

# only allow jogging if in the jog menu linuxcnc/gmoccapy seemed to complain in any other state
net machine-is-injog <= halui.mode.is-manual => jog_x_enable.in-0 jog_y_enable.in-0 jog_z_enable.in-0

# fixed for all axis multiplied from .15 to 1 from scale above. Change scale is difference needed for each axis
setp halui.axis.jog-speed 600
setp halui.joint.jog-speed 600

# wcomp is used here as deadband. Controls relevant jog plus or minus
net enable-x-jog-plus <= plus_x_trigger.over => halui.axis.x.plus or-x-jog.in0
net enable-x-jog-minus <= minus_x_trigger.under => halui.axis.x.minus or-x-jog.in1
net enable-y-jog-plus <= plus_y_trigger.over => halui.axis.y.plus or-y-jog.in0
net enable-y-jog-minus <= minus_y_trigger.under => halui.axis.y.minus or-y-jog.in1
net enable-z-jog-plus <= plus_z_trigger.over => halui.axis.z.plus or-z-jog.in0
net enable-z-jog-minus <= minus_z_trigger.under => halui.axis.z.minus or-z-jog.in1

# if all 3 conditions are met i.e. not in deadband, is homed and is manual then select mux and route analog value to axis
net jog-x-either <= or-x-jog.out => jog_x_enable.in-2
net enable-x-mux <= jog_x_enable.out => mux2_x.sel
net jog-x-speed <= mux2_x.out => halui.axis.x.analog

net jog-y-either <= or-y-jog.out => jog_y_enable.in-2
net enable-y-mux <= jog_y_enable.out => mux2_y.sel
net jog-y-speed <= mux2_y.out => halui.axis.y.analog

net jog-z-either <= or-z-jog.out => jog_z_enable.in-2
net enable-z-mux <= jog_z_enable.out => mux2_z.sel
net jog-z-speed <= mux2_z.out => halui.axis.z.analog
The following user(s) said Thank You: spumco

Please Log in or Create an account to join the conversation.

Time to create page: 0.076 seconds
Powered by Kunena Forum