Gentlemen, I have some of the Saitek joypad buttons working as I want. I would like to share the configuration logic. In my shop the operators can hardly wait to use the machine with a wireless game joypad. I will probably dismantle the joypad and use the joystick components in a more robust container. The joypad may last a while in the shop environment. If they last a few months I may just leave them as they are. New ones are $30.00.
This is the complete joypad file. # joypad.hal -- hal configuration file to move a cnc machine using a joypad # [JOG] # Components # We will use hal_joystick to read the axis value (float) for X Y Z, we will send these values to the # speed pin of a sim-encoder component, for X Y Z, this component outputs Phase-A and Phase-B signal, # just like a real quadrature rotary encoder. We will decode those signals with an encoder component for X Y Z # and will send the result counts value to the axis jog pin for X Y Z. # Load the hal_joystick component that creates joypad.axis.<n> and joypad.button.<n> pins loadusr hal_joystick -d /dev/input/js0 -p joypad # Load three encoder and three sim_encoder components #loadrt encoder num_chan=3 #loadrt sim_encoder num_chan=3 # Create links between the axis pins and the speed pin of the sim-encoder for X Y Z net velX joypad.axis.0 => sim-encoder.3.speed net velY joypad.axis.1 => sim-encoder.4.speed #net velZ joypad.axis.3 => sim-encoder.2.speed # Create links between sim-encoder Phase-A and Phase-B and encoder Phase-A and Phase-B for X Y Z net XA sim-encoder.3.phase-A => encoder.6.phase-A net XB sim-encoder.3.phase-B => encoder.6.phase-B net YA sim-encoder.4.phase-A => encoder.7.phase-A net YB sim-encoder.4.phase-B => encoder.7.phase-B #net ZA sim-encoder.2.phase-A => encoder.2.phase-A #net ZB sim-encoder.2.phase-B => encoder.2.phase-B # Create links between encoder counts and jog counts for X Y Z net countX encoder.6.counts => axis.0.jog-counts net countY encoder.7.counts => axis.1.jog-counts #net countZ encoder.2.counts => axis.2.jog-counts # Set parameter values setp encoder.6.position-scale 1 setp encoder.6.x4-mode TRUE setp encoder.7.position-scale 1 setp encoder.7.x4-mode TRUE #setp encoder.2.position-scale 1 #setp encoder.2.x4-mode TRUE setp encoder.capture-position.tmax 0 setp encoder.update-counters.tmax 0 setp sim-encoder.3.ppr 00000064 setp sim-encoder.3.scale 1 setp sim-encoder.4.ppr 00000064 setp sim-encoder.4.scale -1 #setp sim-encoder.2.ppr 00000064 #setp sim-encoder.2.scale 1 setp sim-encoder.make-pulses.tmax 0 setp sim-encoder.update-speed.tmax 0 # Enable jog for X Y Z setp axis.0.jog-enable TRUE setp axis.1.jog-enable TRUE # uncover setp to enable the Z axis jog joystick all the time # uncover net button6 to enable the Z axis by pushing button7 #setp axis.2.jog-enable TRUE #net button6 joypad.button.6 axis.2.jog-enable # Enable handwheel overrun elimination # This stops the machine as soon as the joystick is released # This is a very nice feature. setp axis.0.jog-vel-mode TRUE setp axis.1.jog-vel-mode TRUE setp axis.2.jog-vel-mode TRUE # Attach realtime functions to threads #addf encoder.capture-position servo-thread #addf sim-encoder.update-speed servo-thread #addf encoder.update-counters base-thread #addf sim-encoder.make-pulses base-thread #addf encoder.update-counters servo-thread #addf sim-encoder.make-pulses servo-thread # [BUTTON-EXAMPLES] # Scale button # set four buttons (1, 2, 3, and 4) to choose the jogscale value. # Pressing button 1 will set the scale to 0.0001 # Pressing button 2 will set the scale to 0.001 # Pressing button 3 will set the scale to 0.01 # Pressing button 4 will set the scale to 0.1 # # Components # use four or2's, two flipflops and a mux4 loadrt mux4 loadrt flipflop count=2 loadrt or2 count=4 # Links between buttons and and2's net button0 joypad.button.0 => or2.0.in0 net button0 joypad.button.0 => or2.1.in0 net button1 joypad.button.1 => or2.0.in1 net button1 joypad.button.1 => or2.2.in0 net button2 joypad.button.2 => or2.3.in0 net button2 joypad.button.2 => or2.1.in1 net button3 joypad.button.3 => or2.3.in1 net button3 joypad.button.3 => or2.2.in1 # Links between the or2's and the flipflop's net or2-0 or2.0.out flipflop.0.reset net or2-1 or2.1.out flipflop.1.set net or2-2 or2.2.out flipflop.1.reset net or2-3 or2.3.out flipflop.0.set # Links between the flipflop's and the mux4's net ff-1 flipflop.0.out mux4.0.sel0 net ff-2 flipflop.1.out mux4.0.sel1 # Link between the mux4 output and the jogscale pin for X Y Z net jogscale mux4.0.out => axis.0.jog-scale net jogscale mux4.0.out => axis.1.jog-scale #net jogscale mux4.0.out => axis.2.jog-scale # Set the four scale values setp mux4.0.in1 0.0001 setp mux4.0.in0 0.001 setp mux4.0.in3 0.01 setp mux4.0.in2 0.1 # Attach realtime functions to threads addf flipflop.0 servo-thread addf flipflop.1 servo-thread addf or2.0 servo-thread addf or2.1 servo-thread addf or2.2 servo-thread addf or2.3 servo-thread addf mux4.0 servo-thread # Flood button # Components # use a TOGGLE component and a NOT component # TOGGLE makes the button change state one and # only one time per button push. # at this time TOGGLE is only in the head release # The source is available in volume 12, issue 23 # It will probably work in any 2.1.x compiled version loadrt toggle loadrt not setp toggle.0.debounce 10 net button7 joypad.button.7 => toggle.0.in net floodOn toggle.0.out => halui.flood.on net floodOn toggle.0.out => not.0.in net floodOff not.0.out => halui.flood.off # Attach realtime functions to threads addf toggle.0 servo-thread addf not.0 servo-thread have fun thanks Stuart ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Emc-users mailing list Emc-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/emc-users