Recognition of Spindle Emergency Stop

More
21 Jan 2024 19:55 #291278 by Gnevko
Hi people!

I'm trying to create the simple hal configuration file for the spindle (servo motor), driwing with step/dir instruction. My problem at the moment is, how to stop programm (or mashine at all), if spindle becomes an error and doesn't rotate anymore ? In the following hal configuration I try to use spindle.0.brake but it seems to be not a good idea.
#*******************
#  SPINDLE
#*******************

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

setp   hm2_7i95.0.stepgen.05.dirsetup        [SPINDLE_0]DIRSETUP
setp   hm2_7i95.0.stepgen.05.dirhold         [SPINDLE_0]DIRHOLD
setp   hm2_7i95.0.stepgen.05.steplen         [SPINDLE_0]STEPLEN
setp   hm2_7i95.0.stepgen.05.stepspace       [SPINDLE_0]STEPSPACE
setp   hm2_7i95.0.stepgen.05.position-scale  [SPINDLE_0]OUTPUT_SCALE
setp   hm2_7i95.0.stepgen.05.step_type        0 #0 = Step/Dir
setp   hm2_7i95.0.stepgen.05.control-type     1 #1 = velocity control mode
setp   hm2_7i95.0.stepgen.05.maxaccel        [SPINDLE_0]STEPGEN_MAXACCEL
setp   hm2_7i95.0.stepgen.05.maxvel          [SPINDLE_0]STEPGEN_MAXVEL

#connect the encoder to the spindle
net spindle-velocity-signal hm2_7i95.0.encoder.05.velocity #the hal signal will be used in more places
net spindle-speed-out-signal spindle.0.speed-out #the hal signal will be used in more places

net spindle-pos-encoder   hm2_7i95.0.encoder.05.position => spindle.0.revs
net spindle-velocity-signal => spindle.0.speed-in
net spindle-index-enable  hm2_7i95.0.encoder.05.index-enable <=> spindle.0.index-enable

#connect the spindle to the step generator
net spindle-enable spindle.0.on => hm2_7i95.0.stepgen.05.enable
net spindle-speed-out-signal => hm2_7i95.0.stepgen.05.velocity-cmd

#*******************
#stopping the program if the spindle fails
#*******************
loadrt near names=near_spindle_stop           # spindle stop reset, regardless of the reason
loadrt timedelay names=timedelay_spindle_stop # time delay for switching to emergency shutdown mode
loadrt and2 names=and2_spindle_stop_logic     # spindle stop - is the spindle stop planned or is it an emergency?

# Add the new components to the servo thread
addf near_spindle_stop servo-thread
addf timedelay_spindle_stop servo-thread
addf and2_spindle_stop_logic servo-thread

setp near_spindle_stop.scale 1 #default value
setp near_spindle_stop.difference [SPINDLE_0]MAX_ERROR  # Threshold for detecting spindle stop

setp timedelay_spindle_stop.on-delay 0  # The time, in seconds, for which in must be true before out becomes true
setp timedelay_spindle_stop.off-delay [SPINDLE_0]DELAY_TIME  # Immediate deactivation delay (optional)

net spindle-velocity-signal => near_spindle_stop.in2
net near-spindle-stopped near_spindle_stop.out => timedelay_spindle_stop.in

# Logic to determine if the spindle stop is expected
net spindle-brake-commanded spindle.0.brake  => and2_spindle_stop_logic.in0
net and2-spindle-stopped timedelay_spindle_stop.out => and2_spindle_stop_logic.in1

# Only trigger emergency stop if the stop was unexpected
net unexpected-spindle-stop and2_spindle_stop_logic.out => halui.estop.activate

Thank you in advance!

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

More
21 Jan 2024 20:28 #291283 by spumco
Assuming your servo amp has a fault output, I would use motion.spindle.N.amp-fault-in.

linuxcnc.org/docs/devel/html/man/man9/mo....html#SPINDLE%20PINS

You will likely need to check and perhaps edit how 'fault' is defined in your drive and make sure that definition covers everything you consider a fault.  Like over-current, following error, etc.

Keep in mind that halui pins don't work while the machine in running a program (auto mode), so halui.estop.activate won't work like I think you want.

Bonus: if you have other components you want to trigger an estop (or similar fault condition), a somewhat recent addition to LCnC are motion.misc-error-NN pins.  These are defined in the same HAL line as your digital-in/analog-in values.  Thusly:

num_dio=[EMCMOT](DIO) num_aio=[EMCMOT](AIO) num_misc_error=[EMCMOT](MISC_ERRORS)
The following user(s) said Thank You: Gnevko, smc.collins

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

More
22 Jan 2024 10:35 #291330 by Gnevko
Thank you for your response; it was truly helpful!

My initial idea was to compare the stepgen command and encoder input to identify spindle motor faults. However, using an AMP signal is a more effective approach, despite the drawback of requiring the installation of an additional signal cable.

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

More
22 Jan 2024 17:49 #291350 by Gnevko
Now it looks like this:
#******************* 
#stopping the program if the spindle fails 
#******************* 
net servo-amplifier-fault hm2_7i95.0.inmux.00.input-07-not => spindle.0.amp-fault-in
and it works! thank you!

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

More
23 Jan 2024 18:44 #291445 by Gnevko
I understand that my question might not directly relate to the topic name, but what is the best practice for accelerating (and more importantly, decelerating) the hm2 stepgen in velocity mode?

I ask because I found a parameter like this - hm2_7i95.0.stepgen.05.maxaccel - but I couldn't find anything about deceleration.

Thank you in advance!

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

More
23 Jan 2024 20:01 #291460 by Aciera
The 'maxaccel' value also applies to deceleration.

For more exposure about best practice when using hm2 stepgen in velocity mode you may want to start a new topic.

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

More
24 Jan 2024 07:01 #291496 by Gnevko
thank you, you are right - the new topic is hier

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

Time to create page: 0.134 seconds
Powered by Kunena Forum