- LinuxCNC
- General LinuxCNC Questions
- How would you design a real time application for cnc control in c / c++ ???
How would you design a real time application for cnc control in c / c++ ???
02 Mar 2022 09:50 #236162
by udoS
Replied by udoS on topic How would you design a real time application for cnc control in c / c++ ???
@Grotius and
@Reinhard
Hallo Grotius, hallo Reinhard
But you don't need hal to create a cnc program like lcnc. --> I thought so.
I think that a Software-PLC is just the same thing as the HAL plus a bit more.
The point is: How do I get all the pins... into a "PLC-HAL" to work with them inside the PLC.
For now I have a module that read from / write into the HAL. I thought there should be a way to bypass the HAL.
How can that be done ?
@Grotius: How many segments of a live-toolpath can you build before the graphics slowing down to much.
best regards. udos
@Reinhard
Hallo Grotius, hallo Reinhard
But you don't need hal to create a cnc program like lcnc. --> I thought so.
I think that a Software-PLC is just the same thing as the HAL plus a bit more.
The point is: How do I get all the pins... into a "PLC-HAL" to work with them inside the PLC.
For now I have a module that read from / write into the HAL. I thought there should be a way to bypass the HAL.
How can that be done ?
@Grotius: How many segments of a live-toolpath can you build before the graphics slowing down to much.
best regards. udos
Please Log in or Create an account to join the conversation.
02 Mar 2022 14:40 #236182
by Reinhard
Replied by Reinhard on topic How would you design a real time application for cnc control in c / c++ ???
Hi
> I thought there should be a way to bypass the HAL.
> How can that be done ?
What do you want to achieve by redeveloping?
Unlike the user interfaces, Hal is the workhorse in the background. Completely invisible and extremely versatile. I would argue that Hal is the best thing about linuxcnc ever. So I understand that most are writing new user interfaces. As we all know, there is no accounting for taste.
I see it completely differently with Hal. It's an insane amount of work to recreate Hal and I doubt you'll get anywhere near the functionality of the original. So why replace something that works perfectly?
In my opinion Grotius way is the only right way: kick out all the crap of Linuxcnc and use only the most necessary (HAL).
So I can only give you the advice: try to understand hal-core and then use it, or adapt it to your needs.
Everything else I personally think is a waste of time.
> I thought there should be a way to bypass the HAL.
> How can that be done ?
What do you want to achieve by redeveloping?
Unlike the user interfaces, Hal is the workhorse in the background. Completely invisible and extremely versatile. I would argue that Hal is the best thing about linuxcnc ever. So I understand that most are writing new user interfaces. As we all know, there is no accounting for taste.
I see it completely differently with Hal. It's an insane amount of work to recreate Hal and I doubt you'll get anywhere near the functionality of the original. So why replace something that works perfectly?
In my opinion Grotius way is the only right way: kick out all the crap of Linuxcnc and use only the most necessary (HAL).
So I can only give you the advice: try to understand hal-core and then use it, or adapt it to your needs.
Everything else I personally think is a waste of time.
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
Less
More
- Posts: 19188
- Thank you received: 6433
02 Mar 2022 14:50 #236188
by tommylight
Replied by tommylight on topic How would you design a real time application for cnc control in c / c++ ???
I wholeheartedly agree with the above, it was HAL that got me hooked to LinuxCNC, and AXIS GUI helped with that elegant simplicity.Unlike the user interfaces, Hal is the workhorse in the background. Completely invisible and extremely versatile. I would argue that Hal is the best thing about linuxcnc ever.
The following user(s) said Thank You: Grotius
Please Log in or Create an account to join the conversation.
02 Mar 2022 19:18 - 02 Mar 2022 19:20 #236210
by udoS
Replied by udoS on topic How would you design a real time application for cnc control in c / c++ ???
Hallo
@Grotius
How can that be rebuild. Starting just before Nr.1;
// tricky to understand.// LoL // The understatement of the year
But exactly the point. How to get the pins... etc from the CNC and after the fiddling back.
As I understand it there is a CNC-Kernel and there is a HAL. ( Hardware Abstraction Layer ).
If I look at the schematic in the manual there is a clear cut between the both of it.
In simple terms - the HAL is the wiring terminal between CNC and the Hardware world .
For anything else you need a component. Even it is just an AND or OR or ... comp ..or...... and so on.
// Completely invisible and extremely versatile // neither - nor // ??? It better be. !!!!!
I was just looking into the idea to have an other clean box for the ins and outs and doing the wiring somewhere else.
best regards. udos
@Grotius
How can that be rebuild. Starting just before Nr.1;
// tricky to understand.// LoL // The understatement of the year
But exactly the point. How to get the pins... etc from the CNC and after the fiddling back.
As I understand it there is a CNC-Kernel and there is a HAL. ( Hardware Abstraction Layer ).
If I look at the schematic in the manual there is a clear cut between the both of it.
In simple terms - the HAL is the wiring terminal between CNC and the Hardware world .
For anything else you need a component. Even it is just an AND or OR or ... comp ..or...... and so on.
// Completely invisible and extremely versatile // neither - nor // ??? It better be. !!!!!
I was just looking into the idea to have an other clean box for the ins and outs and doing the wiring somewhere else.
best regards. udos
Last edit: 02 Mar 2022 19:20 by udoS.
Please Log in or Create an account to join the conversation.
03 Mar 2022 06:43 #236246
by Grotius
Replied by Grotius on topic How would you design a real time application for cnc control in c / c++ ???
Hi,
Reinhard explanation is perfect.
Understanding the interaction between : hal, componenents, halcompile, user interface's is difficult.
Some key principle's :
1. Hal
Reinhard explanation is perfect.
Understanding the interaction between : hal, componenents, halcompile, user interface's is difficult.
Some key principle's :
1. Hal
- Hal is everything inside the "golden ring", this means at linux kernel level. The surface (kernel output) is visible in Userland. Just Duckduck some keywords to see the encircled layering of this .
- Talking from kernel-land to user-land and visa-versa requires coding skills. You have different thread's (speeds) running around. Some things have to wait (interupts).
- Hal is a "kernel module". It's capable to insert other kernel modules. The top level hal module is designed in such a way that the "child modules" can talk with each other trough shared memory (Hal uses a ringbuffer in shared memory to enchange data).
- Halcompile uses a .comp extension. This is just a preprocess (custom script language) to become a compiled .so. (kernel module) My personal view is that halcompile would be better not used, because it limit's programming options, and most users are not aware of this. For full power, you need to be able to compile with gcc directly.
Please Log in or Create an account to join the conversation.
03 Mar 2022 11:18 #236252
by udoS
Replied by udoS on topic How would you design a real time application for cnc control in c / c++ ???
Hallo Grotius
thanks for explaining, and not just merely make a statement or offer an opinion.
I was asking earlier about that hal-view of yours, but if its gone its gone.
What happen now: and correct me if I'm wrong.
At startup lcnc starts with .ini looking for configuration.
Then loading what it gets from .hal files.
With all that it is providing the ins and outs pins, signals etc... in the hal.
Now there are all these pins available in the HAL.
What I like to archive: Getting a mirror or image of ALL those pins etc.. at best at the time of creation.
How I do it as of now: I use a kind of blank template module with a shared memory and semaphore.
Then I configure the machine in .ini and .hal .
Then getting the pins from the HAL and filling the template.
Now I have the HAL pins and the image-pins inside the HAL.
Then connect the image-pins to tie hal-pins 1 to 1 .
LCNC now starts without asking any more questions.
From this point on I can fiddle with the signals / pins live.
I just thought there ought to be an easier way to get there.
best Regards. udos
thanks for explaining, and not just merely make a statement or offer an opinion.
I was asking earlier about that hal-view of yours, but if its gone its gone.
What happen now: and correct me if I'm wrong.
At startup lcnc starts with .ini looking for configuration.
Then loading what it gets from .hal files.
With all that it is providing the ins and outs pins, signals etc... in the hal.
Now there are all these pins available in the HAL.
What I like to archive: Getting a mirror or image of ALL those pins etc.. at best at the time of creation.
How I do it as of now: I use a kind of blank template module with a shared memory and semaphore.
Then I configure the machine in .ini and .hal .
Then getting the pins from the HAL and filling the template.
Now I have the HAL pins and the image-pins inside the HAL.
Then connect the image-pins to tie hal-pins 1 to 1 .
LCNC now starts without asking any more questions.
From this point on I can fiddle with the signals / pins live.
I just thought there ought to be an easier way to get there.
best Regards. udos
Please Log in or Create an account to join the conversation.
03 Mar 2022 14:46 #236261
by Reinhard
Replied by Reinhard on topic How would you design a real time application for cnc control in c / c++ ???
>> Completely invisible and extremely versatile // neither - nor // ??? It better be. !!!!!
You seem to have something mixed up. What I wrote about Hal referred to "using Hal", not "patching Hal".
If you want to control a machine with linuxcnc, you don't need to care much about Hal. PncConf already takes care of everything.
You just need to carefully fill in the pages of PncConf and you will get a Hal configuration ready configured and ready to use.
I am convinced that there are many CNC machines controlled by linuxcnc where the users did not bothered much about Hal.
However, if you want to modify Hal, then you have to dive deep into the source code and it is essential that you understand the big picture and lot of details. Only then will you be able to make meaningful changes. The learning curve is hard work. Even more if you never had to deal with Linux kernel before.
>> and not just merely make a statement or offer an opinion.
As far as that is concerned, I wanted to make you think!
Depending on what you want to achieve, there are different paths you should follow: if your goal is to control a machine, then learn how to use pncconf.
If you have more advanced wishes that are not covered by linuxcnc, then you have to learn yourself. Nobody will do the work for you and you can't expect bite-sized tips. Hal is much too complex for that.
If it becomes apparent that you are learning the ropes, then you will certainly receive more qualified tips.
You seem to have something mixed up. What I wrote about Hal referred to "using Hal", not "patching Hal".
If you want to control a machine with linuxcnc, you don't need to care much about Hal. PncConf already takes care of everything.
You just need to carefully fill in the pages of PncConf and you will get a Hal configuration ready configured and ready to use.
I am convinced that there are many CNC machines controlled by linuxcnc where the users did not bothered much about Hal.
However, if you want to modify Hal, then you have to dive deep into the source code and it is essential that you understand the big picture and lot of details. Only then will you be able to make meaningful changes. The learning curve is hard work. Even more if you never had to deal with Linux kernel before.
>> and not just merely make a statement or offer an opinion.
As far as that is concerned, I wanted to make you think!
Depending on what you want to achieve, there are different paths you should follow: if your goal is to control a machine, then learn how to use pncconf.
If you have more advanced wishes that are not covered by linuxcnc, then you have to learn yourself. Nobody will do the work for you and you can't expect bite-sized tips. Hal is much too complex for that.
If it becomes apparent that you are learning the ropes, then you will certainly receive more qualified tips.
Please Log in or Create an account to join the conversation.
03 Mar 2022 23:54 #236296
by andypugh
I think that halcompile is very useful for simple components.
If you start with a simple component and then find that it has become complex, then it is possible to compile to a C file and then work with that (though that would require unwinding a lot of macros that are used to access internal data)
Replied by andypugh on topic How would you design a real time application for cnc control in c / c++ ???
My personal view is that halcompile would be better not used, because it limit's programming options, and most users are not aware of this. For full power, you need to be able to compile with gcc directly.
I think that halcompile is very useful for simple components.
If you start with a simple component and then find that it has become complex, then it is possible to compile to a C file and then work with that (though that would require unwinding a lot of macros that are used to access internal data)
Please Log in or Create an account to join the conversation.
04 Mar 2022 10:12 #236327
by rodw
X 2
I wrote a simple component recently for a user to activate a pneumatic ram when his Z axis was moving up to help take the load. He just loves it and it took all of 5 minutes to write...
I'm sure Andy the wizard could have done it with existing hal components but a component called liftaxis.comp is much clearer in his hal file as it self documents.
In my view this is Linuxcnc's hidden secret weapon!
Replied by rodw on topic How would you design a real time application for cnc control in c / c++ ???
I think that halcompile is very useful for simple components.
X 2
I wrote a simple component recently for a user to activate a pneumatic ram when his Z axis was moving up to help take the load. He just loves it and it took all of 5 minutes to write...
I'm sure Andy the wizard could have done it with existing hal components but a component called liftaxis.comp is much clearer in his hal file as it self documents.
In my view this is Linuxcnc's hidden secret weapon!
Please Log in or Create an account to join the conversation.
04 Mar 2022 10:32 #236329
by udoS
Replied by udoS on topic How would you design a real time application for cnc control in c / c++ ???
Hi, thanks to all for your comments.
My Master Aim: I like to use Linuxcnc as the motion controller and hook it to my software-plc.
That is it.
If any one is interested about it, most Wellcome. The interface to the plc is all in c++;
Best Regards. udos
My Master Aim: I like to use Linuxcnc as the motion controller and hook it to my software-plc.
That is it.
If any one is interested about it, most Wellcome. The interface to the plc is all in c++;
Best Regards. udos
Please Log in or Create an account to join the conversation.
- LinuxCNC
- General LinuxCNC Questions
- How would you design a real time application for cnc control in c / c++ ???
Time to create page: 0.119 seconds