USB Joypad/Joystick Struggles

More
20 Apr 2024 23:53 #298753 by Project_Hopeless
I have an Axis/Vismach sim I'm trying to add a joystick to.  I used PNCconf to setup a dummy config including the USB Joystick.  I then copied some joystick lines to my  Axis/Vismach sim.  Halshow sees the joystick and the inputs toggle, the sim does not seem to respond.

 

The tutorials made it look simple.  What am I missing setting up the joystick? 
Attachments:

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

More
21 Apr 2024 16:54 #298788 by Project_Hopeless
The below HAL line are copied form a joypad example I'm using.
# To avoid any startup problems and machine turning off transients, mux/sample-hold the analog signals to avoid sending a jog command.
#
loadrt mux2 names=mux2_x,mux2_y,mux2_z
 
addf mux2_x servo-thread
addf mux2_y servo-thread
addf mux2_z servo-thread

Loading dumps at the mux2 declaration.  How does one add additional mux2 signal handling?
Starting DISPLAY program: axis
mux2: already exists

Shutting down and cleaning up LinuxCNC...

 

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

More
21 Apr 2024 17:50 #298790 by Aciera
Do you have another line starting with ' loadrt mux2' ?
If not remove the underscores ( _ ) in the names and try again.

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

More
21 Apr 2024 19:37 #298797 by Project_Hopeless
Yes in a different hal file.  When I copied a working sim as a template for mine, it created the  ./moveo_cmds.hal from  /tmp/tmp_basic_sim.tcl 

In the _cmd file is   loadrt mux2 names=J0_mux,J1_mux,J2_mux,J3_mux,J4_mux,J5_mux

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

More
22 Apr 2024 08:44 - 22 Apr 2024 08:50 #298825 by Aciera
If you want to load instances of the same rt-component in different lines you need to add this to the [HAL] section of your ini file:

TWOPASS = ON

linuxcnc.org/docs/html/config/ini-config.html#sub:ini:sec:hal

[edit]

When I copied a working sim as a template for mine, it created the  ./moveo_cmds.hal from  /tmp/tmp_basic_sim.tcl 

Just realized, I strongly advise against copying hal entries from a sim-config unless you really know what you are doing. The simulator creates HAL entries that have no relevance in a config for a physical machine.
I recommend creating a basic configuration using stepconf or PNCConf tools (depending on what hardware interface you are aiming for), get all the limit switches and motors working  and then modify that to add anything else you might need. 
Last edit: 22 Apr 2024 08:50 by Aciera.

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

More
01 May 2024 16:25 #299473 by V34michel
I'm not a specialist, just a beginner trying to understand.... I have used a standard Joystick doing the following: (source wiki.linuxcnc.org/cgi-bin/wiki.pl?Using_...ove_Your_CNC_Machine)
- in custom_postgui.hal added this 2 lines
source joypad_jog_speed.hal
source joypad_xyz.hal

- joypad_xyz.hal contain
#
# To avoid any startup problems and machine turning off transients, mux/sample-hold the analog signals to avoid sending a jog command.
#
loadrt mux2 names=mux2_x,mux2_y,mux2_z

addf mux2_x servo-thread
addf mux2_y servo-thread
addf mux2_z servo-thread

#
# Use a mux as a sample hold so analog jogs don't change when machine is off.
#
net machine-is-on <= halui.machine.is-on => mux2_x.sel mux2_y.sel mux2_z.sel # Control the mux with the machine on/off state.

net jog-x-pre <= input.0.abs-x-position => mux2_x.in1
net jog-y-pre <= input.0.abs-y-position => mux2_y.in1
net jog-z-pre <= input.0.abs-rz-position => mux2_z.in1 # rz feels more natural.

net jog-x-analog <= mux2_x.out => mux2_x.in0 halui.joint.0.analog halui.axis.x.analog
net jog-y-analog <= mux2_y.out => mux2_y.in0 halui.joint.1.analog halui.axis.y.analog
net jog-z-analog <= mux2_z.out => mux2_z.in0 halui.joint.2.analog halui.axis.z.analog

- joypad_jog_speed.hal contain
#
# Joypad_jog_speed.hal
#
# This file is an example .hal for control of the halui jog speed using a hal_input device.
# This was tested with a Logitech F310.
#
# This file connects three buttons to choose maximum jog speed in axis and joint modes.
# Add this file to postgui_call_list.hal using a line with "source Joypad_jog_speed.hal".
# Add another file (joypad_xyz.hal or joypad_xy.hal) to link the joysticks values to achieve motion.
#
loadusr -W hal_input -KRAL Joystick
#
# Using Joypad buttons to set the speeds
#
# This feature makes the joypad safer to use as you must hold a speed selection button while jogging.
#
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 50.0 # Max jog speed when first speed select button is pressed.
setp joy_mux4.in2 500.0 # Max jog speed when second speed select button is pressed.
setp joy_mux4.in3 2000.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.
# Notice this does not fully decode the button possibilities. If you simultaneously press multiple buttons you will get the higher speed.
#
net slow <= joy_or2_sel0.in0 => input.0.btn-trigger # 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
net jog-speed <= joy_mux4.out => halui.axis.jog-speed halui.joint.jog-speed

# inverse jog Z
setp input.0.abs-rz-scale -127.5
# inverse jog Y
setp input.0.abs-y-scale -127.5

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

Time to create page: 0.546 seconds
Powered by Kunena Forum