Linuxcnc equivalent of UCCNC macros, macroloops, plugins
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
11 Jun 2022 22:37 - 11 Jun 2022 22:39 #244963
by beefy
Linuxcnc equivalent of UCCNC macros, macroloops, plugins was created by beefy
When I used UCCNC I got into writing macros, macroloops, and plugins.
I'm starting all over again with Linuxcnc and don't know what the equivalents are in Linuxcnc.
A custom macro was simply a bit of C# code that ran once. It could be called from the gcode or a custom screen button could call it.
A macroloop is like a self repeating macro. It is described as follows (from the manual):
Macro loops are program loops or in other words software threads. These threads can run one macro in an infinite loop.
The loop runs in the background, asynchronously and independently from the other operations of the software.
A macro loop can do it's own task while the software is operating and doing the user commanded operations.
For example the macro in a loop can continuously monitor the value of a DRO and can trigger outputs of the motion controller based on the value read from the DRO or it can write new values to another DRO.
One thing we recommend not to do is executing G-code and other motion commands from a macro loop, because they could conflict with other motions commanded by the user via the UCCNC GUI interface.
There are currently 48 available macro loop slots which means that up to 48 macros can be placed and run in separated threads.
A plugin is more powerful and can utilise the full object oriented programming capability of C#.
It gets compiled into a DLL (dynamic link library file) using an IDE like Microsoft Visual Studio, and like a macroloop it runs in the background independent of the running gcode.
So I'm basically wondering where to start learning the equivalent in Linuxcnc.
What are the equivalents of macros, macroloops, and plugins, if equivalents of all three exist.
Where are they written/compiled, what language, and where are the finished files stored.
Not looking for a full tutorial, but instead wanting to know where to look/start learning.
I'm starting all over again with Linuxcnc and don't know what the equivalents are in Linuxcnc.
A custom macro was simply a bit of C# code that ran once. It could be called from the gcode or a custom screen button could call it.
A macroloop is like a self repeating macro. It is described as follows (from the manual):
Macro loops are program loops or in other words software threads. These threads can run one macro in an infinite loop.
The loop runs in the background, asynchronously and independently from the other operations of the software.
A macro loop can do it's own task while the software is operating and doing the user commanded operations.
For example the macro in a loop can continuously monitor the value of a DRO and can trigger outputs of the motion controller based on the value read from the DRO or it can write new values to another DRO.
One thing we recommend not to do is executing G-code and other motion commands from a macro loop, because they could conflict with other motions commanded by the user via the UCCNC GUI interface.
There are currently 48 available macro loop slots which means that up to 48 macros can be placed and run in separated threads.
A plugin is more powerful and can utilise the full object oriented programming capability of C#.
It gets compiled into a DLL (dynamic link library file) using an IDE like Microsoft Visual Studio, and like a macroloop it runs in the background independent of the running gcode.
So I'm basically wondering where to start learning the equivalent in Linuxcnc.
What are the equivalents of macros, macroloops, and plugins, if equivalents of all three exist.
Where are they written/compiled, what language, and where are the finished files stored.
Not looking for a full tutorial, but instead wanting to know where to look/start learning.
Last edit: 11 Jun 2022 22:39 by beefy.
Please Log in or Create an account to join the conversation.
- spumco
- Offline
- Platinum Member
Less
More
- Posts: 1831
- Thank you received: 741
11 Jun 2022 23:12 #244964
by spumco
Replied by spumco on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
I've no experience writing macroloops in UCCNC - never made it that far before I walked away from it. But I understand the concepts (sort-of), and used a few that other folks had written for me.
I think the equivalent can be found in a combination of HAL, Classic Ladder, and subroutines. Classic ladder can be connected to HAL pins (hardware or software pins), and the ladder just runs looking for input or state changes. A PLC function is one of those things UCCNC just doesn't have, but the macroloop is, I believe, the equivalent.
Functions similar to macroloops can be accomplished directly in HAL as well. For example, I have an air blast feature set up strictly in HAL that's pretty useful. I connected a physical momentary button to a multi-click HAL component, and also connected two analog pots.
A long press on the button simply opens the air solenoid; release it and it turns off.
A short press (multi-click single-press) activates a HAL time-delay relay component that pulses the air on and off. One pot controls the ON time, another the OFF time.
A double-short press (multi-click double-press) cancels the pulsing function.
With some fiddling, the same 'manual-pulse-off' scheme could be connected to motion.digital-out-NN and motion.digital-in-NN, and the whole thing could be set up as a user M-code in a subroutine.
Or a combination of CL, HAL, and subroutines.
While you're waiting for someone much more experienced to respond, start reviewing the CL section of the user manual. And have a look in the CL forum section on what people are accomplishing with it. "Feral Engineer" has some very good videos on YT explaining the basics if you're not familiar with PLC's and ladder logic.
I think the equivalent can be found in a combination of HAL, Classic Ladder, and subroutines. Classic ladder can be connected to HAL pins (hardware or software pins), and the ladder just runs looking for input or state changes. A PLC function is one of those things UCCNC just doesn't have, but the macroloop is, I believe, the equivalent.
Functions similar to macroloops can be accomplished directly in HAL as well. For example, I have an air blast feature set up strictly in HAL that's pretty useful. I connected a physical momentary button to a multi-click HAL component, and also connected two analog pots.
A long press on the button simply opens the air solenoid; release it and it turns off.
A short press (multi-click single-press) activates a HAL time-delay relay component that pulses the air on and off. One pot controls the ON time, another the OFF time.
A double-short press (multi-click double-press) cancels the pulsing function.
With some fiddling, the same 'manual-pulse-off' scheme could be connected to motion.digital-out-NN and motion.digital-in-NN, and the whole thing could be set up as a user M-code in a subroutine.
Or a combination of CL, HAL, and subroutines.
While you're waiting for someone much more experienced to respond, start reviewing the CL section of the user manual. And have a look in the CL forum section on what people are accomplishing with it. "Feral Engineer" has some very good videos on YT explaining the basics if you're not familiar with PLC's and ladder logic.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7777
- Thank you received: 2073
12 Jun 2022 07:06 #244976
by cmorley
Replied by cmorley on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
if you need fast, motion related routines then realtime components is what linuxcnc uses.
you can code then in restricted c or c-like language called comp.
linuxcnc.org/docs/devel/html/hal/comp.html
If slower response is ok and less restricted libraries are needed then user space components are used. They can be programmed in many languages, but python is very popular.
eg.
linuxcnc.org/docs/devel/html/hal/halmodule.html
linuxcnc.org/docs/devel/html/config/python-interface.html
Give an idea of what you want to program and we can offer more info.
Chris
you can code then in restricted c or c-like language called comp.
linuxcnc.org/docs/devel/html/hal/comp.html
If slower response is ok and less restricted libraries are needed then user space components are used. They can be programmed in many languages, but python is very popular.
eg.
linuxcnc.org/docs/devel/html/hal/halmodule.html
linuxcnc.org/docs/devel/html/config/python-interface.html
Give an idea of what you want to program and we can offer more info.
Chris
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
12 Jun 2022 07:37 #244978
by robertspark
Replied by robertspark on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Keith
what are you trying to do?
post the uccnc macroloop, and I'll take a look.
I am no linuxcnc expert but may be able to translate or show a way to do it
what are you trying to do?
post the uccnc macroloop, and I'll take a look.
I am no linuxcnc expert but may be able to translate or show a way to do it
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
12 Jun 2022 08:26 #244980
by beefy
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Thanks very much everyone.
I'm not trying to do anything specific at the moment. I'm not the type of guy who only starts learning when I need to do something. I tend to learn what the software can do then I find uses for it.
So at the moment just trying to understand how Lcnc does the aforementioned things that UCCNC does.
Having said that, when I was using UCCNC for my plasma table I made my own torch height controller. All the high speed stuff was done with an AVR microcontroller reading a Mesa THCAD card frequency output.
In UCCNC I wrote a DLL plugin in C# to communicate with a serial connection to the microcontroller. The plugin would read parameters from my custom screenset DROs, and send that info serially to the microcontroller. The microcontroller would read the voltage (freq. from the Mesa card) and send the voltage value back to UCCNC over the serial connection. After the plugin recieved these values it would update the custom screenset DROs. There were also things like screen LEDs that displayed if the THC (microcontroller) had locked the torch height when crossing a void, etc.
It was very exciting being able to do that sort of stuff. Right now though I'm at the rather clueless stage with Linuxcnc LOL.
I'm not trying to do anything specific at the moment. I'm not the type of guy who only starts learning when I need to do something. I tend to learn what the software can do then I find uses for it.
So at the moment just trying to understand how Lcnc does the aforementioned things that UCCNC does.
Having said that, when I was using UCCNC for my plasma table I made my own torch height controller. All the high speed stuff was done with an AVR microcontroller reading a Mesa THCAD card frequency output.
In UCCNC I wrote a DLL plugin in C# to communicate with a serial connection to the microcontroller. The plugin would read parameters from my custom screenset DROs, and send that info serially to the microcontroller. The microcontroller would read the voltage (freq. from the Mesa card) and send the voltage value back to UCCNC over the serial connection. After the plugin recieved these values it would update the custom screenset DROs. There were also things like screen LEDs that displayed if the THC (microcontroller) had locked the torch height when crossing a void, etc.
It was very exciting being able to do that sort of stuff. Right now though I'm at the rather clueless stage with Linuxcnc LOL.
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
12 Jun 2022 08:45 #244981
by robertspark
Replied by robertspark on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
I would suggest hal components would be the preferred way to do things.
the components are added to the servo loop and run in a sequential macro loop type arrangement.
hal is impressive when you get your head into it.
just think of them like electronic components and you wire (link) them from an input to and output / series or inputs to outputs.
the naming convention of finding what I want (or rather want it to do) takes the time imo when you are not used to it.
I would suggest maybe creating something (anything) to have a go at seeing how hal works.
the components are added to the servo loop and run in a sequential macro loop type arrangement.
hal is impressive when you get your head into it.
just think of them like electronic components and you wire (link) them from an input to and output / series or inputs to outputs.
the naming convention of finding what I want (or rather want it to do) takes the time imo when you are not used to it.
I would suggest maybe creating something (anything) to have a go at seeing how hal works.
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
12 Jun 2022 09:09 - 12 Jun 2022 09:10 #244982
by beefy
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
And can you add Python coding to hal components. Example if you wanted to check a variable is within a range, or greater than a certain value, or any other other reason you may need code.
Anyway looks like I need to get familiar with hal and Classicladder to start, and see what those offer.
Anyway looks like I need to get familiar with hal and Classicladder to start, and see what those offer.
Last edit: 12 Jun 2022 09:10 by beefy.
Please Log in or Create an account to join the conversation.
- robertspark
- Offline
- Platinum Member
Less
More
- Posts: 915
- Thank you received: 216
12 Jun 2022 10:22 #244983
by robertspark
Replied by robertspark on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
python will not run realtime as far as I am aware.
________________
you could use the near component to provide a TRUE if within range linuxcnc.org/docs/devel/html/man/man9/near.9.html
___________________
you can rescale values with one of the limit components (there are a few)
linuxcnc.org/docs/devel/html/man/man9/limit1.9.html
___________________
basically I spend my time trawling through the components at the bottom of. the documentation
linuxcnc.org/docs/devel/html/
_______________
classic ladder is the same / similar to mach3 "brains"
I dabbled with it but am not good at using it.
hal seems to do everything I need but it is probably a neater / more diagmamatic solution.
there are a few of these you can watch through.... if you used brains you could probably skim through
________________
you could use the near component to provide a TRUE if within range linuxcnc.org/docs/devel/html/man/man9/near.9.html
___________________
you can rescale values with one of the limit components (there are a few)
linuxcnc.org/docs/devel/html/man/man9/limit1.9.html
___________________
basically I spend my time trawling through the components at the bottom of. the documentation
linuxcnc.org/docs/devel/html/
_______________
classic ladder is the same / similar to mach3 "brains"
I dabbled with it but am not good at using it.
hal seems to do everything I need but it is probably a neater / more diagmamatic solution.
there are a few of these you can watch through.... if you used brains you could probably skim through
Please Log in or Create an account to join the conversation.
- beefy
- Offline
- Elite Member
Less
More
- Posts: 224
- Thank you received: 56
12 Jun 2022 12:30 #244990
by beefy
Replied by beefy on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
Cheers Rob, that's some good links you supplied.
I already had that Feral Engineer video open in one of my Chrome tabs LOL.
Been smashing my brain reading through the manual and read about the two types of hal files (standard & tcl). The tcl hal files have "computational" capability with tcl scripting.
Seen Classicladder has max speed of 1000 hz, so whenever CL will do the job the speed is not bad.
And if I'm reading between the lines correctly a custom macro is done with "O" commands but running custom Python code in the subroutine. I'm sure I read in a forum thread earlier that in Linuxcnc there is no such thing as a custom macro, and it's done in a subroutine.
Slowly working my way there. Looks like I need to learn some Python too.
I already had that Feral Engineer video open in one of my Chrome tabs LOL.
Been smashing my brain reading through the manual and read about the two types of hal files (standard & tcl). The tcl hal files have "computational" capability with tcl scripting.
Seen Classicladder has max speed of 1000 hz, so whenever CL will do the job the speed is not bad.
And if I'm reading between the lines correctly a custom macro is done with "O" commands but running custom Python code in the subroutine. I'm sure I read in a forum thread earlier that in Linuxcnc there is no such thing as a custom macro, and it's done in a subroutine.
Slowly working my way there. Looks like I need to learn some Python too.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23170
- Thank you received: 4860
15 Jun 2022 10:26 #245176
by andypugh
Replied by andypugh on topic Linuxcnc equivalent of UCCNC macros, macroloops, plugins
To add to the baffling array of options...
Codes M100 to M199 can call any executable file. (including bash and python scripts)
Also, LinuxCNC G-code has loops and conditional execution controlled by O-codes eg:
I would suggest choosing one of custom HAL components (in C for realtime or Python / C / C++ for non-realtme) or ClassicLadder.
Personally I know enough C to have never needed CL. If I knew ladder, I probably wouldn't have used custom comps.
Also note that Tcl HAL files only run once, at startup. They can conditionally make HAL connections, but once the HAL is set up no more processing happens in the files.
Codes M100 to M199 can call any executable file. (including bash and python scripts)
Also, LinuxCNC G-code has loops and conditional execution controlled by O-codes eg:
O100 REPEAT[100}
M100
O200 IF [#1 NE 0]
M101
O200 ENDIF
O100 ENDREPEAT
I would suggest choosing one of custom HAL components (in C for realtime or Python / C / C++ for non-realtme) or ClassicLadder.
Personally I know enough C to have never needed CL. If I knew ladder, I probably wouldn't have used custom comps.
Also note that Tcl HAL files only run once, at startup. They can conditionally make HAL connections, but once the HAL is set up no more processing happens in the files.
Please Log in or Create an account to join the conversation.
Time to create page: 0.166 seconds