The driver correctly synthesizes pins (and associated logic) for 'goto-zero', '=1/2' and 'zero' buttons, in addition to creating pins for the physical pendant buttons (independent of rotary switch selection). 'xhc-hb04.tcl' creates nets as appropriate, but this leads for instance to simultaneous 'stop spindle' and 'half-x' commands (for the attached illustrative INI config), when the '=1/2' button is pressed with rotary switch in 'x' position (as 'watch' of the associated button HAL pins confirms).

It is suggested that the driver should be enhanced with additional logic to inhibit the three default (physical, non-synthesized) button functions when the rotary switch is not in the 'off' position.

See also comments in stanza [XHC_HB04_BUTTONS] of attached INI file.

The attached proposed (as yet untested) code fragment to replace lines 450 - 474 of linuxcnc/src/hal/user_comps/xhc-hb04.cc indicates the enhancement should require only minor code changes to the XHC-HB04 HAL User Component.

Existing code (with comments inserted) included in attached xhc-hb04 user_comp_lines_450_474.txt.

                for (i=0; i<NB_MAX_BUTTONS; i++) {
                        if (!xhc.hal->button_pin[i]) continue;
                                                     /* Now assert HAL pin for 
physical button pressed */
                        *(xhc.hal->button_pin[i]) = (xhc.button_code == 
xhc.buttons[i].code);
                                          /* in addition to HAL pin for 
appropriate synthesized button */
            if (strcmp("button-zero", xhc.buttons[i].pin_name) == 0) {
               *(xhc.hal->zero_x) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_x);
               *(xhc.hal->zero_y) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_y);
               *(xhc.hal->zero_z) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_z);
               *(xhc.hal->zero_a) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_a);
            }
            if (strcmp("button-goto-zero", xhc.buttons[i].pin_name) == 0) {
               *(xhc.hal->gotozero_x) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_x);
               *(xhc.hal->gotozero_y) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_y);
               *(xhc.hal->gotozero_z) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_z);
               *(xhc.hal->gotozero_a) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_a);
            }
            if (strcmp("button-half", xhc.buttons[i].pin_name) == 0) {
               *(xhc.hal->half_x) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_x);
               *(xhc.hal->half_y) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_y);
               *(xhc.hal->half_z) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_z);
               *(xhc.hal->half_a) = (xhc.button_code == xhc.buttons[i].code) && 
(xhc.axis == axis_a);
            }
                        if (simu_mode && *(xhc.hal->button_pin[i])) {
                                printf("%s pressed", xhc.buttons[i].pin_name);
                        }
                }
        for (i=0; i<NB_MAX_BUTTONS; i++) {
            if (!xhc.hal->button_pin[i]) continue;
                                                     /* Now assert HAL pin for 
physical button pressed */
            *(xhc.hal->button_pin[i]) = (xhc.button_code == 
xhc.buttons[i].code);
            if (strcmp("button-zero", xhc.buttons[i].pin_name) == 0) {
                      /* In event of synthesized button, de-assert HAL pin for 
physical button pressed */
                                         /* and assert only HAL pin for 
appropriate synthesized button */
                if (xhc.axis != axis_off) {
                   *(xhc.hal->button_pin[i] = 0;
                   *(xhc.hal->zero_x) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_x);
                   *(xhc.hal->zero_y) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_y);
                   *(xhc.hal->zero_z) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_z);
                   *(xhc.hal->zero_a) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_a);
                }
            }
            if (strcmp("button-goto-zero", xhc.buttons[i].pin_name) == 0) {
                if (xhc.axis != axis_off) {
                   *(xhc.hal->button_pin[i] = 0;
                   *(xhc.hal->gotozero_x) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_x);
                   *(xhc.hal->gotozero_y) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_y);
                   *(xhc.hal->gotozero_z) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_z);
                   *(xhc.hal->gotozero_a) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_a);
                }
            }
            if (strcmp("button-half", xhc.buttons[i].pin_name) == 0) {
                if (xhc.axis != axis_off) {
                   *(xhc.hal->button_pin[i] = 0;
                   *(xhc.hal->half_x) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_x);
                   *(xhc.hal->half_y) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_y);
                   *(xhc.hal->half_z) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_z);
                   *(xhc.hal->half_a) = (xhc.button_code == 
xhc.buttons[i].code) && (xhc.axis == axis_a);
                }
            }
                        if (simu_mode && *(xhc.hal->button_pin[i])) {
                                printf("%s pressed", xhc.buttons[i].pin_name);
                        }
        }
[EMC]
VERSION = 1.0
MACHINE = Paracreo-XHC-HB04
# Debug level, 0 means no messages. See src/emc/nml_intf/debugflags.h for others
DEBUG = 0

[DISPLAY]
DISPLAY = axis
CYCLE_TIME = 0.10
POSITION_OFFSET = RELATIVE
POSITION_FEEDBACK = ACTUAL
PROGRAM_PREFIX = ../../nc_files/
INTRO_GRAPHIC = linuxcnc.gif
INTRO_TIME = 2.5
PYVCP = spindle.xml

