5i25+7i76 Spindle and Encoder Setup

More
13 years 1 month ago #39344 by Bad_German
Hi, I've been stuck on this for a wile and cannot get the lathe spindle and encoder working correctly.

1. The spindle analogue output (0-10V) works with Sxxx M3 command but not with a M4, CCW.
The enable and direction optocoupler outputs work, I just don't get any analogue output on SPINDLE OUT pin with an M4 command.

2. I have no feedback from the encoder, it is a 360ppr + index, non-quadrature encoder which I don't know how to setup.
PNCConf has already set "setp hm2_5i25.0.encoder.00.counter-mode 1", and I can't figure out what to change, to show the speed in the PYVCP.
In halscope "spindle-vel-fb" is also always zero.

Can you please point me in the right direction, to fix these 2 problems?

My Setup:
meas 5i25+7i76
Linuxcnc 2.5.3
Spindle Control: 0-10V, direction, enable
Encoder: 5V 360ppr (channel A) + index.


Hall:
Code:
# Generated by PNCconf at Sun Sep 29 12:26:37 2013 # If you make changes to this file, they will be # overwritten when you run PNCconf again loadrt trivkins loadrt [EMCMOT]EMCMOT servo_period_nsec=[EMCMOT]SERVO_PERIOD num_joints=[TRAJ]AXES loadrt probe_parport loadrt hostmot2 loadrt hm2_pci config=" num_encoders=1 num_pwmgens=0 num_3pwmgens=0 num_stepgens=2 sserial_port_0=00xxxxxx " setp hm2_5i25.0.watchdog.timeout_ns 10000000 loadrt hal_parport cfg="0x0378 out" loadrt pid names=pid.s loadrt abs names=abs.spindle loadrt lowpass names=lowpass.spindle loadrt scale names=scale.spindle addf parport.0.read servo-thread addf parport.0.write servo-thread addf hm2_5i25.0.read servo-thread addf motion-command-handler servo-thread addf motion-controller servo-thread addf pid.s.do-pid-calcs servo-thread addf abs.spindle servo-thread addf scale.spindle servo-thread addf lowpass.spindle servo-thread addf hm2_5i25.0.write servo-thread addf hm2_5i25.0.pet_watchdog servo-thread # external output signals # --- MACHINE-IS-ENABLED --- net machine-is-enabled parport.0.pin-01-out # --- COOLANT-FLOOD --- net coolant-flood parport.0.pin-09-out # external input signals # --- MIN-X --- net min-x <= hm2_5i25.0.7i76.0.0.input-00-not # --- MIN-Z --- net min-z <= hm2_5i25.0.7i76.0.0.input-01-not # --- MAX-HOME-X --- net max-home-x <= hm2_5i25.0.7i76.0.0.input-02-not # --- MAX-HOME-Z --- net max-home-z <= hm2_5i25.0.7i76.0.0.input-03-not # --- ESTOP-EXT --- net estop-ext <= parport.0.pin-15-in-not #******************* # AXIS X #******************* # Step Gen signals/setup setp hm2_5i25.0.stepgen.00.dirsetup [AXIS_0]DIRSETUP setp hm2_5i25.0.stepgen.00.dirhold [AXIS_0]DIRHOLD setp hm2_5i25.0.stepgen.00.steplen [AXIS_0]STEPLEN setp hm2_5i25.0.stepgen.00.stepspace [AXIS_0]STEPSPACE setp hm2_5i25.0.stepgen.00.position-scale [AXIS_0]STEP_SCALE setp hm2_5i25.0.stepgen.00.step_type 0 setp hm2_5i25.0.stepgen.00.control-type 0 setp hm2_5i25.0.stepgen.00.maxaccel 62.5 setp hm2_5i25.0.stepgen.00.maxvel 16.7 net x-pos-fb axis.0.motor-pos-fb <= hm2_5i25.0.stepgen.00.position-fb net x-pos-cmd axis.0.motor-pos-cmd => hm2_5i25.0.stepgen.00.position-cmd net x-enable axis.0.amp-enable-out => hm2_5i25.0.stepgen.00.enable # ---setup home / limit switch signals--- net max-home-x => axis.0.home-sw-in net min-x => axis.0.neg-lim-sw-in net max-home-x => axis.0.pos-lim-sw-in #******************* # AXIS Z #******************* # Step Gen signals/setup setp hm2_5i25.0.stepgen.01.dirsetup [AXIS_2]DIRSETUP setp hm2_5i25.0.stepgen.01.dirhold [AXIS_2]DIRHOLD setp hm2_5i25.0.stepgen.01.steplen [AXIS_2]STEPLEN setp hm2_5i25.0.stepgen.01.stepspace [AXIS_2]STEPSPACE setp hm2_5i25.0.stepgen.01.position-scale [AXIS_2]STEP_SCALE setp hm2_5i25.0.stepgen.01.step_type 0 setp hm2_5i25.0.stepgen.01.control-type 0 setp hm2_5i25.0.stepgen.01.maxaccel 62.5 setp hm2_5i25.0.stepgen.01.maxvel 16.7 net z-pos-fb axis.2.motor-pos-fb <= hm2_5i25.0.stepgen.01.position-fb net z-pos-cmd axis.2.motor-pos-cmd => hm2_5i25.0.stepgen.01.position-cmd net z-enable axis.2.amp-enable-out => hm2_5i25.0.stepgen.01.enable # ---setup home / limit switch signals--- net max-home-z => axis.2.home-sw-in net min-z => axis.2.neg-lim-sw-in net max-home-z => axis.2.pos-lim-sw-in #******************* # SPINDLE S #******************* # ---digital potentionmeter output signals/setup--- setp hm2_5i25.0.7i76.0.0.spinout-minlim [SPINDLE_9]OUTPUT_MIN_LIMIT setp hm2_5i25.0.7i76.0.0.spinout-maxlim [SPINDLE_9]OUTPUT_MAX_LIMIT setp hm2_5i25.0.7i76.0.0.spinout-scalemax [SPINDLE_9]OUTPUT_SCALE net spindle-vel-cmd => hm2_5i25.0.7i76.0.0.spinout net machine-is-enabled => hm2_5i25.0.7i76.0.0.spinena net spindle-ccw => hm2_5i25.0.7i76.0.0.spindir # ---Encoder feedback signals/setup--- setp hm2_5i25.0.encoder.00.counter-mode 1 setp hm2_5i25.0.encoder.00.filter 1 setp hm2_5i25.0.encoder.00.index-invert 0 setp hm2_5i25.0.encoder.00.index-mask 0 setp hm2_5i25.0.encoder.00.index-mask-invert 0 setp hm2_5i25.0.encoder.00.scale [SPINDLE_9]ENCODER_SCALE net spindle-revs <= hm2_5i25.0.encoder.00.position net spindle-vel-fb <= hm2_5i25.0.encoder.00.velocity net spindle-index-enable <=> hm2_5i25.0.encoder.00.index-enable # ---setup spindle control signals--- net spindle-vel-cmd-rps <= motion.spindle-speed-out-rps net spindle-vel-cmd <= motion.spindle-speed-out net spindle-on <= motion.spindle-on net spindle-cw <= motion.spindle-forward net spindle-ccw <= motion.spindle-reverse net spindle-brake <= motion.spindle-brake net spindle-revs => motion.spindle-revs net spindle-at-speed => motion.spindle-at-speed net spindle-vel-fb => motion.spindle-speed-in net spindle-index-enable <=> motion.spindle-index-enable # ---Setup spindle at speed signals--- sets spindle-at-speed true # Use ACTUAL spindle velocity from spindle encoder # spindle-velocity bounces around so we filter it with lowpass # spindle-velocity is signed so we use absolute component to remove sign # ACTUAL velocity is in RPS not RPM so we scale it. setp scale.spindle.gain 60 setp lowpass.spindle.gain 1.000000 net spindle-vel-fb => lowpass.spindle.in net spindle-fb-filtered-rps lowpass.spindle.out => abs.spindle.in net spindle-fb-filtered-abs-rps abs.spindle.out => scale.spindle.in net spindle-fb-filtered-abs-rpm scale.spindle.out #****************************** # connect miscellaneous signals #****************************** # ---HALUI signals--- net joint-select-a halui.joint.0.select net x-is-homed halui.joint.0.is-homed net jog-x-pos halui.jog.0.plus net jog-x-neg halui.jog.0.minus net jog-x-analog halui.jog.0.analog net joint-select-c halui.joint.2.select net z-is-homed halui.joint.2.is-homed net jog-z-pos halui.jog.2.plus net jog-z-neg halui.jog.2.minus net jog-z-analog halui.jog.2.analog net jog-selected-pos halui.jog.selected.plus net jog-selected-neg halui.jog.selected.minus net spindle-manual-cw halui.spindle.forward net spindle-manual-ccw halui.spindle.reverse net spindle-manual-stop halui.spindle.stop net machine-is-on halui.machine.is-on net jog-speed halui.jog-speed net MDI-mode halui.mode.is-mdi # ---coolant signals--- net coolant-mist <= iocontrol.0.coolant-mist net coolant-flood <= iocontrol.0.coolant-flood # ---probe signal--- net probe-in => motion.probe-input # ---motion control signals--- net in-position <= motion.in-position net machine-is-enabled <= motion.motion-enabled # ---digital in / out signals--- # ---estop signals--- net estop-out <= iocontrol.0.user-enable-out net estop-ext => iocontrol.0.emc-enable-in # ---toolchange signals for custom tool changer--- 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

