Trying to get analog joystick to control jogging
- peterdownunder
- Offline
- Junior Member
-
Less
More
- Posts: 39
- Thank you received: 5
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
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
- Offline
- Junior Member
-
Less
More
- Posts: 39
- Thank you received: 5
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.
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.
- tommylight
-
- Away
- Moderator
-
Less
More
- Posts: 21580
- Thank you received: 7367
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
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
- Offline
- Junior Member
-
Less
More
- Posts: 39
- Thank you received: 5
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
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
- Offline
- Platinum Member
-
Less
More
- Posts: 2082
- Thank you received: 864
21 May 2026 10:42 #346532
by spumco
Replied by spumco on topic Trying to get analog joystick to control jogging
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.
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
- Offline
- Junior Member
-
Less
More
- Posts: 39
- Thank you received: 5
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
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
- Offline
- Platinum Member
-
Less
More
- Posts: 2082
- Thank you received: 864
21 May 2026 22:12 #346544
by spumco
Replied by spumco on topic Trying to get analog joystick to control jogging
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:
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
The following user(s) said Thank You: peterdownunder
Please Log in or Create an account to join the conversation.
- peterdownunder
- Offline
- Junior Member
-
Less
More
- Posts: 39
- Thank you received: 5
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 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.
Time to create page: 0.170 seconds