- Posts: 42
- Thank you received: 5
best practice for creating a "digital twin" - simulation version of a real machi
- piflixe
- Offline
- Senior Member
-
Less
More
3 years 11 months ago #256606
by piflixe
best practice for creating a "digital twin" - simulation version of a real machi was created by piflixe
Dear LinuxCNC community!
I thought it would be practical to have a simulation version of our real machine. The simulation could be used to test several things eg. changes and compatibility on post-processor, tweaking of the UI or custom UI elements, changes to the ini config, training of team-members to the use of LinuxCNC etc.
So my aim is to have a digital twin version of the real machine, as close as possible without extraordinary effort or overhead. However, I would like the simulation to always reflect the latest changes to the config of the real machine. So I am wondering if there is best practice for that. I could think of several options:
- is there a way of having a "if SIMULATION" syntax in the config files?
- is there way of including / excluding certain files to the ini / hal? then the simulation / real machine sections could be stored in different files and the main file would only include parts of the configs that apply to both real machine and simulation config.
- something else?
Some links I found in the forum so far:
- simalar question , but unanswered
- tbc
thank you for your help!
I thought it would be practical to have a simulation version of our real machine. The simulation could be used to test several things eg. changes and compatibility on post-processor, tweaking of the UI or custom UI elements, changes to the ini config, training of team-members to the use of LinuxCNC etc.
So my aim is to have a digital twin version of the real machine, as close as possible without extraordinary effort or overhead. However, I would like the simulation to always reflect the latest changes to the config of the real machine. So I am wondering if there is best practice for that. I could think of several options:
- is there a way of having a "if SIMULATION" syntax in the config files?
- is there way of including / excluding certain files to the ini / hal? then the simulation / real machine sections could be stored in different files and the main file would only include parts of the configs that apply to both real machine and simulation config.
- something else?
Some links I found in the forum so far:
- simalar question , but unanswered
- tbc
thank you for your help!
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
-
Less
More
- Posts: 19899
- Thank you received: 4655
3 years 11 months ago #256619
by andypugh
Replied by andypugh on topic best practice for creating a "digital twin" - simulation version of a real machi
It is possible for HAL files to be written in Tcl, which can allow for conditional execution.
However it might be simpler to have two separate INI files which share the common stuff via an INCLUDE.
linuxcnc.org/docs/stable/html/config/ini....html#_include_files
So they would have some HAL files in common, and the same axis definitions, but one would connect to a Vismach model and one to the real hardware.
So each twin would have an INI something like:
And the other:
However it might be simpler to have two separate INI files which share the common stuff via an INCLUDE.
linuxcnc.org/docs/stable/html/config/ini....html#_include_files
So they would have some HAL files in common, and the same axis definitions, but one would connect to a Vismach model and one to the real hardware.
So each twin would have an INI something like:
Code:
#INCLUDE main.inc
[HAL]
common.hal
simulator.hal
And the other:
Code:
#INCLUDE main.inc
[HAL]
common.hal
hardware.hal
The following user(s) said Thank You: piflixe, Vector
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
-
Less
More
- Posts: 19899
- Thank you received: 4655
3 years 11 months ago #256620
by andypugh
Replied by andypugh on topic best practice for creating a "digital twin" - simulation version of a real machi
Just be aware that any [SECTION] that needs to be different has to be included in its entirety, you can't distribute a [SECTION] throughout the substantive document.
Please Log in or Create an account to join the conversation.
- piflixe
- Offline
- Senior Member
-
Less
More
- Posts: 42
- Thank you received: 5
3 years 11 months ago #256680
by piflixe
Replied by piflixe on topic best practice for creating a "digital twin" - simulation version of a real machi
thanks so much for the quick reply! I will try that straight away.
Yes I thought that [SECTION]s can't be torn apart but thanks anyway for the hint!
Yes I thought that [SECTION]s can't be torn apart but thanks anyway for the hint!
Please Log in or Create an account to join the conversation.
- piflixe
- Offline
- Senior Member
-
Less
More
- Posts: 42
- Thank you received: 5
3 years 11 months ago #257896
by piflixe
Replied by piflixe on topic best practice for creating a "digital twin" - simulation version of a real machi
I tried splitting the ini file as described above. I then copied the hal files from the simulation example into the config folder and linked them in the [HAL] section.
However, homing seems not to work correctly. I think the reason for this is that my homing direction is different than in the simulation example. I tried to figure out how the simulated_home.hal works but I couldn't find the virtual home switches in the hal file.
Could anyone point out to me how I can solve this or give some advice?
Thank you!
However, homing seems not to work correctly. I think the reason for this is that my homing direction is different than in the simulation example. I tried to figure out how the simulated_home.hal works but I couldn't find the virtual home switches in the hal file.
Could anyone point out to me how I can solve this or give some advice?
Thank you!
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
-
Less
More
- Posts: 19899
- Thank you received: 4655
3 years 11 months ago #257903
by andypugh
Replied by andypugh on topic best practice for creating a "digital twin" - simulation version of a real machi
You probably found the file?
github.com/LinuxCNC/linuxcnc/blob/master...b/simulated_home.hal
It is using the "comp" HAL component to make something that behaves a bit like a home switch:
linuxcnc.org/docs/stable/html/man/man9/comp.9.html
(the hysteresis makes it behave a little like a real switch)
This sets the home switch positions, you would probably need to change the numbers.
And You might also need to swap in0 and in1 for each comp so that it works in the direction that you want.
Also, personally I would change
To
Which has exactly the same effect.
It is using the "comp" HAL component to make something that behaves a bit like a home switch:
linuxcnc.org/docs/stable/html/man/man9/comp.9.html
(the hysteresis makes it behave a little like a real switch)
This sets the home switch positions, you would probably need to change the numbers.
Code:
net Xhomeswpos => comp_x.in0
net Yhomeswpos => comp_y.in0
net Zhomeswpos => comp_z.in0
sets Xhomeswpos 1
sets Yhomeswpos .5
sets Zhomeswpos 2
And You might also need to swap in0 and in1 for each comp so that it works in the direction that you want.
Also, personally I would change
Code:
net Xhomeswpos => comp_x.in0
sets Xhomeswpos 1
To
Code:
setp comp_x.in0 1
Which has exactly the same effect.
Please Log in or Create an account to join the conversation.
Time to create page: 0.158 seconds