Ini:
Code:
# Generated by PNCconf at Sun Sep 29 12:26:37 2013 # If you make changes to this file, they will be # overwritten when you run PNCconf again [EMC] MACHINE = EMCO-Turn120 DEBUG = 0 [DISPLAY] DISPLAY = axis POSITION_OFFSET = RELATIVE POSITION_FEEDBACK = ACTUAL MAX_FEED_OVERRIDE = 2.000000 MAX_SPINDLE_OVERRIDE = 1.000000 MIN_SPINDLE_OVERRIDE = 0.500000 INTRO_GRAPHIC = linuxcnc.gif INTRO_TIME = 5 PROGRAM_PREFIX = /home/stephan/linuxcnc/nc_files PYVCP = pyvcp-panel.xml INCREMENTS = 5mm 1mm .5mm .1mm .05mm .01mm .005mm LATHE = 1 POSITION_OFFSET = RELATIVE POSITION_FEEDBACK = ACTUAL DEFAULT_LINEAR_VELOCITY = 10.000000 MAX_LINEAR_VELOCITY = 13.333333 MIN_LINEAR_VELOCITY = 0.010000 DEFAULT_ANGULAR_VELOCITY = 0.250000 MAX_ANGULAR_VELOCITY = 1.000000 MIN_ANGULAR_VELOCITY = 0.010000 EDITOR = gedit GEOMETRY = xz [FILTER] PROGRAM_EXTENSION = .png,.gif,.jpg Greyscale 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.010 [RS274NGC] PARAMETER_FILE = linuxcnc.var [EMCMOT] EMCMOT = motmod COMM_TIMEOUT = 1.0 COMM_WAIT = 0.010 SERVO_PERIOD = 1000000 [HOSTMOT2] # **** This is for info only **** # DRIVER0=hm2_pci # BOARD0=5i25 [HAL] HALUI = halui HALFILE = EMCO-Turn120.hal HALFILE = custom.hal POSTGUI_HALFILE = postgui_call_list.hal SHUTDOWN = shutdown.hal [HALUI] [TRAJ] AXES = 3 COORDINATES = X Z LINEAR_UNITS = mm ANGULAR_UNITS = degree CYCLE_TIME = 0.010 DEFAULT_VELOCITY = 1.33 MAX_LINEAR_VELOCITY = 13.33 NO_FORCE_HOMING = 1 [EMCIO] EMCIO = io CYCLE_TIME = 0.100 TOOL_TABLE = tool.tbl #******************** # Axis X #******************** [AXIS_0] TYPE = LINEAR HOME = 0.0 FERROR = 0.005 MIN_FERROR = 0.0005 MAX_VELOCITY = 13.3333333333 MAX_ACCELERATION = 50.0 # these are in nanoseconds DIRSETUP = 5000 DIRHOLD = 5000 STEPLEN = 2500 STEPSPACE = 2500 STEP_SCALE = -1280.0 MIN_LIMIT = -0.2 MAX_LIMIT = 50.0 HOME_OFFSET = 0.000000 HOME_SEARCH_VEL = -6.666667 HOME_LATCH_VEL = 3.333333 HOME_FINAL_VEL = 0.333333 HOME_USE_INDEX = NO HOME_IGNORE_LIMITS = YES HOME_SEQUENCE = 1 #******************** # Axis Z #******************** [AXIS_2] TYPE = LINEAR HOME = 0.0 FERROR = 0.005 MIN_FERROR = 0.0005 MAX_VELOCITY = 13.3333333333 MAX_ACCELERATION = 50.0 # these are in nanoseconds DIRSETUP = 5000 DIRHOLD = 5000 STEPLEN = 2500 STEPSPACE = 2500 STEP_SCALE = -1280.0 MIN_LIMIT = -134.0 MAX_LIMIT = 0.2 HOME_OFFSET = 0.000000 HOME_SEARCH_VEL = 6.666667 HOME_LATCH_VEL = -3.333333 HOME_FINAL_VEL = 0.333333 HOME_USE_INDEX = NO HOME_IGNORE_LIMITS = YES HOME_SEQUENCE = 0 #******************** # Spindle #******************** [SPINDLE_9] ENCODER_SCALE = 1440.0 OUTPUT_SCALE = 2000.0 OUTPUT_MIN_LIMIT = 0.0 OUTPUT_MAX_LIMIT = 2000.0

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

