Is there a way to touch-off purely in HAL?

More
07 Mar 2024 18:32 #295423 by chowderhead
I'm writing a python HAL component that includes touching off and want to avoid importing linuxcnc and firing an mdi command if possible. Is there any way to do it using only HAL?

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

More
07 Mar 2024 20:12 - 07 Mar 2024 20:15 #295426 by Mecanix
Mind you I have no idea what you're trying to achieve. Until we've figured that part out, try that just for fun: 
 
1. Create a new file, call it "whatever.py"
2. Copy below code in it. Save it into your ~/chowderhead/
3. Start Axis, Un-stop & En it, home all. 
4. Start terminal and type $ python3 ~/chowderhead/whatever.py


#!/usr/bin/env python
feed = 300
from subprocess import call
call(['axis-remote','-m', 'G38.3 Z-10 F{}'.format(feed)])

 
Last edit: 07 Mar 2024 20:15 by Mecanix.

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

More
07 Mar 2024 20:28 #295428 by Mecanix
Above method given being under the assumption you ain't fond of the unreliable c.mdi() that rarely wait. And I don't blame you. A way around that issue that I had luck with (sort of, still bugged) is with INTERP_IDLE. If you ever manage to write something up for rtai_api and achieve what you are trying to do (halrun/halcmd?), please share!

import linuxcnc

s = linuxcnc.stat()
c = linuxcnc.command()

def moveAxis(ax, pos, f):
    try:
        c.mode(linuxcnc.MODE_MDI)
        c.wait_complete()
        c.mdi('G1 {}{} F{}'.format(ax, pos, f))
        s.poll()
        while (s.interp_state != linuxcnc.INTERP_IDLE):
            time.sleep(.01)
            s.poll()
        c.mode(linuxcnc.MODE_MANUAL)
    except Exception as ex:
        print('Error:', ex)
        
### call with
moveAxis(Z, -10, 300)
   

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

More
24 Apr 2024 22:13 #299033 by bondglen
I am also looking for a way to touch-off without using the keyboard.
I'm trying to build a remote pendant and want a button for touch-off.
I'm not using a USB/keyboard interface for my pendant, so I need to go thru HAL (I think).

I have looked at the previous reply, and don't really understand it. I am unfamiliar with python. I'm hoping to find a way to work with halcmd.

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

More
25 Apr 2024 07:33 - 25 Apr 2024 07:49 #299048 by Aciera
Why not use an MDI_COMMAND:
forum.linuxcnc.org/38-general-linuxcnc-q...parallel-port#292850

Note: you can use any mdi command, it does not have to be an m-code. ie you could also define:
[HALUI]
MDI_COMMAND = G38.3 Z-20 F100


and then connect it to your button in hal:
net run-probe <= your_pin_here => halui.mdi-command-00
Last edit: 25 Apr 2024 07:49 by Aciera.

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

More
26 Apr 2024 01:17 #299090 by bondglen
Thanks, I think a MDI command may work well for me.

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

Time to create page: 0.164 seconds
Powered by Kunena Forum