- 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++ ???
29 Dec 2021 17:47 #230261
by bkt
Replied by bkt on topic How would you design a real time application for cnc control in c / c++ ???
In above example's nml is inside the lcnc rip and can be accesed by qt directly on the c++ level. There are example's
how to send and read commands to and from the nml server.
Thanks Grotius .... I've made some code with position logger example .... plus some other but Qt/C++ and NML exchange data through a "NEW" without the relative "DELETE" thus creating an overbuffer and the application crashes .... now I have never looked at whether it is possible at the end of the function to use "DELETE" without interrupting the channel communication with NML .... and in any case I was worried about the fact if you had solved this which is the main reason why I no longer wasted time on it .... besides, your hal-core solution excites me .... do you run it on rtai, ros or preempt? Excuse the stupid question but I didn't look inside the files ....
PLUS: ....where does opencascade get the values of the axes? Another stupid question ... but knowing it first makes it easier to understand where to focus more.
Real Thanks for all ....
bkt
how to send and read commands to and from the nml server.
Thanks Grotius .... I've made some code with position logger example .... plus some other but Qt/C++ and NML exchange data through a "NEW" without the relative "DELETE" thus creating an overbuffer and the application crashes .... now I have never looked at whether it is possible at the end of the function to use "DELETE" without interrupting the channel communication with NML .... and in any case I was worried about the fact if you had solved this which is the main reason why I no longer wasted time on it .... besides, your hal-core solution excites me .... do you run it on rtai, ros or preempt? Excuse the stupid question but I didn't look inside the files ....
PLUS: ....where does opencascade get the values of the axes? Another stupid question ... but knowing it first makes it easier to understand where to focus more.
Real Thanks for all ....
bkt
Please Log in or Create an account to join the conversation.
29 Dec 2021 18:24 #230263
by Grotius
Replied by Grotius on topic How would you design a real time application for cnc control in c / c++ ???
A while ago i made a universal lcnc widget.
Take your time and look into the c++ code. It has also a c++ to python converter under the hood.
That's why it looks a lot of code.
This project : github.com/grotius-cnc/universal_graphic_widget
This archive : github.com/grotius-cnc/universal_graphic...0.0/libpython.tar.gz
~/libpython/Qt_Nml_Python/src/nml_plugin.cpp
Has everything to interact with nml.
~/libpython/Qt_Occ_Python/src/opencascade.cpp
Has everything to preview dro's etc.
your hal-core solution excites me
Hal-core runs on preempt by default.
Currently it has no trajectory planner finished. I am working on it, but it takes more time then expected.
I could implement a traditional lineair acc, dcc planner. But i want to have the scurve with lineair transition implemented.
This can reduce machine production time by ~30% ~50%. The acceleration stage is the qlue.
Take your time and look into the c++ code. It has also a c++ to python converter under the hood.
That's why it looks a lot of code.
This project : github.com/grotius-cnc/universal_graphic_widget
This archive : github.com/grotius-cnc/universal_graphic...0.0/libpython.tar.gz
~/libpython/Qt_Nml_Python/src/nml_plugin.cpp
Has everything to interact with nml.
~/libpython/Qt_Occ_Python/src/opencascade.cpp
Has everything to preview dro's etc.
your hal-core solution excites me
Hal-core runs on preempt by default.
Currently it has no trajectory planner finished. I am working on it, but it takes more time then expected.
I could implement a traditional lineair acc, dcc planner. But i want to have the scurve with lineair transition implemented.
This can reduce machine production time by ~30% ~50%. The acceleration stage is the qlue.
Please Log in or Create an account to join the conversation.
02 Jan 2022 13:33 #230548
by aleksamc
It would be very nice (as for me - as uninitiated) to read some tutorials for this topic - how to do this. Like for example qtpyvcp.com
Replied by aleksamc on topic How would you design a real time application for cnc control in c / c++ ???
It's very interesting to read your story))) But it look like some cipher for the uninitiated (beginers).Option 2:
and how about hal_core? seems a good base for my project. It have some problem with nml or other library?
Hal-core is only using the hal environment of the original lcnc code. It is clean from Python, Nml, etc.
It has no smoke curtains like halcompile under the hood. It uses gcc and g++ commands to compile.
All lcnc components will work in hal-core.
Hal-core uses high level c++ library's from kernel space.
If you exactly know what you want to code, you can code it straight away in hal-core.
It takes some coding knowlegde.
It would be very nice (as for me - as uninitiated) to read some tutorials for this topic - how to do this. Like for example qtpyvcp.com
Please Log in or Create an account to join the conversation.
02 Jan 2022 14:22 #230553
by Grotius
Replied by Grotius on topic How would you design a real time application for cnc control in c / c++ ???
Hi,
to read some tutorials for this topic
I understand the difficulty for beginners. Currently i have no time to make tutorials like your qtpyvcp example.
The priority is the trajectory planner. This stagnates the hal-core project now.
Once that is implemented, there is time for making a tutorial.
On the other hand, i hope a participant can help making documentation.
To understand hal-core, sniffing into this directory will show you the components.
In hal-core some components are the executable program, like the opencascade component.
It doesn't use .ini files. It only uses .hal files or halcmd to load components. The component then loads a gui program if there is one. A more complex example program is the component "matrix". It's in the release section archive .
In general reading at the halmodule.c file's. This is where it starts.
to read some tutorials for this topic
I understand the difficulty for beginners. Currently i have no time to make tutorials like your qtpyvcp example.
The priority is the trajectory planner. This stagnates the hal-core project now.
Once that is implemented, there is time for making a tutorial.
On the other hand, i hope a participant can help making documentation.
To understand hal-core, sniffing into this directory will show you the components.
In hal-core some components are the executable program, like the opencascade component.
It doesn't use .ini files. It only uses .hal files or halcmd to load components. The component then loads a gui program if there is one. A more complex example program is the component "matrix". It's in the release section archive .
In general reading at the halmodule.c file's. This is where it starts.
The following user(s) said Thank You: aleksamc
Please Log in or Create an account to join the conversation.
02 Jan 2022 18:45 #230563
by aleksamc
Replied by aleksamc on topic How would you design a real time application for cnc control in c / c++ ???
As for your last reference - archive - reverse feed critically needed when is used electrical discharge cutting.
Thank you very much for your answer. But as for me I don't understand the basics: how to build and compile project (from git) in developing system (CodeBlocks for example). So I'm very-very bad programmer.
Thank you very much for your answer. But as for me I don't understand the basics: how to build and compile project (from git) in developing system (CodeBlocks for example). So I'm very-very bad programmer.
Please Log in or Create an account to join the conversation.
02 Jan 2022 19:53 #230568
by Grotius
Replied by Grotius on topic How would you design a real time application for cnc control in c / c++ ???
Hi,
how to build and compile project (from git) in developing system (CodeBlocks for example).
Don't worry about program skills. When hal-core has the trajectory planner running good times are coming.
Hal-core is not designed for skill programmers. It's designed to be clean of any entanglement.
We can add a CodeBlocks example to the todo list, good point!
You don't have to clone from git. You can just run the next commands in terminal for a basic install.
This install includes several programs like qt, hal-core, opencascade, kdl etc.
how to build and compile project (from git) in developing system (CodeBlocks for example).
Don't worry about program skills. When hal-core has the trajectory planner running good times are coming.
Hal-core is not designed for skill programmers. It's designed to be clean of any entanglement.
We can add a CodeBlocks example to the todo list, good point!
You don't have to clone from git. You can just run the next commands in terminal for a basic install.
This install includes several programs like qt, hal-core, opencascade, kdl etc.
wget https://raw.githubusercontent.com/grotius-cnc/hal-core/main/install_guide
chmod +x install_guide
sudo ./install_guide
sudo chmod -R -f 777 /opt
sudo chown -R $USER /opt
sudo chown -R $USER:$USER /opt
The following user(s) said Thank You: aleksamc
Please Log in or Create an account to join the conversation.
05 Jan 2022 09:27 - 05 Jan 2022 09:28 #230843
by aleksamc
Replied by aleksamc on topic How would you design a real time application for cnc control in c / c++ ???
Tried to install with your instruction, thanks.
But It seems that I have some errors when install because I don't see any changes in installed programs.
As my workstation I use Debian 11 Cinnamon.
Possibly I should use something else? I add some errors to the list.
But It seems that I have some errors when install because I don't see any changes in installed programs.
As my workstation I use Debian 11 Cinnamon.
Possibly I should use something else? I add some errors to the list.
Attachments:
Last edit: 05 Jan 2022 09:28 by aleksamc.
Please Log in or Create an account to join the conversation.
06 Jan 2022 00:27 #230913
by rodw
Replied by rodw on topic How would you design a real time application for cnc control in c / c++ ???
There is a missing dependency right at the end of your errors. Always look for the messages and do what it says and you'll get there
BUt if you are running debian 11 you might as well build from source.
BUt if you are running debian 11 you might as well build from source.
Please Log in or Create an account to join the conversation.
17 Jan 2022 19:40 - 17 Jan 2022 19:44 #232173
by bkt
best regards
BKT
Replied by bkt on topic How would you design a real time application for cnc control in c / c++ ???
Ok see but not real sure about hal user pin .... like lcec.0.1.din-00 .... and right way to start my app with linuxcnc .... for sure on INi file on DISPLAY macro i write "my_qt_cpp_app" .... but my app need to start linuxcnc first .... about these can start a "halrun" command like in your app skynet .... of for make a simple gui without axis only toggle and puch button for drive a classicladder program can use these program row:This archive : github.com/grotius-cnc/universal_graphic...0.0/libpython.tar.gz
~/libpython/Qt_Nml_Python/src/nml_plugin.cpp
Has everything to interact with nml.
#include "hal.h"
#include "cmainwindow.h"
#include "ui_cmainwindow.h"
#include <QStringList>
//hal realtime layertypedef struct {hal_float_t *pin;} float_data_t;
typedef struct {hal_bit_t *pin;} bit_data_t;
int comp_id = hal_init("gui");
/*float_data_t *float_data_0 = (float_data_t*)hal_malloc(sizeof(float_data_t));int retval0 = hal_pin_float_new("J2_POS_CMD",HAL_OUT,&cryingfloat_data_0->pin),comp_id);
float_data_t *float_data_1 = (float_data_t*)hal_malloc(sizeof(float_data_t));int retval1 = hal_pin_float_new("J3_POS_CMD",HAL_OUT,&cryingfloat_data_1->pin),comp_id);*/
//example to set up bit databit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));int retval01 = hal_pin_bit_new("valve_01",HAL_OUT,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));int retval02 = hal_pin_bit_new("valve_02",HAL_OUT,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));int retval03 = hal_pin_bit_new("valve_03",HAL_OUT,&cryingbit_data_0->pin),comp_id);bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));int retval04 = hal_pin_bit_new("valve_04",HAL_OUT,&cryingbit_data_0->pin),comp_id);bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));int retval05 = hal_pin_bit_new("valve_05",HAL_OUT,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));
int retval11 = hal_pin_bit_new("input_01",HAL_IN,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));
int retval12 = hal_pin_bit_new("input_02",HAL_IN,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));
int retval13 = hal_pin_bit_new("input_03",HAL_IN,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));
int retval14 = hal_pin_bit_new("input_04",HAL_IN,&cryingbit_data_0->pin),comp_id);
bit_data_t *bit_data_0 = (bit_data_t*)hal_malloc(sizeof(bit_data_t));
int retval15 = hal_pin_bit_new("input_05",HAL_IN,&cryingbit_data_0->pin),comp_id);
CMainWindow::CMainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::CMainWindow)
{
ui->setupUi(this);
m_3d_widget = new C3DWidget(this);
ui->gridLayout->addWidget(m_3d_widget,0,0);
//start ethercat..
system("halcmd \-f robot/Ethercat/ethercat.hal");
system("halcmd start");
}
CMainWindow::~CMainWindow()
{
hal_exit(comp_id);
system("halrun -U"); //this is really important.
delete ui;
}
best regards
BKT
Last edit: 17 Jan 2022 19:44 by bkt.
Please Log in or Create an account to join the conversation.
20 Jan 2022 15:08 #232535
by Grotius
Replied by Grotius on topic How would you design a real time application for cnc control in c / c++ ???
Hi Bkt,
If you take a look in this archive . It first starts lcnc. Then it start a gui app with a few hal pins.
Maybe this is what you are looking for?
If you take a look in this archive . It first starts lcnc. Then it start a gui app with a few hal pins.
Maybe this is what you are looking for?
The following user(s) said Thank You: bkt
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.107 seconds