More
13 years 1 month ago - 13 years 1 month ago #39346 by cmorley
I see you have set:
min output limit of the spindle to 0
max limit to 2000
ans scale to 2000

That means you can have a range of 0 to 2000.
Notice how there is no negative range - negative is reverse rotation.

set min limit to -2000

oh wait you can't have negative voltage...so don't change it
I think you need to add an abs component to make sure the voltage is always positive.

you would need to change:
loadrt abs names=abs.spindle
to:
loadrt abs names=abs.spindle,abs,spindle_output

add line
addf abs.spindle_output servo-thread
after line
addf abs.spindle servo-thread

it needs to go between:
net spindle-vel-cmd => hm2_5i25.0.7i76.0.0.spinout
so change it to:
net spindle-vel-cmd => abs.spindle_output.in
net spindle-vel-cmd-abs abs.spindle_output => hm2_5i25.0.7i76.0.0.spinout

I've not tested this but that should do it.
looking at the encoder part ....

Chris M
Last edit: 13 years 1 month ago by cmorley.

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

More
13 years 1 month ago #39348 by cmorley
I don't see anything obviously wrong with the encoder HAL file.
Please check wiring, if the encoder is producing signals and that you are connected to encoder 0

Chris M
The following user(s) said Thank You: Bad_German

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