# list of selectable jog increments
INCREMENTS = 5.0mm, 1.0mm, 0.1mm, 0.01mm, 0.001mm

# Highest value that will be allowed for feed override, 1.0 = 100%
MAX_SPINDLE_OVERRIDE =  1.25
MIN_SPINDLE_OVERRIDE = .25
MAX_FEED_OVERRIDE = 1.5

[FILTER]
PROGRAM_EXTENSION = .png,.gif,.jpg Grayscale Depth Image
PROGRAM_EXTENSION = .py Python Script
png = image-to-gcode
gif = image-to-gcode
jpg = image-to-gcode
py = python

[TASK]
TASK = milltask
CYCLE_TIME = 0.001

# Task controller section -----------------------------------------------------
[RS274NGC]
RS274NGC_STARTUP_CODE = G17 G21 G40 G43H0 G64P0.005 G80 G90 G94 G97 M5 M9
PARAMETER_FILE = paracreo_router.var
#SUBROUTINE_PATH = ../../macros

[EMCMOT]
EMCMOT=motmod
COMM_TIMEOUT = 1.0
# Base period used only for charge pump 1kHz pulse generation
BASE_PERIOD = 90000
SERVO_PERIOD = 1000000

[HAL]
HALFILE = gantry_XHC-HB04.hal
HALFILE = LIB:xhc-hb04.tcl
HALUI = halui

# Single file that is executed after the GUI has started
POSTGUI_HALFILE = spindle_to_pyvcp.hal

[KINS]
KINEMATICS = trivkins coordinates=xyyz kinstype=BOTH
JOINTS = 4

[TRAJ]
COORDINATES = X Y Y Z
LINEAR_UNITS = mm
ANGULAR_UNITS = degree
DEFAULT_LINEAR_VELOCITY = 250
MAX_LINEAR_VELOCITY = 400
DEFAULT_LINEAR_ACCEL = 250
MAX_LINEAR_ACCEL = 500
NO_FORCE_HOMING = 1

[EMCIO]
EMCIO = io
CYCLE_TIME = 0.10
TOOL_TABLE = tool.tbl

[JOINT_0]
TYPE = LINEAR
FERROR = 5.0
MIN_FERROR = 1.0
MAX_VELOCITY = 400
MAX_ACCELERATION = 600
STEPGEN_MAX_VELOCITY = 450
STEPGEN_MAX_ACCELERATION = 850
# these are in nanoseconds
DIRSETUP   = 2000
DIRHOLD    = 2000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = -115.749
# Large minimum limit to allow jogging to home position at start-up
MIN_LIMIT = -55.0
MAX_LIMIT = 1800.0
HOME = 0.0
HOME_OFFSET = 0.0
HOME_SEARCH_VEL = 0
# Above set to zero => no home switch
HOME_LATCH_VEL = 0
# Joint 0 is last to be homed
HOME_SEQUENCE = 2

[AXIS_X]
MAX_VELOCITY = 400
MAX_ACCELERATION = 500
MIN_LIMIT = -55.0
MAX_LIMIT = 1800.0

[JOINT_1]
TYPE = LINEAR
FERROR = 5.0
MIN_FERROR = 1.0
MAX_VELOCITY = 300
MAX_ACCELERATION = 400
STEPGEN_MAX_VELOCITY = 350
STEPGEN_MAX_ACCELERATION = 450
# these are in nanoseconds
DIRSETUP   = 2000
DIRHOLD    = 2000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = -115.749
# Large minimum limit to allow jogging to home position at start-up
MIN_LIMIT = -200
MAX_LIMIT = 2800
HOME = 0.0
HOME_OFFSET = -200.0
HOME_SEARCH_VEL = 0
# Above set to zero => no home switch
HOME_LATCH_VEL = 0
HOME_SEQUENCE = -1

[JOINT_2]
TYPE = LINEAR
FERROR = 5.0
MIN_FERROR = 1.0
MAX_VELOCITY = 300
MAX_ACCELERATION = 400
STEPGEN_MAX_VELOCITY = 350
STEPGEN_MAX_ACCELERATION = 450
# these are in nanoseconds
DIRSETUP   = 2000
DIRHOLD    = 2000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = +115.749
# Large minimum limit to allow jogging to home position at start-up
MIN_LIMIT = -200
MAX_LIMIT = 2800
HOME = 0.0
HOME_OFFSET = -200.0
HOME_SEARCH_VEL = 0
# Above set to zero => no home switch
HOME_LATCH_VEL = 0
# Homing of Joints 1 & 2 is synchronised
HOME_SEQUENCE = -1

[AXIS_Y]
MAX_VELOCITY = 300
MAX_ACCELERATION = 400
MIN_LIMIT = -200
MAX_LIMIT = 2800

