Linuxcnc equivalent of UCCNC macros, macroloops, plugins
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
17 Jun 2022 08:07 #245306
by beefy
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Thanks Andy.
This part of Linuxcnc is rather hard to find information on. Youtube comes up with very little results and in general trying to find out how to get from A (when you know where A starts) to B is very frustrating.
Perhaps half the problem is knowing exactly where to look.
I'm guessing in time, as I keep reading and searching, it will all start coming together.
This part of Linuxcnc is rather hard to find information on. Youtube comes up with very little results and in general trying to find out how to get from A (when you know where A starts) to B is very frustrating.
Perhaps half the problem is knowing exactly where to look.
I'm guessing in time, as I keep reading and searching, it will all start coming together.
Please Log in or Create an account to join the conversation.
- tommylight
- Online
- Moderator
Less
More
- Posts: 19471
- Thank you received: 6530
17 Jun 2022 14:06 #245324
by tommylight
Replied by tommylight on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Example for google searching:will bring back results only form the LinuxCNC web sitewill bring results containing the exact phrase, in this case LinuxCNC macros
Search google for "google hacking", there are a lot more such gems there.
LinuxCNC macros site:linuxcnc.org
"LinuxCNC macros"
Search google for "google hacking", there are a lot more such gems there.
The following user(s) said Thank You: beefy
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
28 Jun 2022 20:17 - 28 Jun 2022 20:18 #246100
by beefy
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Starting to make a bit of headway with Python scripting.
I now know how to use Python to query Linuxcnc status. However, I'm pulling my hair out trying to find documentation that explains the returned results.
One of the results I can get is the current state of the digital input and output pins.
In Axis you can also get the Linuxcnc status by going to the Machine menu and clicking on "Show Linuxcnc Status".
You'll see in the pop-up box there are results for "din" and "dout" which are the digital input pins and digital output pins. However the results for each are 64 boolean True/False values.
At present that is absolutely meaningless as I have no idea what each boolean value refers to.
When I did scripting in UCCNC such results were given by port and pin number for example, so you knew exactly what value for what pin.
Can anyone explain these status results from Linuxcnc.
I now know how to use Python to query Linuxcnc status. However, I'm pulling my hair out trying to find documentation that explains the returned results.
One of the results I can get is the current state of the digital input and output pins.
In Axis you can also get the Linuxcnc status by going to the Machine menu and clicking on "Show Linuxcnc Status".
You'll see in the pop-up box there are results for "din" and "dout" which are the digital input pins and digital output pins. However the results for each are 64 boolean True/False values.
At present that is absolutely meaningless as I have no idea what each boolean value refers to.
When I did scripting in UCCNC such results were given by port and pin number for example, so you knew exactly what value for what pin.
Can anyone explain these status results from Linuxcnc.
Last edit: 28 Jun 2022 20:18 by beefy.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
28 Jun 2022 21:13 #246105
by andypugh
Replied by andypugh on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
I think that the results you see in LinuxCNC status are the G-code digital inputs and outputs. ie the values of motion.digital-in/out-NN which are controlled by the M65 command (and friends)
If you want the value of an actual physical IO then you need to look at the value of the corresponding HAL pin.
For example.
linuxcnc.org/docs/stable/html/hal/halmodule.html
There is also a way to trigger a callback on a HAL pin value change, though that is a little more involved.
If you want the value of an actual physical IO then you need to look at the value of the corresponding HAL pin.
import hal
v = hal.get_value("hm2_7i76E.0.input-00")
For example.
linuxcnc.org/docs/stable/html/hal/halmodule.html
There is also a way to trigger a callback on a HAL pin value change, though that is a little more involved.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7777
- Thank you received: 2073
29 Jun 2022 01:44 - 29 Jun 2022 01:46 #246123
by cmorley
That gives you a python tuple (a specific python type of list) of the (default number of) 64 integer values.
To just get a specific integer use this:
Gstat is a useful library for working with linuxcnc in python
(not sure what version of linuxcnc you are using.)
linuxcnc.org/docs/devel/html/gui/gstat.html
Replied by cmorley on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
import linuxcnc
s = linuxcnc.stat()
s.poll()
analogin = s.ain
That gives you a python tuple (a specific python type of list) of the (default number of) 64 integer values.
To just get a specific integer use this:
# used with code above.
analogin0 = analogin[0]
analogin1 = analogin[1]
# etc
Gstat is a useful library for working with linuxcnc in python
(not sure what version of linuxcnc you are using.)
linuxcnc.org/docs/devel/html/gui/gstat.html
Last edit: 29 Jun 2022 01:46 by cmorley.
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
29 Jun 2022 06:29 #246136
by beefy
that's great info. So it looks like it's a mixture of Python and Hal for that sort of stuff.
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Thanks Andy,I think that the results you see in LinuxCNC status are the G-code digital inputs and outputs. ie the values of motion.digital-in/out-NN which are controlled by the M65 command (and friends)
If you want the value of an actual physical IO then you need to look at the value of the corresponding HAL pin.
import hal v = hal.get_value("hm2_7i76E.0.input-00") For example. https://linuxcnc.org/docs/stable/html/hal/halmodule.html There is also a way to trigger a callback on a HAL pin value change, though that is a little more involved.
that's great info. So it looks like it's a mixture of Python and Hal for that sort of stuff.
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
29 Jun 2022 06:37 #246137
by beefy
I knew how to do the first part of the code but wasn't up to the second bit you showed me, where you get individual values from the tuple, so that's useful.
Problem is I wouldn't know what the analogue value referred to. In Andy's example it states the input I'm reading is input number 0, on 7i76E, board number 0.
So at present the Linuxcnc Status values such as "ain", "din", "dout", etc are a complete mystery to me.
Thanks for the info and link to Gstat too.
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Thanks Cmorley,
[/code]import linuxcnc s = linuxcnc.stat() s.poll() analogin = s.ain That gives you a python tuple (a specific python type of list) of the (default number of) 64 integer values. To just get a specific integer use this: [code]# used with code above. analogin0 = analogin[0] analogin1 = analogin[1] # etc Gstat is a useful library for working with linuxcnc in python (not sure what version of linuxcnc you are using.) http://linuxcnc.org/docs/devel/html/gui/gstat.html
I knew how to do the first part of the code but wasn't up to the second bit you showed me, where you get individual values from the tuple, so that's useful.
Problem is I wouldn't know what the analogue value referred to. In Andy's example it states the input I'm reading is input number 0, on 7i76E, board number 0.
So at present the Linuxcnc Status values such as "ain", "din", "dout", etc are a complete mystery to me.
Thanks for the info and link to Gstat too.
Please Log in or Create an account to join the conversation.
- phillc54
- Offline
- Platinum Member
Less
More
- Posts: 5707
- Thank you received: 2085
29 Jun 2022 07:26 #246138
by phillc54
Replied by phillc54 on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
29 Jun 2022 09:29 #246145
by beefy
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Cheers Phill. The rabbit hole deepens LOL.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
29 Jun 2022 10:28 #246147
by andypugh
linuxcnc.org/docs/stable/html/gcode/m-code.html#mcode:m62-m65
These are how G-code can interact with the HAL layer with no programming. These (and only these) are the ain / din pins in the stat structure
Your Python code has several ways in which it, in turn, can interact with HAL.
First note that all physical IO has to pass through HAL.
Your Python component can create its own HAL pins. You can hook them up in HAL and the values of the Python variables will then update immediately when the HAL value changes.
Your Python code can query HAL by pin name and get the value of a pin, by polling.
Or, you can use GStat to hook a callback to a HAL pin.
And, you can do all these at the same time, if you want.
Replied by andypugh on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
To elaborate. G-code has virtual digital and analogue inputs, that link to HAL pins and are controlled by G-codes:They are from motion:
linuxcnc.org/docs/devel/html/man/man9/motion.9.html
linuxcnc.org/docs/stable/html/gcode/m-code.html#mcode:m62-m65
These are how G-code can interact with the HAL layer with no programming. These (and only these) are the ain / din pins in the stat structure
Your Python code has several ways in which it, in turn, can interact with HAL.
First note that all physical IO has to pass through HAL.
Your Python component can create its own HAL pins. You can hook them up in HAL and the values of the Python variables will then update immediately when the HAL value changes.
Your Python code can query HAL by pin name and get the value of a pin, by polling.
Or, you can use GStat to hook a callback to a HAL pin.
And, you can do all these at the same time, if you want.
Please Log in or Create an account to join the conversation.
Time to create page: 0.077 seconds