More
13 years 1 month ago #39349 by PCW
Also for the encoder to work in count mode you must connect the encoder output
to the 'A' input on the 7I76 and jumper the 7I76 encoder input for TTL type signals

Its probably arguable that motion should have both a signed spindle
velocity pin (as it does now) and a unsigned spindle speed pin
(since it already has the direction signals) To avoid the common
requirement of the absolute component here.
The following user(s) said Thank You: Bad_German

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

More
13 years 1 month ago #39367 by Bad_German
Thanks for the help guy's, you're awesome,
both parts are working now.

fixed two typos, just for future reference...
Code:
Replace: loadrt abs names=abs.spindle with: loadrt abs names=abs.spindle,abs.spindle_output add: addf abs.spindle_output servo-thread replace: net spindle-vel-cmd => hm2_5i25.0.7i76.0.0.spinout with: net spindle-vel-cmd => abs.spindle_output.in net spindle-vel-cmd-abs abs.spindle_output.out => hm2_5i25.0.7i76.0.0.spinout

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

More
13 years 1 month ago #39369 by cmorley

PCW wrote: Also for the encoder to work in count mode you must connect the encoder output
to the 'A' input on the 7I76 and jumper the 7I76 encoder input for TTL type signals

Its probably arguable that motion should have both a signed spindle
velocity pin (as it does now) and a unsigned spindle speed pin
(since it already has the direction signals) To avoid the common
requirement of the absolute component here.


Yes I agree - working on a patch now.
It would be nice if hostmot has encoder/resolver velocity as an absolute as well.
its common to filter and absolute it for spindle readout display...

Chris M

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

Moderators: cmorley
Time to create page: 0.062 seconds
Powered by Kunena Forum