Controlling Linuxcnc machine with Digital Twin over MQTT

More
18 Oct 2022 12:48 #254404 by mdi13
Hi everyone,I have a Linuxcnc machine and a Digital Twin (DT) and want to control the machine with DT over MQTT. The DT publishes the .json format data and the linuxcnc subscribes to the defined topic to get the data. (The digital twin installed on an Ubuntu system and the version of linuxcnc is 2.8). Here is also a schematic of what I want to do:
  For example we want to stop machine from digital twin and there is a stop button in DT. When I press that virtual button, the related variable which stored in .json file changes and this change publishes by MQTT. In the other side the python code should receive this message and extract the data and implement the commands. As soon as the stop variable become 1, the command for stopping the machine will send to it using Linuxcnc library in python.The problem which I have is this: When I change the values and the parameters in DT, the MQTT client disconnects and the commands which should be sent to linuxcnc do not send.I separated the code into two parts. First I checked the connection between linuxcnc PC and the machine with python library and commands with python worked properly. Then I checked the connection between DT and linuxcnc PC (MQTT client) and I could get the data without any disconnecting. But when I tried to put these two subjects in one code the mentioned problem occurs. Here I attached the code.

 

File Attachment:

File Name: pycode_2022-10-18.py
File Size:1 KB
Do you have any experience about this issue and how to solve it?
Attachments:

Please Log in or Create an account to join the conversation.

More
19 Oct 2022 13:19 #254522 by rmu
E-Stop via MQTT is potentially unreliable and therefore dangerous.

To your problem: I would first try receiving the message without anything linuxcnc and then go from there. Also watch for error messages/exceptions. Look at log file of your MQTT broker.
The following user(s) said Thank You: mdi13

Please Log in or Create an account to join the conversation.

More
20 Oct 2022 07:04 #254589 by mdi13
Thanks for your answer and also recommendations.

Here I use estop as an example. I have a physical estop. The main problem is losing the connection.
I tried it without linuxcnc and everything worked perfectly. But when it comes to linuxcnc commands, the connection is lost.
I will check the log file also.
Thanks again.

Please Log in or Create an account to join the conversation.

More
20 Nov 2022 00:34 #257134 by pevlabs
Hello, I am exploring trying to do some very basic linuxCNC control functions via MQTT. Did you make anymore progress on this. I find this a very fascinating topic as I have strong interest in industry 4.0.

Brian

Please Log in or Create an account to join the conversation.

Time to create page: 0.945 seconds
Powered by Kunena Forum