[JOINT_3]
TYPE = LINEAR
FERROR = 5.0
MIN_FERROR = 1.0
MAX_VELOCITY = 125
MAX_ACCELERATION = 250
STEPGEN_MAX_VELOCITY = 150
STEPGEN_MAX_ACCELERATION = 275
# these are in nanoseconds
DIRSETUP   = 2000
DIRHOLD    = 2000
STEPLEN    = 5000
STEPSPACE  = 5000
STEP_SCALE = 400
# Large minimum limit to allow jogging to home position at start-up
MIN_LIMIT = -25.0
MAX_LIMIT = 230
HOME = 50.0
HOME_OFFSET = 50.0
HOME_SEARCH_VEL = 0
# Above set to zero => no home switch
HOME_LATCH_VEL = 0
# Joint 0 is homed first
HOME_SEQUENCE = 0

[AXIS_Z]
MAX_VELOCITY = 125
MAX_ACCELERATION = 250
MIN_LIMIT = -25.0
MAX_LIMIT = 230

#********************
# Spindle 
#********************
[SPINDLE]
MAX_SPINDLE_SPEED = 20000.0
RAMP_RATE = 1500.0
NEAR_SCALE = 0.995

#********************
[XHC_HB04_CONFIG]
#********************
layout = 2
coords = x y z
# lowpass settings:
# coef: slows rate of change of output,  range: 0 < coef < 1
coefs = 0.1 0.1 0.1
# scale plus or minus, rotaries may require larger scale factor:
scales = 1 1 1
# jogmode normal(default) or vnormal
jogmode = vnormal
# sequence 1: 0.001,0.010,0.100,1.000 (mm-based machine)
sequence = 1
# require_pendant = yes|no: create xhc-hb04 hal pins when pendant not
#                           connected at startup
require_pendant = no
# inch_or_mm = in | mm
inch_or_mm = mm
# mpg_accels: provision for reduced acceleration for manual mode jogging
mpg_accels = 200 200 150

[XHC_HB04_BUTTONS]
# note: "start-pause" is connected for standard behavior
#        controlling halui.pause/halui.resume/halui.run

reset       = halui.estop.activate
stop        = halui.program.stop

# 'Go to Zero' config: NOP unless specific axis selected ('A' => X, Y & Z)
# XHC-HB04 driver anomaly: Goto Zero all axes should be inhibited if specific 
axis selected,
# thus next line commented out:
#goto-zero = halui.mdi-command-00
# Synthesized per-axis buttons for goto-zero button:
goto-zero-x = halui.mdi-command-08
goto-zero-y = halui.mdi-command-09
goto-zero-z = halui.mdi-command-10
# "a" signifies all in this config
goto-zero-a = halui.mdi-command-11

start-pause = std_start_pause
rewind      = halui.program.step

# probe-input for simulating a probe
probe-z     = motion.probe-input
spindle     = halui.spindle.start

# XHC-HB04 driver anomaly: '=1/2' button always stops spindle; should be 
ineffective
# when synthesized axis function selected by rotary switch:
half        = halui.spindle.stop

# Synthesized per-axis buttons for '=1/2" button:
half-x      = halui.mdi-command-04
half-y      = halui.mdi-command-05
half-z      = ""

# 'Zero' button effective only when specific axis selected
zero        = ""
# synthesized per-axis buttons for zero button:
zero-x      = halui.mdi-command-12
zero-y      = halui.mdi-command-13
zero-z      = halui.mdi-command-14

safe-z      = halui.mdi-command-15

home        = halui.home-all

macro-1     = halui.mdi-command-01
macro-2     = halui.mdi-command-02
macro-3     = halui.mdi-command-03

step        = xhc-hb04.stepsize-up
# No function assigned to 'Mode' button
mode        = ""

# Manual toolchange Z-touch-off:
macro-6     = halui.mdi-command-06

# Park for shutdown
macro-7     = halui.mdi-command-07

[APPLICATIONS]
APP = xhc-hb04-accels
APP = monitor-xhc-hb04

[HALUI]
# Three mdi commands (1-3) available for customisation
# HAL pin is created for each MDI_COMMAND below
#0
MDI_COMMAND=G0 X0 Y0 Z50
#1
MDI_COMMAND=(debug, example: mdi-01)
#2
MDI_COMMAND=(debug, example: mdi-02)
#3
MDI_COMMAND=(debug, example: mdi-03)
#4
MDI_COMMAND=G0 X[#<_x>/2.0]
#5
MDI_COMMAND=G0 Y[#<_y>/2.0]
#6
MDI_COMMAND=G10 L20 P1 Z50 (Manual toolchange Z-touch-off)
#7
MDI_COMMAND=G0 X0 Y-200 Z50 (Park for shutdown)
#8
MDI_COMMAND=G0 X0
#9
MDI_COMMAND=G0 Y0
#10
MDI_COMMAND=G0 Z30
#11
MDI_COMMAND=G0 X0 Y0 Z50
#12
MDI_COMMAND= G10 L20 P1 X0
#13
MDI_COMMAND= G10 L20 P1 Y0
#14
MDI_COMMAND= G10 L20 P1 Z0
#15
MDI_COMMAND=G0 Z120

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Emc-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/emc-users

Reply via email to