- Posts: 154
- Thank you received: 0
gmoccapy pins
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
2 years 2 months ago #306505
by Moutomation
gmoccapy pins was created by Moutomation
I want to control the home button, emergency stop, G code refresh button, program start button from the classic ladder, what should I add to the hale file for this?
Attachment not found
Please Log in to join the conversation.
2 years 2 months ago #306508
by Aciera
Replied by Aciera on topic gmoccapy pins
for estop-activate use 'halui.estop.activate'
for estop-reset use 'halui.estop.reset'
for machine-on use 'halui.machine.on'
for machine-off use 'halui.machine.off
for home-button use 'halui.home-all '
for program-start use 'halui.program.run'
Gcode refresh I'm not sure.
linuxcnc.org/docs/html/man/man1/halui.1.html
for estop-reset use 'halui.estop.reset'
for machine-on use 'halui.machine.on'
for machine-off use 'halui.machine.off
for home-button use 'halui.home-all '
for program-start use 'halui.program.run'
Gcode refresh I'm not sure.
linuxcnc.org/docs/html/man/man1/halui.1.html
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #306511
by Moutomation
Replied by Moutomation on topic gmoccapy pins
Thanks a lot
Can program refresh be controlled from the classic ladder?
Can program refresh be controlled from the classic ladder?
Please Log in to join the conversation.
2 years 2 months ago #306911
by newbynobi
Replied by newbynobi on topic gmoccapy pins
I do recommend not to use halui pins, but the hardware button pins to control that stuff.
See:
Right and Botton Button Hal Pin
See:
Right and Botton Button Hal Pin
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #306921
by Moutomation
Replied by Moutomation on topic gmoccapy pins
Instead of binding this key to a button, is there a way to refresh the g-code file every few seconds while the g-code is not executing? I want to automatically load the g-code file into linuxcnc continuously. The name of the g-code file is always the same and never changes.
Please Log in to join the conversation.
2 years 2 months ago #307066
by Aciera
Replied by Aciera on topic gmoccapy pins
Try this:
Save the python code below as 'file-check.py' into a folder named 'python' in your machine config folder and mark as executable.
This user component will create a hal pin 'file-checked.file-changed' and output a pulse if the file is modified:#!/usr/bin/env python3
To load this on startup add this to the [HAL] section of your .ini file:
then add this line to your POSTGUI_HALFILE:
Save the python code below as 'file-check.py' into a folder named 'python' in your machine config folder and mark as executable.
This user component will create a hal pin 'file-checked.file-changed' and output a pulse if the file is modified:#!/usr/bin/env python3
Code:
#!/usr/bin/env python3
import os
import time
import hal
import linuxcnc
h = hal.component("file-check")
h.newpin("file-changed", hal.HAL_BIT, hal.HAL_OUT)
h.ready()
# create a connection to the status channel
s = linuxcnc.stat()
# this is the file being checked for updates (example looks for 'file.txt' in the config folder)
file_path = 'file.txt'
# length of output puls in milliseconds
pulse_length = 1000
last_modified = os.path.getmtime(file_path)
h['file-changed'] = False
try:
while 1:
s.poll()
# we don't want to reload when program is running
if s.task_mode == 2 and s.state == 1: # ie AUTO-mode and 'RCS_DONE'
current_modified = os.path.getmtime(file_path)
if current_modified != last_modified:
print("File has changed!")
h['file-changed'] = True
timer_start = round(time.time()*1000)
last_modified = current_modified
if h['file-changed'] and timer_start + pulse_length <= round(time.time()*1000):
h['file-changed'] = False
except KeyboardInterrupt:
raise SystemExit
To load this on startup add this to the [HAL] section of your .ini file:
Code:
HALCMD = loadusr -W ./python/file-check.py
then add this line to your POSTGUI_HALFILE:
Code:
net file-reload file-check.file-changed gmoccapy.h-button.button-1
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #307113
by Moutomation
Replied by Moutomation on topic gmoccapy pins
You are great, thank you very much. I will try to do it tomorrow.
Please Log in to join the conversation.
- Moutomation
- Topic Author
- Offline
- Premium Member
-
Less
More
- Posts: 154
- Thank you received: 0
2 years 2 months ago #307144
by Moutomation
Replied by Moutomation on topic gmoccapy pins
Hello,
I think I'm making a mistake somewhere
The file.txt file is in the config folder, but I think it cannot find this file.
./python/file-check.py: 1: import: not found
./python/file-check.py: 2: import: not found
./python/file-check.py: 3: import: not found
./python/file-check.py: 4: import: not found
./python/file-check.py: 6: Syntax error: "(" unexpected
<commandline>:0: waitpid failed ./python/file-check.py file-check
<commandline>:0: ./python/file-check.py exited without becoming ready
I think I'm making a mistake somewhere
The file.txt file is in the config folder, but I think it cannot find this file.
./python/file-check.py: 1: import: not found
./python/file-check.py: 2: import: not found
./python/file-check.py: 3: import: not found
./python/file-check.py: 4: import: not found
./python/file-check.py: 6: Syntax error: "(" unexpected
<commandline>:0: waitpid failed ./python/file-check.py file-check
<commandline>:0: ./python/file-check.py exited without becoming ready
Please Log in to join the conversation.
2 years 2 months ago #307146
by Aciera
Replied by Aciera on topic gmoccapy pins
Seems likeI lost the hashbang in the first line of the python code in my last post.
I just fixed that, so copy/paste the fixtd python code above and try again.
I just fixed that, so copy/paste the fixtd python code above and try again.
Please Log in to join the conversation.
Time to create page: 0.132 seconds
