hal file for gamepad pendant with retrofitted 12-position selector switch

More
1 year 1 week ago #336607 by juergen-home
hal file for gamepad with retrofitted 12-position selector switch
# use special version of toggle2nist:  www.forum.linuxcnc.org/24-hal-components...ton-at-the-same-time
# ALPS encoder EC18AGA20402
# Simple gamepad as a pendant

# Jogging (axes): Buttons 1–4, 11–12 control X, Y, Z motion (+/−).  
# Feed Controls: Buttons 9, 10 adjust program feed override +1 / -1.  
# Feed Controls: Encoder: inputs (6, 8) (17, 19) adjust program feed override in predefined steps
# Program Control: Buttons 13–16 manage stop, pause, start, and mist-coolant.  
# Mode Selection: Encoder: inputs (6, 8) (17, 19) set jog/increment steps via `mux16` and `lut5` for maual jog. 
Code:
# ttm_a for linuxcnc 2.9.6 AXIS GUI 2025-10-17 encoder 16 # use special version of toggle2nist: forum.linuxcnc post 05 Oct 2025 18:50 #335873 special  toggle2nist.comp with "pulse-length" mode from Aciera # https://www.forum.linuxcnc.org/24-hal-components/57307-toggle2nist-hangs-when-pressing-an-other-button-at-the-same-time # https://www.forum.linuxcnc.org/media/kunena/attachments/25994/toggle2nist.comp # sudo halcompile --install toggle2nist.comp # +joging while not homed # +ALPS encoder functionality prepared # ALPS encoder functionality functional # override prepered with Max-velocity # override with Feed Override + Rapid Override # suppress error messages when pressing 1 2 3 4 11 12 start.. while halui.program.is-running / halui.program.is-paused # short circuit one unused analog button to detect if analog is on   # Jogging (axes): Buttons 1–4, 11–12 control X, Y, Z motion (+/−).   # Feed Controls: Buttons 9, 10 adjust program feed override +1 / -1.   # Feed Controls: Encoder: inputs (6, 8) (17, 19) adjust program feed override in predefined steps # Program Control: Buttons 13–16 manage stop, pause, start, and mist-coolant.   # Mode Selection: Encoder: inputs (6, 8) (17, 19) set jog/increment steps via `mux16` and `lut5` for maual jog.  # ================================================================================= # Analog LED on the gamepad has to be switched on, otherwise it is not working as intended. # Furthermore when analog is not on it will e-stop on switching on. If analog is switched off while # program is running it will e-stop when program is stoped. # ================================================================================= # hal file for a simple usb gamepad. # do not trust this .hal file until you tested it yourself under save conditions. # this code contain traces of code from smarter people than me.                                                                                      # For easier integration with my other .hal files components are loaded in "loadrt or2 names=or2_0a" format #For testing in sim.axis I switch "TWOPASS = on" as follow: (axis_mm.ini) #[HAL] #TWOPASS = on #HALFILE = core_sim.hal #HALFILE = sim_spindle_encoder.hal #->#HALFILE = axis_manualtoolchange.hal #HALFILE = simulated_home.hal #->#HALFILE = cooling.hal #HALFILE = gamepad.hal #POSTGUI_HALFILE = postguihalfile2.hal # https://linuxcnc.org/docs/html/man/man9/ # https://linuxcnc.org/docs/html/hal/components.html # --------------------------------------------------------------- # $ less /proc/bus/input/devices  --> usb device name "USB Gamepad" # To use the next line the proper device must be plugged in or it will fail # IF your machine have to run without the gamepad comment out the gamepad.hal in the machines ini file. # generic china loadusr -W hal_input -KRAL USB Gamepad #loadusr -W hal_input -KRAL USB Logitech Logitech Dual Action # RF generic china #loadusr -W hal_input -KRAL Twin USB Joystick Twin USB Joystick # NOTE: LinuxCNC 2.9 renames btn-joystick to btn-trigger.  # --------------------------------------------------------------- # analog LED must be ON: only 2 inputs are usable with buttons. # position: joystick left hand # input.0.abs-x-is-neg # input.0.abs-x-is-pos        not usable (poti swich to +) # input.0.abs-y-is-neg # input.0.abs-y-is-pos        not usable (poti swich to +) # analog LED must be ON: only 2 inputs are usable with buttons. # # position: joystick right hand # input.0.abs-rz-is-neg # input.0.abs-rz-is-pos        not usable (poti swich to +) # input.0.abs-z-is-neg # input.0.abs-z-is-pos        not usable (poti swich to +) # analog LED must be ON: max 2 input buttons in one corner on at the same time are working. # 2 input buttons in opposite (r+l) will not work, more than 2 input buttons at the same time will not work. # position: 4 cross buttons left hand #input.0.abs-hat0x-is-pos     #input.0.abs-hat0x-is-neg #input.0.abs-hat0y-is-pos     #input.0.abs-hat0y-is-neg  # Gamepad USB: # 01 input.0.btn-trigger        1                        y+ direction # 02 input.0.btn-thumb            2                        x+ direction # 03 input.0.btn-thumb2            3                        y- direction # 04 input.0.btn-top            4                        x- direction # 05 input.0.abs-hat0y-is-pos    left-cross top                                not usable (only 2 out of 4 at the same time) # 06 input.0.abs-hat0x-is-pos    left-cross right        incr1 mux16/lut5 # 07 input.0.abs-hat0x-is-neg    left-cross left                                not usable (only 2 out of 4 at the same time) # 08 input.0.abs-hat0y-is-neg    left-cross bottom        incr3 mux16/lut5 # 09 input.0.btn-base            left2                    feed 1% - # 10 input.0.btn-top2            left1                    feed 1% + # 11 input.0.btn-base2            right2                    z- direction # 12 input.0.btn-pinkie            right1                    z+ direction # 13 input.0.btn-base5            button left (3d-print)    E-Stop # 14 input.0.btn-base6            button right (3d-print)    pause # 15 input.0.btn-base3            select                    toggle coolant-mist # 16 input.0.btn-base4            start                    start/home all # 17 input.0.abs-x-is-neg        joystick left hand        incr0    mux16/lut5 # 18 input.0.abs-x-is-pos        joystick left hand                            not usable (poti swich to +) # 19 input.0.abs-y-is-neg        joystick left hand        incr2    mux16/lut5 # 20 input.0.abs-y-is-pos        joystick left hand                            not usable (poti swich to +) # 21 input.0.abs-rz-is-neg        joystick right hand        analog-on # 22 input.0.abs-rz-is-pos        joystick right hand                            not usable (poti swich to +) # 23 input.0.abs-z-is-neg        joystick right hand        free # 24 input.0.abs-z-is-pos        joystick right hand                            not usable (poti swich to +) #┌────────────────────────────────────────────────┐ #│  ┌─────┐           front           ┌─────┐     │ #│  │  9  │        <--bottom-->       │ 11  │     │ #│  └─────┘                           └─────┘     │ #│  ┌─────┐           front           ┌─────┐     │ #│  │ 10  │         <--top-->         │ 12  │     │ #│  └─────┘     select        start   └─────┘     │ #│     5          15            16           1    │ #│                                                │ #│  8     6       17            21        4     2 │ #│              ┌────┐        ┌────┐              │ #│     7      20│ 13 │18    24│ 14 │22       3    │ #│              └────┘        └────┘              │ #│                19            23                │ #└────────────────────────────────────────────────┘ # example how to change increment # set jog increment to 1 #setp halui.axis.x.increment 0.1 # example how to change jog-speed # set jog speed to 100 jog-speed #setp halui.axis.jog-speed 100 #Buttons to net (if we want to use a button for more than 1 function) net net-input-base6 input.0.btn-base6 net net-input-0-btn-base input.0.btn-base #--------------------- # Software-based estop (13) #--------------------- #net net-estop input.0.btn-base5 => halui.estop.activate  # button estop #--------------------- #--------------------- # Program Stop (13) net net-stop1 input.0.btn-base5 => halui.program.stop #--------------------- #--------------------- # when analog mode is not on   #--------------------- # for detecting this, there is a bridge soldered in for input.0.abs-rz-is-neg # while input.0.abs-rz-is-neg is the same as input.0.btn-top (x- direction) if analog mode is off  the x-axis is running x-direction all the time # so we have to prevent this state with immediately e-stop when no program is running or e-stop when a running program stops. # let the program run for the case analog is switched off by accidentely so the work is not lost. # by this you can not even switch on the machine when analog is off. # if you have a better solution let me know. #--------------------- loadrt and2 names=and2_analog,and2_analog_p_run,and2_analog_p_run_not addf and2_analog servo-thread addf and2_analog_p_run servo-thread addf and2_analog_p_run_not servo-thread loadrt not names=not_analog addf not_analog servo-thread loadrt message names=analog,analog_alert messages="gamepad: switch on analog,gamepad: switch on analog or machine will e-stop if program is stopped" addf analog servo-thread addf analog_alert servo-thread  setp analog.edge 1                      setp analog_alert.edge 1                      loadrt edge names=edge_clear_msg addf edge_clear_msg servo-thread  setp edge_clear_msg.both 0 setp edge_clear_msg.in-edge 0 setp edge_clear_msg.out-width-ns 100000000 net net-analog-in input.0.abs-rz-is-neg => not_analog.in        # signal from gamepdad net net-analog-on-not <= not_analog.out                            # inverse signal from gamepdad net net-analog-in edge_clear_msg.in                                # impulse for clear messages when analog is switched on net net-edge-clear-msg edge_clear_msg.out                        # impulse for clear messages when analog is switched on # if analog is not on and machine is switched on message is triggered net net-analog-on-not and2_analog.in0 net net-analog-on-not1 and2_analog.in1 <= halui.machine.is-on net net-analog and2_analog.out => analog.trigger                                 #message to GUI Axis # if analog is not on and no prog. is running do e-stop net net-programm-is-on-not and2_analog_p_run_not.in0     net net-analog and2_analog_p_run_not.in1     net met-analog-p-run-not-out and2_analog_p_run_not.out    halui.estop.activate     # e-stop if analog not active # if analog is not on and prog. is running  message2 is triggered  net net-programm-is-on and2_analog_p_run.in0     net net-analog-on-not and2_analog_p_run.in1     net net-analog-p-run-out and2_analog_p_run.out    => analog_alert.trigger         #message to GUI Axis # this is for clearing messages. clearing code is in the postguihalfile2.hal loadrt or2 names=or2-clear-messages        # for postguihalfile2.hal clear message addf or2-clear-messages servo-thread    # for postguihalfile2.hal clear message #--------------------- #--------------------- # Program Start (start when homed / home when not homed) / clear all messages in axix gui #--------------------- loadrt and2 names=and_home addf and_home servo-thread loadrt not names=not_homed addf not_homed servo-thread # if not homed: home all axis when pressing the start button net net-homed not_homed.in <= halui.joint.0.is-homed     # homed net net-not-homed not_homed.out and_home.in0            # when not homed net net-start.button-pressed  and_home.in1                # and start pressed net net-home-all-now and_home.out halui.home-all            # home all axis # start program (when at least x-axis is homed, only x-axis is checked but start will fail if not all axis are homed) loadrt and2 names=and_is_homed addf and_is_homed servo-thread loadrt and2 names=and_prog-11 #Load AND components for logical AND operations addf and_prog-11 servo-thread # for start net net-homed and_is_homed.in0                         # when homed net net-start.button-pressed input.0.btn-base4        # and start pressed net net-start.button-pressed  and_is_homed.in1        # and start pressed net net-programm-is-on-not and_prog-11.in0            # dont start when program is already running to prevent error message  net net-programm-is-on-not11 and_prog-11.in1 and_is_homed.out net net-run-prog and_prog-11.out => halui.program.run    # start program # ->postguihalfile2.hal: axisui.notifications-clear #clear all messages in axix gui #--------------------- #--------------------- # Program Pause on/off #--------------------- # known bugs: if you e-stop  while pressing pause, than swich on and start program again, occasionally pause will not work. # sometimes tog2nist_1.on stays on! --> only with original toggle2nist.comp #loadrt toggle names=tog_1  # Load N components for logical NOT operations #addf tog_1 servo-thread loadrt toggle2nist names=tog2nist_1  # Load N components for logical NOT operations addf tog2nist_1 servo-thread # these 2 setp have to be commented out for regular toggle2nist.comp in 2.9.6 # setp tog2nist_1.debounce 2 setp tog2nist_1.pulse-length 50 # to prevent hanging tog2nist / forum.linuxcnc post 05 Oct 2025 18:50 #335873 special  toggle2nist.comp from Aciera # this toggle in front of toggle2nist is needed for regular toggle2nist.comp in 2.9.6 #net  net-input-base6 => tog_1.in  # this is the pause button #net net-button-pause tog2nist_1.in <= tog_1.out net net-input-base6 => tog2nist_1.in net net-halui-program-is-paused halui.program.is-paused net net-halui-program-is-paused tog2nist_1.is-on net net-pause-off tog2nist_1.off => halui.program.resume net net-pause-on tog2nist_1.on => halui.program.pause #--------------------- #--------------------- # Coolant Signal #--------------------- # with this 2 lines each coolant shows a checkbox in the axis ui # this is normaly part of the machine.hal / here only for test in the SIM-HAL-AXIS net coolant-mist      <=  iocontrol.0.coolant-mist net coolant-flood     <=  iocontrol.0.coolant-flood #--------------------- #---------------------------------------------------------------------------------------------------------- # Activate coolant / mist #---------------------------------------------------------------------------------------------------------- # A single joypad button will start and stop the coolant. # coolant on-off with toggle2nist loadrt toggle names=tog_0   # Load N components for logical NOT operations addf tog_0 servo-thread loadrt toggle2nist names=tog2nist_0   # Load N components for logical NOT operations addf tog2nist_0 servo-thread # this toggle in front of toggle2nist is needed for regular toggle2nist.comp in 2.9.6 #net net-joy-mist-toggle tog_0.in  <= input.0.btn-base3 #net net-button-start tog2nist_0.in <= tog_0.out net net-button-start tog2nist_0.in <= input.0.btn-base3  # here is the button net net-mist.is-on tog2nist_0.is-on <= halui.mist.is-on net net-mist-off tog2nist_0.off => halui.mist.off net net-mist-on tog2nist_0.on => halui.mist.on #---------------------------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------------------------- # For jog without (before) homing - fixed jog-speed 500 #---------------------------------------------------------------------------------------------------------- # This is not properly working with the simulation. If you jog before homing with x+ or z- homing may fail. # In my real machine it seems to work # we have to use the net name "net-x-minus.jog" not the actual button name because we feed the botton to multiple inputs # Before homing (if allowed) you jog joints. After homing you must jog axes. setp halui.joint.jog-speed 500 net net-x-minus-jog    => halui.joint.0.minus net net-x-plus-jog    => halui.joint.0.plus net net-y-minus-jog    => halui.joint.1.minus net net-y-plus-jog    => halui.joint.1.plus net net-z-minus-jog    => halui.joint.2.minus net net-z-plus-jog    => halui.joint.2.plus #---------------------------------------------------------------------------------------------------------- # ----- # selection of incremental / jog  values with (mux16) # ----- # we use a 4 bit 12 position encoder here loadrt mux16 names=mux_encoder # for 16 different incremental steps addf mux_encoder servo-thread     # add to the servo-thread so it can be used #mux16.N.use-graycode bit in #This signifies the input will use Gray code instead of binary. Gray code is a good choice when using physical switches because for each increment only one select input changes at a time. #not used yet # Define the gamepad inputs for selection of incremental / jog  values  # # alps    gamepad                        net # 2        input.0.abs-hat0x-is-pos    incr1     #      # 4        input.0.abs-hat0y-is-neg    incr3 # 5        COM                             # 3        input.0.abs-y-is-neg        incr2 # 1        input.0.abs-x-is-neg        incr0 # buttons for the encoder net incr0 input.0.abs-x-is-neg net incr1 input.0.abs-hat0x-is-pos net incr2 input.0.abs-y-is-neg net incr3 input.0.abs-hat0y-is-neg # connect the buttons with the multiplexer net incr0 mux_encoder.sel0 net incr1 mux_encoder.sel1 net incr2 mux_encoder.sel2 net incr3 mux_encoder.sel3 # ----- # Set the 12 incremental step and jog values for the mux16 component setp mux_encoder.in00 0            # off            0 setp mux_encoder.in01 0.01        # Increment        1 setp mux_encoder.in03 0.05        # Increment        2 setp mux_encoder.in02 0.1        # Increment     3     setp mux_encoder.in06 1            # Increment        4 setp mux_encoder.in07 10        # Jog            5 setp mux_encoder.in05 50        # Jog             6 setp mux_encoder.in04 100        # Jog             7 setp mux_encoder.in12 200        # Jog            8     setp mux_encoder.in13 500        # Jog            9 setp mux_encoder.in09 1000        # Jog            10 setp mux_encoder.in08 3000        # Jog            11 setp mux_encoder.in11 0            # Jog            # not used setp mux_encoder.in10 0            # Jog            # not used setp mux_encoder.in14 0            # Jog            # not used setp mux_encoder.in15 0            # Jog            # not used #---- if you want to use mux16grey code instead use this example: # Set the 12 incremental step and jog values for the mux16 component use grey code #setp mux_encoder.use-graycode 1 #setp mux_encoder.in00 0        # off            0 #setp mux_encoder.in01 0.01        # Increment        1 #setp mux_encoder.in02 0.05        # Increment        2 #setp mux_encoder.in03 0.1        # Increment     3     #setp mux_encoder.in04 1        # Increment        4 #setp mux_encoder.in05 10        # Jog            5 #setp mux_encoder.in06 50        # Jog             6 #setp mux_encoder.in07 100        # Jog             7 #setp mux_encoder.in08 200        # Jog            8     #setp mux_encoder.in09 500        # Jog            9 #setp mux_encoder.in10 0        # Jog            # not used #setp mux_encoder.in11 0        # Jog            # not used #setp mux_encoder.in12 0        # Jog            # not used #setp mux_encoder.in13 0        # Jog            # not used #setp mux_encoder.in14 1000        # Jog            10 #setp mux_encoder.in15 3000        # Jog            11 #---- # 4-Bit- # Gray-Code # 4321    16pos    Switch position ALPS # 0000    1        1 # 0001    2        2 # 0011    3        3 # 0010    4        4 # 0110    5        5 # 0111    6        6 # 0101    7        7 # 0100    8        8 # 1100    9        9 # 1101    10        10 # 1111    11         # 1110    12         # 1010    13         # 1011    14         # 1001    15        11 # 1000    16        12 net net-mux-encoder-out mux_encoder.out-f            # the actual increment value net net-mux-encoder-out => halui.axis.x.increment     # the actual increment value to the axis net net-mux-encoder-out => halui.axis.y.increment  # the actual increment value to the axis net net-mux-encoder-out => halui.axis.z.increment  # the actual increment value to the axis # ! The 4 bit 12 position ALPS ecoder uses GREY code #                                            Position #            (8)        (4)        (2)        (1)        GREY code                        LUT5 #    decimal    sel3    sel2    sel1    sel0    ALPS SW    mux_encoder.out    mux.in    weight    jog/incr #    0        0        0        0        0        1        0        0        00        0x1 #    1        0        0        0        1        2        0.01    1        01        0x2        increment #    2        0        0        1        0        4        0.1        3        02        0x4        increment #    3        0        0        1        1        3        0.05    2        03        0x8        increment #    4        0        1        0        0        8        200        7        04        0x10    jog #    5        0        1        0        1        7        100        6        05        0x20    jog #    6        0        1        1        0        5        1        4        06        0x40    increment #    7        0        1        1        1        6        10        5        07        0x80    jog #    8        1        0        0        0        12        50        11        08        0x100    jog #    9        1        0        0        1        11        3000    10        09        0x200    jog #    10        1        0        1        0                                10     #    11        1        0        1        1                                11 #    12        1        1        0        0        9        500        8        12        0x1000    jog #    13        1        1        0        1        10        1000    9        13        0x2000    jog #    14        1        1        1        0                                14 #    15        1        1        1        1                                15 # ----- # selection of when to jog-incremental and when to jog - with lut5 (look up tabel) # ----- loadrt lut5 names=lut5_incr,lut5_jog #  if we incr or jog addf lut5_incr servo-thread     # add to the servo-thread so it can be used addf lut5_jog servo-thread        # add to the servo-thread so it can be used net incr0 lut5_incr.in-0  net incr1 lut5_incr.in-1  net incr2 lut5_incr.in-2  net incr3 lut5_incr.in-3  #-------------------------------------------------------- # LUT5 function for increment #                                                HEX        DEZ # dec    Bit4    Bit3    Bit2    Bit1    Bit0    Weight    Weight # 1        0        0        0        0        1        0x2        2         # 2        0        0        0        1        0        0x4        4         # 3        0        0        1        0        0        0x8        8 # 6        0        0        1        1        0        0x40    64                 #                                            SUM=0x4E    78         #-------------------------------------------------------- setp lut5_incr.function 0x4E net net-incr-true lut5_incr.out        # indicates that we want to jog-incremental net incr0 lut5_jog.in-0  net incr1 lut5_jog.in-1  net incr2 lut5_jog.in-2  net incr3 lut5_jog.in-3 #-------------------------------------------------------- # LUT5 function for jog #                                                HEX        DEZ #dec    Bit4    Bit3    Bit2    Bit1    Bit0    Weight    Weight # 04    0        0        1        0        0        0x10    16 # 05    0        0        1        0        1        0x20    32         # 07    0        0        1        1        1        0x80    128 # 08    0        1        0        0        0        0x100    256 # 09    0        1        0        0        1        0x200    512 # 12    0        1        1        0        0        0x1000    4096 # 13    0        1        1        0        1        0x2000    8192 #                                            SUM=0x33B0    13232 #-------------------------------------------------------- setp lut5_jog.function 0x33B0 net net-jog-true lut5_jog.out    # indicates that we want to jog #+++++++++++++++++++++++++++++ # Define a fixed jog speed value for the jog-incremental moves loadrt constant names=fixed_jog_speed addf fixed_jog_speed servo-thread setp fixed_jog_speed.value 1000 #+++++++++++++++++++++++++++++ #+++++++++++++++++++++++++++++ # Use mux2 to choose jog speed source between fixed_jog_speed and mux_encoder output loadrt mux2 names=mux_jog_speed     # for 1 different incr-jog speeds addf mux_jog_speed servo-thread     # add to the servo-thread so it can be used # Connect mux2 selection input net net-incr-true => mux_jog_speed.sel     # Select fixed jog speed when jog-incremental is active # Connect mux2 inputs net net-mux-encoder-out mux_jog_speed.in0                        # Variable jog speed from mux_encoder (mux16) net net-fixed-jog-speed fixed_jog_speed.out mux_jog_speed.in1      # Fixed jog-incremental speed from fixed_jog_speed # Connect mux output to halui axis jog speed pin net net-mux2-out mux_jog_speed.out => halui.axis.jog-speed        # output of normal jog speed/ fixed jog speed #+++++++++++++++++++++++++++++ #--feed control with +/- buttons --------------------------------- #--------------------- # increase feed +1 #--------------------- #net net-vel-increase input.0.btn-top2 => halui.max-velocity.increase # with max-velocity net net-vel-increase input.0.btn-top2 => halui.feed-override.increase # with feed-override #--------------------- #--------------------- # decrease feed -1 #--------------------- #net  net-input-0-btn-base => halui.max-velocity.decrease                    # with max-velocity net  net-input-0-btn-base => halui.feed-override.decrease                    # with feed-override #--------------------- # ----- # selection of mux16_feed-override values with (mux16) # ----- # we use a 4 bit 12 position encoder here loadrt mux16 names=mux16_feed-override # for 16 different incremental steps addf mux16_feed-override servo-thread     # add to the servo-thread so it can be used # Define the gamepad inputs for selection of incremental / jog  values  # # alps    gamepad                        net # 2        input.0.abs-hat0x-is-pos    incr1     #      # 4        input.0.abs-hat0y-is-neg    incr3 # 5        COM                             # 3        input.0.abs-y-is-neg        incr2 # 1        input.0.abs-x-is-neg        incr0 # this is already done in the mux_encoder section # buttons for the encoder #net incr0 input.0.abs-x-is-neg #net incr1 input.0.abs-hat0x-is-pos #net incr2 input.0.abs-y-is-neg #net incr3 input.0.abs-hat0y-is-neg # connect the buttons with the multiplexer net incr0 mux16_feed-override.sel0 net incr1 mux16_feed-override.sel1 net incr2 mux16_feed-override.sel2 net incr3 mux16_feed-override.sel3 # ----- # Set the values for the mux16 component feed-override setp mux16_feed-override.in00 0            #    0        0% setp mux16_feed-override.in01 1            #    1        1% setp mux16_feed-override.in03 3            #    2        3% setp mux16_feed-override.in02 10        #      3        10%     setp mux16_feed-override.in06 50        #    4        60% setp mux16_feed-override.in07 100        #    5        100% setp mux16_feed-override.in05 0            #    6        0% setp mux16_feed-override.in04 0            #    7 setp mux16_feed-override.in12 0            #    8     setp mux16_feed-override.in13 0            #    9 setp mux16_feed-override.in09 0            #    10 setp mux16_feed-override.in08 0            #    11 setp mux16_feed-override.in11 0            #    # not used setp mux16_feed-override.in10 0            #    # not used setp mux16_feed-override.in14 0            #    # not used setp mux16_feed-override.in15 0            #    # not used # ----- # selection of rapid-override values with (mux16) # ----- # we use a 4 bit 12 position encoder here loadrt mux16 names=mux16_rapid-override # for 16 different incremental steps addf mux16_rapid-override servo-thread     # add to the servo-thread so it can be used # Define the gamepad inputs for selection of incremental / jog  values  # # alps    gamepad                        net # 2        input.0.abs-hat0x-is-pos    incr1     #      # 4        input.0.abs-hat0y-is-neg    incr3 # 5        COM                             # 3        input.0.abs-y-is-neg        incr2 # 1        input.0.abs-x-is-neg        incr0 # this is already done in the mux_encoder section # buttons for the encoder #net incr0 input.0.abs-x-is-neg #net incr1 input.0.abs-hat0x-is-pos #net incr2 input.0.abs-y-is-neg #net incr3 input.0.abs-hat0y-is-neg # connect the buttons with the multiplexer net incr0 mux16_rapid-override.sel0 net incr1 mux16_rapid-override.sel1 net incr2 mux16_rapid-override.sel2 net incr3 mux16_rapid-override.sel3 # ----- # Set the values for the mux16 component rapid-override # this values are smaller in the low percentage range to reduce the high rapid moves to a save level setp mux16_rapid-override.in00 0            #    0        0% setp mux16_rapid-override.in01 1            #    1        1% setp mux16_rapid-override.in03 3            #    2        3% setp mux16_rapid-override.in02 10            #      3        10%     setp mux16_rapid-override.in06 50            #    4        50% setp mux16_rapid-override.in07 1000            #    5        100% setp mux16_rapid-override.in05 0            #    6        0% setp mux16_rapid-override.in04 0            #    7 setp mux16_rapid-override.in12 0            #    8     setp mux16_rapid-override.in13 0            #    9 setp mux16_rapid-override.in09 0            #    10 setp mux16_rapid-override.in08 0            #    11 setp mux16_rapid-override.in11 0            #    # not used setp mux16_rapid-override.in10 0            #    # not used setp mux16_rapid-override.in14 0            #    # not used setp mux16_rapid-override.in15 0            #    # not used # Override with max-velocity example #setp halui.max-velocity.scale 0.01666666666 # divider for m/min values #setp halui.max-velocity.direct-value 1 # use absolute velocity values #net net-max-vel vel_encoder.out-s => halui.max-velocity.counts # use selected mux16 value # we override with Feed Override + Rapid Override / 2 different mux16 for 2 different value selection #halui.feed-override.direct-value bit in setp halui.feed-override.direct-value 1        # uses the direct value, not a percentage # halui.feed-override.scale float in setp halui.feed-override.scale 0.01         #halui.feed-override.counts s32 in net net-feed-override mux16_feed-override.out-s => halui.feed-override.counts # use selected mux16 value #halui.feed-override.value float out net net-feed-override.value <= halui.feed-override.value # halui.rapid-override.direct-value bit in setp halui.rapid-override.direct-value 1 # halui.rapid-override.scale float in setp halui.rapid-override.scale 0.001        # scale 0.001 for finer granulation # halui.rapid-override.counts s32 in net net-rapid-override mux16_rapid-override.out-s => halui.rapid-override.counts # use selected mux16 value #halui.rapid-override.value float out net net-rapid-override.value <= halui.rapid-override.value #--feed control end --------------------------------- # --- detect if program is running or paused to prevent error messages when incidentally press buttons for jogging # so jogging/ incremental-jogging is only commanded when no program is running or paused # halui.program.is-running # halui.program.is-paused loadrt or2 names=or2-programm-is-on          addf or2-programm-is-on servo-thread loadrt not names=not_on   # Load N components for logical NOT operations addf not_on servo-thread net net-program.is-running or2-programm-is-on.in0 <= halui.program.is-running    # program is running net net-halui-program-is-paused or2-programm-is-on.in1                    # program is paused net net-programm-is-on or2-programm-is-on.out                            # program is running or paused                         net net-programm-is-on not_on.in                                        # program is running or paused net net-programm-is-on-not <= not_on.out                                # program is not running or paused  #net net-programm-is-on-not <= halui.program.is-idle loadrt and2 names=and_prog-0,and_prog-2,and_prog-4,and_prog-6,and_prog-8,and_prog-10 #Load AND components for logical AND operations addf and_prog-0 servo-thread     #(for x+) addf and_prog-2 servo-thread addf and_prog-4 servo-thread addf and_prog-6 servo-thread addf and_prog-8 servo-thread addf and_prog-10 servo-thread    #(for z-) net net-programm-is-on-not and_prog-0.in0    # program is running or paused    (for x+) net net-programm-is-on-not and_prog-2.in0    # program is running or paused net net-programm-is-on-not and_prog-4.in0    # program is running or paused net net-programm-is-on-not and_prog-6.in0    # program is running or paused net net-programm-is-on-not and_prog-8.in0    # program is running or paused net net-programm-is-on-not and_prog-10.in0    # program is running or paused    (for z-) #+++++++++++++++++++++++++++++ # jog/jog-incremental the axis #+++++++++++++++++++++++++++++ loadrt and2 names=and_incr_0,and_incr_1,and_incr_2,and_incr_3,and_incr_4,and_incr_5,and_incr_6,and_incr_7,and_incr_8,and_incr_9,and_incr_10,and_incr_11  # Load AND components for logical AND operations addf and_incr_0 servo-thread addf and_incr_1 servo-thread addf and_incr_2 servo-thread addf and_incr_3 servo-thread addf and_incr_4 servo-thread addf and_incr_5 servo-thread addf and_incr_6 servo-thread addf and_incr_7 servo-thread addf and_incr_8 servo-thread addf and_incr_9 servo-thread addf and_incr_10 servo-thread addf and_incr_11 servo-thread #++++ program is on #       halui.program.is-running----|OR                            #                                      |OR─----net-programm-is-on ---|NOT---net-programm-is-on-not                      #    net-halui-program-is-paused----|OR   #      net-programm-is-on-not──|AND                            #                             |AND──input-0-btn-thumb                       #      input.0.btn-thumb───    |AND   # #++++ X plus jog #      input-0-btn-thumb─|AND                            #                     |AND──halui.axis.x.plus                       #      net-jog-true───|AND   # #++++ X plus incremental # input.0.btn-thumb───|AND                            #                     |AND──halui.axis.x.increment-plus                        #     net-incr-true───|AND #------------------------------------------------------------------------------------------------------- # old version #++++ X plus jog #net net-x-plus-jog input.0.btn-thumb                         # button pressed input #net net-x-plus-jog and_incr_0.in0                            # if button is pressed #net net-jog-true and_incr_0.in1                                # and lut5_jog is true #net net-x-plus-jog-out halui.axis.x.plus <= and_incr_0.out     # then jog axis #++++ X plus incremental #net net-x-plus-jog and_incr_1.in0                                            # if button is pressed #net net-incr-true and_incr_1.in1                                            # and lut5_incr is true #net net-x-plus-incr-jog-out halui.axis.x.increment-plus <= and_incr_1.out     # then jog-incremental axis #++++ X plus jog net net-programm-is-on-not1 and_prog-0.in1 input.0.btn-thumb     # program is running or paused and button is pressed net net-x-plus-jog and_prog-0.out                                 #   net net-x-plus-jog and_incr_0.in0                                #  net net-jog-true and_incr_0.in1                                    # and lut5_jog is true net net-x-plus-jog-out halui.axis.x.plus <= and_incr_0.out         # then jog axis #++++ X plus incremental net net-x-plus-jog and_incr_1.in0                                            # if button is pressed net net-incr-true and_incr_1.in1                                            # and lut5_incr is true net net-x-plus-incr-jog-out halui.axis.x.increment-plus <= and_incr_1.out     # then jog-incremental axis #++++ X minus jog net net-programm-is-on-not2 and_prog-2.in1 input.0.btn-top net net-x-minus-jog  and_prog-2.out                            # button pressed input net net-x-minus-jog and_incr_2.in0                                # if button is pressed net net-jog-true and_incr_2.in1                                    # and lut5_jog is true net net-x-minus-jog-out halui.axis.x.minus <= and_incr_2.out     # then jog axis #++++ X minus incremental net net-x-minus-jog and_incr_3.in0                                            # if button is pressed net net-incr-true and_incr_3.in1                                            # and lut5_incr is true net net-x-minus-incr-jog-out halui.axis.x.increment-minus <= and_incr_3.out # then jog-incremental axis #------------------------------------------------------------------------------------------------------- #++++ Y plus jog net net-programm-is-on-not4 and_prog-4.in1 input.0.btn-trigger net net-y-plus-jog  and_prog-4.out                        # button pressed input net net-y-plus-jog and_incr_4.in0                            # if button is pressed net net-jog-true and_incr_4.in1                                # and lut5_jog is true net net-y-plus-jog-out halui.axis.y.plus <= and_incr_4.out     # then jog axis #++++ Y plus incremental net net-y-plus-jog and_incr_5.in0                                            # if button is pressed net net-incr-true and_incr_5.in1                                            # and lut5_incr is true net net-y-plus-incr-jog-out halui.axis.y.increment-plus <= and_incr_5.out     # then jog-incremental axis #++++ Y minus jog net net-programm-is-on-not6 and_prog-6.in1 input.0.btn-thumb2 net net-y-minus-jog  and_prog-6.out                            # button pressed input net net-y-minus-jog and_incr_6.in0                                # if button is pressed net net-jog-true and_incr_6.in1                                    # and lut5_jog is true net net-y-minus-jog-out halui.axis.y.minus <= and_incr_6.out     # then jog axis #++++ Y minus incremental net net-y-minus-jog and_incr_7.in0                                            # if button is pressed net net-incr-true and_incr_7.in1                                            # and lut5_incr is true net net-y-minus-incr-jog-out halui.axis.y.increment-minus <= and_incr_7.out # then jog-incremental axis #-------------------------------------------------------------------------------------------------------# #++++ Z plus jog net net-programm-is-on-not8 and_prog-8.in1 input.0.btn-pinkie net net-z-plus-jog     and_prog-8.out                    # button pressed input net net-z-plus-jog and_incr_8.in0                            # if button is pressed net net-jog-true and_incr_8.in1                                # and lut5_jog is true net net-z-plus-jog-out halui.axis.z.plus <= and_incr_8.out     # then jog axis #++++ Z plus incremental net net-z-plus-jog and_incr_9.in0                                            # if button is pressed net net-incr-true and_incr_9.in1                                            # and lut5_incr is true net net-z-plus-incr-jog-out halui.axis.z.increment-plus <= and_incr_9.out     # then jog-incremental axis #++++ Z minus jog net net-programm-is-on-not10 and_prog-10.in1 input.0.btn-base2 net net-z-minus-jog and_prog-10.out                        # button pressed input net net-z-minus-jog and_incr_10.in0                                # if button is pressed net net-jog-true and_incr_10.in1                                # and lut5_jog is true net net-z-minus-jog-out halui.axis.z.minus <= and_incr_10.out     # then jog axis #++++ Z minus incremental net net-z-minus-jog and_incr_11.in0                                            # if button is pressed net net-incr-true and_incr_11.in1                                            # and lut5_incr is true net net-z-minus-incr-jog-out halui.axis.z.increment-minus <= and_incr_11.out# then jog-incremental axis #-------------------------------------------------------------------------------------------------------
 

Attachment not found


 

Attachment not found


 

Attachment not found



 

Please Log in to join the conversation.

More
1 year 1 week ago #336608 by juergen-home
 

Attachment not found

 

Attachment not found

 

Attachment not found

 

Attachment not found

 

Attachment not found

 

Attachment not found

 

Attachment not found

Please Log in to join the conversation.

More
1 year 1 week ago #336610 by juergen-home
 

Attachment not found

 

Attachment not found

 

Attachment not found

 

Attachment not found

Please Log in to join the conversation.

More
11 months 2 weeks ago #338142 by seuchato
Juergen
Very well done and extremely inspiring!!!
Thanks for sharing. I happen to have one of these gampads trailing around somewhere. Off searching :-)
Greez
chris

Please Log in to join the conversation.

Time to create page: 0.668 seconds
Powered by Kunena Forum