Showing results for 
Search instead for 
Did you mean: 

Post Builder M_spindle


Hello again everyone. I've got another question. I've gotten a request from our CAM programmers to output a spindle stop command any time the spindle changes direction (CW to CCW and vice versa). Digging into it a bit it seems like i should be able to modify the PB_CMD_output_spindle command to add a simple IF statment to check the current state of M_spindle and output a M5 if it changes from it's current state.


So, that's as far as my knowdedge of how the M_spindle command functions. So how would I capture the current state of M_Spindle?


Re: Post Builder M_spindle

Valued Contributor
Valued Contributor

I would program something like the following. I didn't have time to test the code.



global prev_spindle_direction mom_spindle_direction

if {![info exists prev_spindle_direction]} { 
set prev_spindle direction "NONE"

if {$prev_spindle_direction != $mom_spindle_direction && $prev_spindle direction != "NONE"} { 
MOM_output_literal "M05"

set prev_spindle_direction $mom_spindle_direction
Using NX

Re: Post Builder M_spindle

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor

You will have to save & use your own variable


In spindle off, add a custom command like this:

global cs900_spindle_state
catch { unset cs900_spindle_state}

Note you may need to add this elsewhere (e.g. some machines M0 turns off the spindle as well)



Then in the Spindle RPM / Spindle CSS add a custom command like this:

global mom_spindle_direction
global cs900_spindle_state
global mom_spindle_status

# spindle already off
if {$mom_spindle_status == "OFF"} { return }

# no previous state saved
if {![info exists cs900_spindle_state] ||
    ![info exists mom_spindle_direction]} { return }

# if same direction
if {$mom_spindle_direction == $cs900_spindle_state} { return }

#TODO: whatever here to output spindle off
# e.g.
# MOM_do_template spindle_off
# or 
# MOM_spindle_off

# save current direction
set cs900_spindle_state $mom_spindle_direction
Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP16/TC11.2
I'd rather be e-steamed than e-diseaseled

Learn online

Solution Information