Prevent spindle start if a certain tool is selected?

More
17 Jun 2024 10:31 #303164 by pippin88
Ideal solution to me seems to alter tool table to allow a max rpm.

github.com/LinuxCNC/linuxcnc/issues/2949

0rpm for a probe (or have another field that allows spindle to be enabled or disabled).
Face mills / larger tools would benefit from max rpm function.

(I am not capable of doing this sorry).
The following user(s) said Thank You: RotarySMP, Clive S

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

More
17 Jun 2024 11:59 #303170 by RotarySMP
Thanks, I'll give that a go and report back.

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

More
17 Jun 2024 12:07 #303172 by Aciera
Maybe this helps as an example:
forum.linuxcnc.org/38-general-linuxcnc-q...h-ui?start=20#299957

Note the above thread as such is a write off but the example component I presented there might be of interest.
The following user(s) said Thank You: RotarySMP

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

More
17 Jun 2024 12:52 #303176 by RotarySMP
Pippins idea is a really good one.

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

More
17 Jun 2024 14:13 - 17 Jun 2024 14:21 #303180 by Aciera
 

Pippins idea is a really good one.


Given the lack of active developers you may be waiting a long time for a built in solution.
The point I was trying to make in the linked thread was that you can already do this by using an unused tool-table column and a python component to limit the commanded spindle speed.

[edit]
Actually if you use an unused tool-table column say 'w_offset' for max speed you would not even need a python component as that value is directly available as a hal-pin.
Last edit: 17 Jun 2024 14:21 by Aciera.
The following user(s) said Thank You: RotarySMP

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

More
17 Jun 2024 15:45 #303185 by RotarySMP
Nice idea. Will try to see if I can do something with it.

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

More
17 Jun 2024 18:45 - 17 Jun 2024 19:01 #303192 by RotarySMP
TO start with, I'm just trying to add the inhibit for tool 999.

Okay, I added:[DISPLAY]
USER_COMMAND_FILE=usercommand.py

As I am on LCNC 2.7 on the maho, I dont have spindle.0.inhibit, so I replaced that with motion.spindle.inhibit in my usercommand.py file.

#!/usr/bin/env python

prob_in_spindle = 0

def user_live_update():
global prob_in_spindle
#PROBE = T999 / T998
if s.tool_in_spindle == 998 or s.tool_in_spindle == 999:
prob_in_spindle = 1
hal.set_p('motion.spindle.inhibit','1')
else:
if prob_in_spindle == 1:
prob_in_spindle = 0
hal.set_p('motion.spindle.inhibit','0')

I have an INI entry:
[PYTHON]
PATH_PREPEND = python
TOPLEVEL = python/toplevel.py

I tried putting my usercommand.py in both the directory with the INI, and one down in the python directory. In both cases, there are no errors on start, but there is also no change in behaviour. It doesn't inhibit the spindle with T999 active.
I have struggle with this interface of multiple files and directories, and would appreciate your help pointing out which changes I need. Thanks.
Cheers,
Mark

ps... I wonder if my 2.7 Lcnc even has the global variable prob_in_spindle?


 
Last edit: 17 Jun 2024 19:01 by RotarySMP.

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

More
17 Jun 2024 19:24 - 17 Jun 2024 19:33 #303193 by Aciera
First I think you need to add this as a userspace component.
Then you need to have a loop in there as otherwise it will simply run once and then disappear.

Have a look at 'Basic Usage':
linuxcnc.org/docs/2.7/html/hal/halmodule.html

[edit]
2.7 was before my time so things may have changed a bit but these days you would also want to poll the status channel in the loop so your getting up to date information
Last edit: 17 Jun 2024 19:33 by Aciera.
The following user(s) said Thank You: RotarySMP

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

More
17 Jun 2024 19:27 #303194 by RotarySMP
Thanks for pointing me in the right direction. Will do.

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

More
17 Jun 2024 19:48 #303198 by Aciera
I'm a bit worn out right now, so I have no idea if this works on 2.7 but you can give this a go and have a look at 'mycomp.spindle-inhibit' pin in halshow:
#!/usr/bin/env python

import hal
import linuxcnc

h = hal.component("mycomp")

h.newpin("spindle_inhibit", hal.HAL_BIT, hal.HAL_OUT)
h.ready()

# create a connection to the status channel
s = linuxcnc.stat()

try:
    while 1:
        s.poll() # get values from the status channel
        current_tool = s.tool_in_spindle # get curent tool-number
        if s.tool_in_spindle and (s.tool_in_spindle == 998 or s.tool_in_spindle == 999): # a tool is loaded
            h['spindle_inhibit'] = 1
        else:
            h['spindle_inhibit'] = 0

except KeyboardInterrupt:
    raise SystemExit

 

To load this add this to your hal file
loadusr mycomp
The following user(s) said Thank You: RotarySMP

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

Time to create page: 0.077 seconds
Powered by Kunena Forum