radius/diameter programming and hal

More
2 years 8 months ago - 2 years 8 months ago #292755 by bobwolf
what a mess I made with the post :_(
Last edit: 2 years 8 months ago by bobwolf.

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

More
2 years 8 months ago #292757 by Aciera
try this:
Code:
#!/usr/bin/env python # to load this in in hal: # loadusr python linuxcnc-status.py import sys import hal import linuxcnc # Make a component and pins h = hal.component("linuxcnc_status") h.newpin("g7-is-active", hal.HAL_BIT, hal.HAL_OUT) h.newpin("g8-is-active", hal.HAL_BIT, hal.HAL_OUT) h.newpin("g54-is-active", hal.HAL_BIT, hal.HAL_OUT) h.newpin("g55-is-active", hal.HAL_BIT, hal.HAL_OUT) h.ready() # test connection to linuxcnc try:     s = linuxcnc.stat()     # create a connection to the status channel     s.poll()     # get current values except Exception as e:     print("error ", e)     sys.exit(1) #loop while 1:     print(s.gcodes)     # get current values     s.poll()     # Handle absolute / incremental (G90/G91)     if s.gcodes[15] == 70:         h['g7-is-active'] = 1         h['g8-is-active'] = 0     elif s.gcodes[15] == 80:         h['g7-is-active'] = 0         h['g8-is-active'] = 1     else :         h['g7-is-active'] = 0         h['g8-is-active'] = 0     # Handle G54/G55     if s.gcodes[8] == 540:         h['g54-is-active'] = 1         h['g55-is-active'] = 0     elif s.gcodes[8] == 550:         h['g54-is-active'] = 0         h['g55-is-active'] = 1     else :         h['g54-is-active'] = 0         h['g55-is-active'] = 0

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

More
2 years 8 months ago #292759 by bobwolf
I tried and it doesn't work
does not create the component
you only changed from [15] to [8] in my edit; but what does it mean and where can I find the references?

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

More
2 years 8 months ago #292762 by Aciera
Works for me though (on 2.9.1). Maybe try to start your config from the terminal and check for errors.
The line:
print(s.gcodes)
should give you an updating printout of the 'gcodes' list. The active work offset is in list item 8, while G7/G8 is in list item 15.

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

More
2 years 8 months ago #292780 by bobwolf
ok I use 2.8... maybe that's why
I will try to search for the 'gcodes' file on my PC to understand this functionality a little better

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

More
2 years 8 months ago - 2 years 8 months ago #292781 by Aciera
Documentation for the python interface:
linuxcnc.org/docs/2.8/html/config/python-interface.html

As I said, start your config from the console and check for error messages.
Last edit: 2 years 8 months ago by Aciera. Reason: change link to 2.8
The following user(s) said Thank You: bobwolf

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

Time to create page: 0.324 seconds
Powered by Kunena Forum