Lathe rotary encoder mesa 7i96s

More
4 years 1 month ago #251342 by Samuelx
I bought a rotary encoder for my emco lathe.
I connected it to 7i96s card
red wire ->  pin6 (+5VP)
black wire -> pin9 (GND)
green wire (SIGA) -> pin7 (ENCA+)
brown wire (SIGA/) -> pin8 (ENCA-)
white wire (SIGB) -> pin10 (ENCB)
gray wire (SIGB/) -> pin11 (ENCB-)
yellow wire (SIGZ) -> pin13 (IDX+)
orange wire (SIGZ/) -> pin 14 (IDX-)

Is this connection right?

How to modify my hal and ini files?
Code:
   # This file was created with the Mesa Configuration Tool on elo 15 2022 21:05:38 # If you make changes to this file DO NOT run the configuration tool again! # This file will be replaced with a new file if you do! # kinematics loadrt [KINS]KINEMATICS # motion controller loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[KINS]JOINTS  num_dio=10 # standard components loadrt pid num_chan=3  # hostmot2 driver loadrt hostmot2 loadrt [HM2](DRIVER) board_ip=[HM2](IPADDRESS)  setp hm2_7i96s.0.watchdog.timeout_ns 5000000 # THREADS addf hm2_7i96s.0.read servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf pid.0.do-pid-calcs servo-thread addf pid.1.do-pid-calcs servo-thread addf pid.2.do-pid-calcs servo-thread addf hm2_7i96s.0.write servo-thread # Joint 0 # PID Setup setp pid.0.Pgain [JOINT_0]P setp pid.0.Igain [JOINT_0]I setp pid.0.Dgain [JOINT_0]D setp pid.0.bias [JOINT_0]BIAS setp pid.0.FF0 [JOINT_0]FF0 setp pid.0.FF1 [JOINT_0]FF1 setp pid.0.FF2 [JOINT_0]FF2 setp pid.0.deadband [JOINT_0]DEADBAND setp pid.0.maxoutput [JOINT_0]MAX_OUTPUT setp pid.0.maxerror [JOINT_0]MAX_ERROR setp pid.0.error-previous-target true # joint enable chain net joint-0-index-enable <=> pid.0.index-enable net joint-0-enable <= joint.0.amp-enable-out net joint-0-enable => pid.0.enable net joint-0-enable => hm2_7i96s.0.stepgen.00.enable setp hm2_7i96s.0.stepgen.00.dirsetup [JOINT_0]DIRSETUP setp hm2_7i96s.0.stepgen.00.dirhold [JOINT_0]DIRHOLD setp hm2_7i96s.0.stepgen.00.steplen [JOINT_0]STEPLEN setp hm2_7i96s.0.stepgen.00.stepspace [JOINT_0]STEPSPACE setp hm2_7i96s.0.stepgen.00.position-scale [JOINT_0]SCALE setp hm2_7i96s.0.stepgen.00.maxvel [JOINT_0]STEPGEN_MAX_VEL setp hm2_7i96s.0.stepgen.00.maxaccel [JOINT_0]STEPGEN_MAX_ACC setp hm2_7i96s.0.stepgen.00.step_type 0 setp hm2_7i96s.0.stepgen.00.control-type 1 # position command and feedback net joint-0-pos-cmd <= joint.0.motor-pos-cmd net joint-0-pos-cmd => pid.0.command net joint-0-pos-fb <= hm2_7i96s.0.stepgen.00.position-fb net joint-0-pos-fb => joint.0.motor-pos-fb net joint-0-pos-fb => pid.0.feedback net joint.0.output <= pid.0.output net joint.0.output => hm2_7i96s.0.stepgen.00.velocity-cmd # Joint 1 # PID Setup setp pid.1.Pgain [JOINT_1]P setp pid.1.Igain [JOINT_1]I setp pid.1.Dgain [JOINT_1]D setp pid.1.bias [JOINT_1]BIAS setp pid.1.FF0 [JOINT_1]FF0 setp pid.1.FF1 [JOINT_1]FF1 setp pid.1.FF2 [JOINT_1]FF2 setp pid.1.deadband [JOINT_1]DEADBAND setp pid.1.maxoutput [JOINT_1]MAX_OUTPUT setp pid.1.maxerror [JOINT_1]MAX_ERROR setp pid.1.error-previous-target true # joint enable chain net joint-1-index-enable <=> pid.1.index-enable net joint-1-enable <= joint.1.amp-enable-out net joint-1-enable => pid.1.enable net joint-1-enable => hm2_7i96s.0.stepgen.01.enable setp hm2_7i96s.0.stepgen.01.dirsetup [JOINT_1]DIRSETUP setp hm2_7i96s.0.stepgen.01.dirhold [JOINT_1]DIRHOLD setp hm2_7i96s.0.stepgen.01.steplen [JOINT_1]STEPLEN setp hm2_7i96s.0.stepgen.01.stepspace [JOINT_1]STEPSPACE setp hm2_7i96s.0.stepgen.01.position-scale [JOINT_1]SCALE setp hm2_7i96s.0.stepgen.01.maxvel [JOINT_1]STEPGEN_MAX_VEL setp hm2_7i96s.0.stepgen.01.maxaccel [JOINT_1]STEPGEN_MAX_ACC setp hm2_7i96s.0.stepgen.01.step_type 0 setp hm2_7i96s.0.stepgen.01.control-type 1 # position command and feedback net joint-1-pos-cmd <= joint.1.motor-pos-cmd net joint-1-pos-cmd => pid.1.command net joint-1-pos-fb <= hm2_7i96s.0.stepgen.01.position-fb net joint-1-pos-fb => joint.1.motor-pos-fb net joint-1-pos-fb => pid.1.feedback net joint.1.output <= pid.1.output net joint.1.output => hm2_7i96s.0.stepgen.01.velocity-cmd # Spindle # Spindle Velocity Pins net spindle-vel-cmd-rps <=  spindle.0.speed-out-rps net spindle-vel-cmd-rps-abs <= spindle.0.speed-out-rps-abs net spindle-vel-cmd-rpm <= spindle.0.speed-out net spindle-vel-cmd-rpm-abs <= spindle.0.speed-out-abs # Spindle Command Pins net spindle-enable <= spindle.0.on net spindle-cw <= spindle.0.forward net spindle-ccw <= spindle.0.reverse net spindle-brake <= spindle.0.brake net spindle-revs => spindle.0.revs net spindle-at-speed => spindle.0.at-speed net spindle-vel-fb-rps => spindle.0.speed-in net spindle-index-enable => spindle.0.index-enable # Set spindle at speed signal sets spindle-at-speed true # Spindle Board Connections net spindle-enable => hm2_7i96s.0.pwmgen.00.enable net spindle-vel-cmd-rpm hm2_7i96s.0.pwmgen.00.value setp hm2_7i96s.0.pwmgen.00.scale [SPINDLE]MAX_RPM setp hm2_7i96s.0.pwmgen.pwm_frequency [SPINDLE]PWM_FREQUENCY setp hm2_7i96s.0.pwmgen.00.output-type [SPINDLE]SPINDLE_PWM_TYPE #  Manual Tool Change Dialog nama 5 rivia tuli mesacttlta #loadusr -W hal_manualtoolchange #net tool-change-request    =>  hal_manualtoolchange.change #net tool-change-confirmed  <=  hal_manualtoolchange.changed #net tool-number            =>  hal_manualtoolchange.number #  ---toolchange signals for custom tool changer---nama on kopioitu net tool-number             <=  iocontrol.0.tool-prep-number net tool-change-request     <=  iocontrol.0.tool-change net tool-change-confirmed   =>  iocontrol.0.tool-changed net tool-prepare-request    <=  iocontrol.0.tool-prepare net tool-prepare-confirmed  =>  iocontrol.0.tool-prepared # create signals for tool loading loopback nama teki mesact #net tool-prep-loop iocontrol.0.tool-prepare => iocontrol.0.tool-prepared #net tool-change-loop iocontrol.0.tool-change => iocontrol.0.tool-changed # # Load Classicladder without GUI nama 3 rivit teki mesact loadrt classicladder_rt addf classicladder.0.refresh servo-thread 1 # Load Classicladder without GUI (can reload LADDER GUI in AXIS GUI loadusr classicladder --nogui custom.clp    [code]# This file was created with the Mesa Configuration Tool on elo 15 2022 21:05:38 # Changes to most things are ok and will be read by the Configuration Tool [MESA] VERSION = 0.7.0 BOARD = 7i96s FIRMWARE = 7i96s_d.bin CARD_0 = None CARD_1 = None [EMC] VERSION = 1.1 MACHINE = Emco 50 PC turn mesact DEBUG = 0x00000000 [HM2] DRIVER = hm2_eth IPADDRESS = 10.10.10.10 STEPGENS = False PWMGENS = False ENCODERS = False [DISPLAY] DISPLAY = gmoccapy EDITOR = gedit PROGRAM_PREFIX = /home/samuel/linuxcnc/nc_files POSITION_OFFSET = RELATIVE POSITION_FEEDBACK = COMMANDED MAX_FEED_OVERRIDE = 1.2 MIN_VELOCITY = 0.0 DEFAULT_LINEAR_VELOCITY = 2.1 MAX_LINEAR_VELOCITY = 6.8 CYCLE_TIME = 0.1 INTRO_GRAPHIC = emc2.gif INTRO_TIME = 0 OPEN_FILE = "" LATHE = 1 BACK_TOOL_LATHE = 1 [KINS] KINEMATICS = trivkins coordinates=ZX JOINTS = 2 [EMCIO] EMCIO = iov2 CYCLE_TIME = 0.100 TOOL_TABLE = tool.tbl [RS274NGC] PARAMETER_FILE = emco_50_pc_turn_mesact.var SUBROUTINE_PATH = /home/samuel/linuxcnc/subroutines [EMCMOT] EMCMOT = motmod COMM_TIMEOUT = 1.0 SERVO_PERIOD = 1000000 [TASK] TASK = milltask CYCLE_TIME = 0.010 [TRAJ] COORDINATES = ZX LINEAR_UNITS = mm ANGULAR_UNITS = degree MAX_LINEAR_VELOCITY = 6.8 NO_FORCE_HOMING = 1 [APPLICATIONS] APP = monitor-xhc-hb04 [HAL] HALFILE = emco_50_pc_turn_mesact.hal HALFILE = io.hal HALFILE = custom.hal HALFILE = LIB:xhc-hb04.tcl HALUI = halui [HALUI] MDI_COMMAND = g0 x0 z0 MDI_COMMAND = halui.estop.activate MDI_COMMAND = halui.machine.on MDI_COMMAND= G10 L20 P0 Z0.004 MDI_COMMAND= G10 L20 P0 X[#<_x>/2.0] MDI_COMMAND= G10 L20 P0 Z[#<_z>/2.0 MDI_COMMAND= g0 x0 z0 MDI_COMMAND= "" MDI_COMMAND= "" MDI_COMMAND= "" MDI_COMMAND= "" MDI_COMMAND= "" MDI_COMMAND= G10 L20 P1 X0 MDI_COMMAND= "" MDI_COMMAND= G10 L20 P1 Z0 MDI_COMMAND= "" MDI_COMMAND= "" MDI_COMMAND= ""   [AXIS_Z] MIN_LIMIT = -1 MAX_LIMIT = 236 MAX_VELOCITY = 10 MAX_ACCELERATION = 350 [AXIS_X] MIN_LIMIT = -66.0 MAX_LIMIT = 10.0 MAX_VELOCITY = 10 MAX_ACCELERATION = 250 [JOINT_0] AXIS = Z MIN_LIMIT = -26 MAX_LIMIT = 236 MAX_VELOCITY = 10 MAX_ACCELERATION = 350 TYPE = LINEAR SCALE = 1600 DRIVE = Custom STEP_INVERT = False DIR_INVERT = False STEPGEN_MAX_VEL = 12.00 STEPGEN_MAX_ACC = 420.00 DIRSETUP = 20000 DIRHOLD = 20000 STEPLEN = 20000 STEPSPACE = 20000 FERROR = 0.005 MIN_FERROR = 0.0025 DEADBAND = 0 BACKFLASH = 0 P = 1000 I = 0 D = 0 FF0 = 0 FF1 = 1 FF2 = 0 BIAS = 0 MAX_OUTPUT = 0 MAX_ERROR = 0.000127 HOME_OFFSET = 0 HOME_SEARCH_VEL = -8 HOME_LATCH_VEL = -0.1 HOME_FINAL_VEL = 0.000000 HOME_IGNORE_LIMITS = YES HOME_USE_INDEX = YES HOME_INDEX_NO_ENCODER_RESET = YES HOME_SEQUENCE = 1 [JOINT_1] AXIS = X MIN_LIMIT = -66.0 MAX_LIMIT = 10.0 MAX_VELOCITY = 10 MAX_ACCELERATION = 250 TYPE = LINEAR SCALE = 1600 DRIVE = Custom STEP_INVERT = False DIR_INVERT = False STEPGEN_MAX_VEL = 12.00 STEPGEN_MAX_ACC = 300.00 DIRSETUP = 20000 DIRHOLD = 20000 STEPLEN = 20000 STEPSPACE = 20000 FERROR = 0.005 MIN_FERROR = 0.0025 DEADBAND = 0 BACKFLASH = 0.02 P = 1000 I = 0 D = 0 FF0 = 0 FF1 = 1 FF2 = 0 BIAS = 0 MAX_OUTPUT = 0 MAX_ERROR = 0.000127 HOME_OFFSET = 0 HOME_IGNORE_LIMITS = False HOME_SEARCH_VEL = 2 HOME_LATCH_VEL = 0.05 HOME_FINAL_VEL = 0.000000 HOME_USE_INDEX = YES HOME_INDEX_NO_ENCODER_RESET = YES HOME_SEQUENCE = 1 [SPINDLE] SPINDLE_TYPE = analog SPINDLE_PWM_TYPE = 1 PWM_FREQUENCY = 10000 MAX_RPM = 1600 MIN_RPM = 0 FEEDBACK = encoder ENCODER_SCALE = 1024.0 [XHC_HB04_CONFIG]   # specify layout = n for xhc-hb04-layout{n}.cfg files layout = 2   # coords: specify 4 letters   # coords: switch labels are xyza but any unique 4 letters   #         from the set {xyxabcuvw) can be used (if the coord exists) coords = x z   # lowpass settings:   # coef: slows rate of change of output,  range: 0 < coef < 1 coefs = 1 1    # scale plus or minus, rotaries may require larger scale factor: scales = 1 1    # jogmode normal(default) or vnormal jogmode = normal   # accels for jog wheel, set to something a bit less than your max axis accel mpg_accels = 50 50 50   # sequence 1: 0.001,0.010,0.100 (mm-based machine)   # sequence 2: 0.001,0.005,0.010 (inch-based machine) sequence = 1   # require_pendant = no: create xhc-hb04 hal pins when pendant not connecte   #                       at startup require_pendant = yes [XHC_HB04_BUTTONS]   # use button names according to layout file xhc-hb04-layout{n}.cfg   # note: "start-pause" is connected for standard behavior   #        controlling halui.pause/halui.resume/halui.run   # these are examples, edit as required: goto-zero-x   = "" goto-zero-z   = "" start-pause = std_start_pause rewind      = halui.program.step   # probe-input for simulating a probe, [   # note: not compatible with the pncconf generated HAL files. uncomment to enable.   # probe-z     = motion.probe-input macro-3     = halui.mdi-command-03 half        = halui.spindle.0.stop half-x    = halui.mdi-command-04 half-z    = halui.mdi-command-05 zero        = "" zero-x    = halui.mdi-command-12 zero-z    = halui.mdi-command-14 safe-z      = halui.mdi-command-10   # in this sim, home-all only works first time, hold down till finished: home        = halui.home-all macro-1     = halui.mdi-command-01 macro-2     = halui.mdi-command-02 spindle     = halui.spindle.0.start step        = xhc-hb04.stepsize-up mode        = "" macro-6     = halui.mdi-command-06 #z and x goto zero macro-7     = halui.mdi-command-07 stop        = halui.program.stop reset       = halui.estop.activate # Everything below this line is only used to # setup the Configuration Tool when loading the ini. [INPUTS] # DO NOT change the inputs they are used by the configuration tool INPUT_0 = Joint 0 Home INPUT_INVERT_0 = False INPUT_SLOW_0 = False INPUT_1 = Joint 1 Home INPUT_INVERT_1 = True INPUT_SLOW_1 = False INPUT_2 = External E Stop INPUT_INVERT_2 = True INPUT_SLOW_2 = False INPUT_3 = Select INPUT_INVERT_3 = False INPUT_SLOW_3 = False INPUT_4 = Select INPUT_INVERT_4 = False INPUT_SLOW_4 = False INPUT_5 = Select INPUT_INVERT_5 = False INPUT_SLOW_5 = False INPUT_6 = Select INPUT_INVERT_6 = False INPUT_SLOW_6 = False INPUT_7 = Select INPUT_INVERT_7 = False INPUT_SLOW_7 = False INPUT_8 = Select INPUT_INVERT_8 = False INPUT_SLOW_8 = False INPUT_9 = Select INPUT_INVERT_9 = False INPUT_SLOW_9 = False INPUT_10 = Select INPUT_INVERT_10 = False INPUT_SLOW_10 = False INPUT_11 = Select INPUT_INVERT_11 = False INPUT_SLOW_11 = False INPUT_12 = Select INPUT_INVERT_12 = False INPUT_SLOW_12 = False INPUT_13 = Select INPUT_INVERT_13 = False INPUT_SLOW_13 = False INPUT_14 = Select INPUT_INVERT_14 = False INPUT_SLOW_14 = False INPUT_15 = Select INPUT_INVERT_15 = False INPUT_SLOW_15 = False INPUT_16 = Select INPUT_INVERT_16 = False INPUT_SLOW_16 = False INPUT_17 = Select INPUT_INVERT_17 = False INPUT_SLOW_17 = False INPUT_18 = Select INPUT_INVERT_18 = False INPUT_SLOW_18 = False INPUT_19 = Select INPUT_INVERT_19 = False INPUT_SLOW_19 = False INPUT_20 = Select INPUT_INVERT_20 = False INPUT_SLOW_20 = False INPUT_21 = Select INPUT_INVERT_21 = False INPUT_SLOW_21 = False INPUT_22 = Select INPUT_INVERT_22 = False INPUT_SLOW_22 = False INPUT_23 = Select INPUT_INVERT_23 = False INPUT_SLOW_23 = False INPUT_24 = Select INPUT_INVERT_24 = False INPUT_SLOW_24 = False INPUT_25 = Select INPUT_INVERT_25 = False INPUT_SLOW_25 = False INPUT_26 = Select INPUT_INVERT_26 = False INPUT_SLOW_26 = False INPUT_27 = Select INPUT_INVERT_27 = False INPUT_SLOW_27 = False INPUT_28 = Select INPUT_INVERT_28 = False INPUT_SLOW_28 = False INPUT_29 = Select INPUT_INVERT_29 = False INPUT_SLOW_29 = False INPUT_30 = Select INPUT_INVERT_30 = False INPUT_SLOW_30 = False INPUT_31 = Select INPUT_INVERT_31 = False INPUT_SLOW_31 = False [OUTPUTS] # DO NOT change the outputs they are used by the configuration tool OUTPUT_0 = Spindle CW OUTPUT_1 = Spindle CCW OUTPUT_2 = Spindle On OUTPUT_3 = Select OUTPUT_4 = Select OUTPUT_5 = Select OUTPUT_6 = Select OUTPUT_7 = Select OUTPUT_8 = Select OUTPUT_9 = Select OUTPUT_10 = Select OUTPUT_11 = Select OUTPUT_12 = Select OUTPUT_13 = Select OUTPUT_14 = Select OUTPUT_15 = Select [OPTIONS] # DO NOT change the options they are used by the configuration tool LOAD_CONFIG = False INTRO_GRAPHIC = emc2.gif INTRO_GRAPHIC_TIME = 0 MANUAL_TOOL_CHANGE = True CUSTOM_HAL = True POST_GUI_HAL = False SHUTDOWN_HAL = False HALUI = False PYVCP = False GLADEVCP = False LADDER = True BACKUP = False [code] # This file was created with the 7i92 Wizard on elo 15 2022 21:05:38 # If you make changes to this file DO NOT use the Configuration Tool loadrt encoder addf encoder.capture-position servo-thread addf encoder.update-counters servo-thread # home  and limit pins net joint-0-home joint.0.home-sw-in <=  hm2_7i96s.0.inm.00.input-00 net z-home-prox hm2_7i96s.0.inm.00.input-06 encoder.0.phase-Z net z-home-index-enables joint.0.index-enable encoder.0.index-enable net z-is-homed     halui.joint.0.is-homed net z-neg-limit     =>  joint.0.neg-lim-sw-in net z-pos-limit     =>  joint.0.pos-lim-sw-in net joint-1-home joint.1.home-sw-in <=  hm2_7i96s.0.inm.00.input-01-not net x-home-prox hm2_7i96s.0.inm.00.input-07 encoder.1.phase-Z net x-home-index-enables joint.1.index-enable encoder.1.index-enable net x-is-homed     halui.joint.1.is-homed net x-neg-limit     =>  joint.1.neg-lim-sw-in net x-pos-limit     =>  joint.1.pos-lim-sw-in # External E-Stop loadrt estop_latch addf estop-latch.0 servo-thread net estop-loopout iocontrol.0.emc-enable-in <= estop-latch.0.ok-out net estop-loopin iocontrol.0.user-enable-out => estop-latch.0.ok-in net estop-reset iocontrol.0.user-request-enable => estop-latch.0.reset net remote-estop estop-latch.0.fault-in <= hm2_7i96s.0.inm.00.input-02-not # Spindle pins net spindle-cw spindle.0.forward => hm2_7i96s.0.ssr.00.out-00 net spindle-ccw spindle.0.reverse => hm2_7i96s.0.ssr.00.out-01 net spindle-enable => hm2_7i96s.0.ssr.00.out-02
