Trigger HAL pin from gcode

More
10 Sep 2017 12:16 #98767 by AlbertHall
AlbertHall created the topic: Trigger HAL pin from gcode
Is it possible to trigger a HAL pin - e.g. axisui.notifications-clear - with a gcode command?

(MSG, Check the probe connections)
M0
<gcode to clear the message from the axis screen>
More
10 Sep 2017 13:28 - 10 Sep 2017 13:29 #98770 by rodw
rodw replied the topic: Trigger HAL pin from gcode
I don't believe so. The solution that worked for me with Gmocappy was to use M67/68 or M64/65 commands and process them in the python screen handler for the GLADE screen. eg. the handler creates a pin that is changed by the code in the handler on receipt of a GCODE command. Not sure how the screen handler works in axis.

This thread explains how it is done.
forum.linuxcnc.org/plasma-laser/32691-settings-from-g-code-file
Last Edit: 10 Sep 2017 13:29 by rodw.
More
10 Sep 2017 14:07 #98773 by AlbertHall
AlbertHall replied the topic: Trigger HAL pin from gcode
It just occurred to me that there is a HAL pin for coolant on/off which I don't use. is it possible to link the coolant output to the notifications clear input so that the coolant command could clear the notifications?
More
10 Sep 2017 15:13 #98778 by dgarrett
dgarrett replied the topic: Trigger HAL pin from gcode
M100-M199 User Defined Commands

Ref: linuxcnc.org/docs/2.7/html/gcode/m-code.html#mcode:m100-m199

Example:
#!/bin/bash
halcmd setp axisui.notifications-clear-info 1
sleep .1
halcmd setp axisui.notifications-clear-info 0
exit 0
The following user(s) said Thank You: AlbertHall
More
10 Sep 2017 19:20 - 10 Sep 2017 19:22 #98793 by AlbertHall
AlbertHall replied the topic: Trigger HAL pin from gcode
Thanks. I tried that but the M100 doesn't clear the message - it ends the program. No code after the M100 is executed. There are no error messages.

I copied your code into a file called M100, in a folder called mcodes. The folder I put in the same folder as the ini file. I added a line in the RS274NGC section of the ini file:
USER_M_PATH = mcodes
Last Edit: 10 Sep 2017 19:22 by AlbertHall.
More
10 Sep 2017 20:50 #98798 by dgarrett
dgarrett replied the topic: Trigger HAL pin from gcode

There are no error messages.


Then make sure your M1xx is running, augment it with
some echos and start linuxcnc in a terminal.

Example: augmented M1xx file:
#!/bin/bash
echo hello------------------------------------
halcmd show pin axisui.notifications
halcmd setp axisui.notifications-clear 1
halcmd setp axisui.notifications-clear-info 1
halcmd setp axisui.notifications-clear-error 1
halcmd show pin axisui.notifications
sleep .1
halcmd setp axisui.notifications-clear 0
halcmd setp axisui.notifications-clear-info 0
halcmd setp axisui.notifications-clear-error 0
halcmd show pin axisui.notifications
echo bye--------------------------------------
exit 0

It is also possible you need to use a longer sleep
time on a slow or highly-loaded system.

You can test in the MDI tab.
The M1xx script must exist before starting LinuxCNC

Note there are pins to clear all, info only, error only:
Ref: all axisui pins are named here:
linuxcnc.org/docs/2.7/html/gui/axis.html#_axisui_pins

Example stdout:
hello------------------------------------
Component Pins:
Owner   Type  Dir         Value  Name
    71  bit   IN          FALSE  axisui.notifications-clear
    71  bit   IN          FALSE  axisui.notifications-clear-error
    71  bit   IN          FALSE  axisui.notifications-clear-info

Component Pins:
Owner   Type  Dir         Value  Name
    71  bit   IN           TRUE  axisui.notifications-clear
    71  bit   IN           TRUE  axisui.notifications-clear-error
    71  bit   IN           TRUE  axisui.notifications-clear-info

Component Pins:
Owner   Type  Dir         Value  Name
    71  bit   IN          FALSE  axisui.notifications-clear
    71  bit   IN          FALSE  axisui.notifications-clear-error
    71  bit   IN          FALSE  axisui.notifications-clear-info

bye--------------------------------------
More
10 Sep 2017 22:55 #98804 by AlbertHall
AlbertHall replied the topic: Trigger HAL pin from gcode
I tried that. It does the same - ends the program - and it doesn't print anything in the terminal window.

I tried sleep 1 but that made no difference.

I took out everything except the first line, echo lines, and exit line, but that still does the same.

Perhaps I should have mentioned that I am using version 2.5.0 of LinuxCNC?
More
10 Sep 2017 23:35 #98805 by dgarrett
dgarrett replied the topic: Trigger HAL pin from gcode

I tried that. It does the same - ends the program - and it doesn't print anything in the terminal window.


If you run a M1xx script like the one shown (with echo statements, and halcmd
show statements) and it doesn't print to the terminal used in starting
LinuxCNC then you have not configured it correctly (location, permissions, etc.)
or are doing something else wrong in your testing.

It's always a good idea to state the version. 2.5 is pretty old
but the axisui hal pins for were incorporated in 2009 at the 2.4_branch
$ git branch --contains 74d6628d9|grep 2\.
  2.7
  v2.4_branch
* v2.5_branch
More
10 Sep 2017 23:46 #98806 by AlbertHall
AlbertHall replied the topic: Trigger HAL pin from gcode
I may have found the problem :)
I didn't set it as executable. I will try this tomorrow.
For example to open and close a collet closer that is controlled by a parallel port pin using a bash script file using M101 and M102. Create two files named M101 and M102. Set them as executable files (typically right click/properties/permissions) before running LinuxCNC. Make sure the parallel port pin is not connected to anything in a HAL file.
More
11 Sep 2017 09:46 - 11 Sep 2017 09:48 #98821 by AlbertHall
AlbertHall replied the topic: Trigger HAL pin from gcode
No, that wasn't it. The file was already set as executable.
After a lot of messing about I have found the problem. The linux box is not on the internet so I created the file on a windows laptop and the line endings were the problem. I re-saved the file with gedit and set linux line endings and it all works perfectly now.

When ran LinuxCNC from terminal I noticed warnings saying that the ini file had DOS line endings (as I had edited it on the windows machine) but that doesn't seem to cause any problem. However, I have re-saved that too.

Thank you very much for your time and effort on this.
Last Edit: 11 Sep 2017 09:48 by AlbertHall. Reason: Adding thanks
Time to create page: 0.090 seconds
Powered by Kunena Forum