[/code][/code]

Please Log in to join the conversation.

More
4 years 1 month ago #251344 by Samuelx
Is this anything close to be right if I add this to hal file?

# ---Encoder feedback signals/setup---

setp hm2_7i96s.0.encoder.00.counter-mode 1
setp hm2_7i96s.0.encoder.00.filter 1
setp hm2_7i96s.0.encoder.00.index-invert 0
setp hm2_7i96s.0.encoder.00.index-mask 0
setp hm2_7i96s.0.encoder.00.index-mask-invert 0
setp hm2_7i96s.0.encoder.00.scale [SPINDLE_0]ENCODER_SCALE

net spindle-revs <= hm2_7i96s.0.encoder.00.position
net spindle-vel-fb-rps <= hm2_7i96s.0.encoder.00.velocity
net spindle-vel-fb-rpm <= hm2_7i96s.0.encoder.00.velocity-rpm
net spindle-index-enable <=> hm2_7i96s.0.encoder.00.index-enable

Please Log in to join the conversation.

More
4 years 1 month ago #251349 by PCW
Replied by PCW on topic Lathe rotary encoder mesa 7i96s
setp hm2_7i96s.0.encoder.00.counter-mode 1

is wrong (counter mode is for non-quadrature (or 'A' only encoders)

also, these signals:

net spindle-revs <= hm2_7i96s.0.encoder.00.position
net spindle-vel-fb-rps <= hm2_7i96s.0.encoder.00.velocity
net spindle-vel-fb-rpm <= hm2_7i96s.0.encoder.00.velocity-rpm
net spindle-index-enable <=> hm2_7i96s.0.encoder.00.index-enable

Need to connect to the appropriate LinuxCNC spindle pins

Please Log in to join the conversation.

Time to create page: 0.745 seconds
Powered by Kunena Forum