Controlling spindle using python scripts and Modbus TCP
- davidgill
- Offline
- New Member
-
Less
More
- Posts: 1
- Thank you received: 0
10 Oct 2025 03:36 #336181
by davidgill
Controlling spindle using python scripts and Modbus TCP was created by davidgill
Hi All,
I have been playing with this for days and have not cracked it. I was using AI for answers but every solution failed. I want to do the following. I have the python code sorted but getting LinuxCNC to call the python scripts seems to be the problem. The python script sets the Modbus TCP registers on the VFD.Spindle forward, pass the value 1 to my python script as an argSpindle reverse, pass the value 2 to my python script as an argStop spindle, pass the value 5 to my python script as an argSpindle speed, pass a value between 0 and 200 to a python script.can anyone offer a solution. Cheers
I have been playing with this for days and have not cracked it. I was using AI for answers but every solution failed. I want to do the following. I have the python code sorted but getting LinuxCNC to call the python scripts seems to be the problem. The python script sets the Modbus TCP registers on the VFD.Spindle forward, pass the value 1 to my python script as an argSpindle reverse, pass the value 2 to my python script as an argStop spindle, pass the value 5 to my python script as an argSpindle speed, pass a value between 0 and 200 to a python script.can anyone offer a solution. Cheers
Please Log in or Create an account to join the conversation.
- Hakan
- Offline
- Platinum Member
-
Less
More
- Posts: 910
- Thank you received: 318
10 Oct 2025 06:43 #336183
by Hakan
Replied by Hakan on topic Controlling spindle using python scripts and Modbus TCP
Sounds like a user component.
There are some examples, for example the mitsub_vfd.py here github.com/LinuxCNC/linuxcnc/tree/master/src/hal/user_comps
There are some examples, for example the mitsub_vfd.py here github.com/LinuxCNC/linuxcnc/tree/master/src/hal/user_comps
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 19619
- Thank you received: 4526
10 Oct 2025 20:38 #336230
by andypugh
Replied by andypugh on topic Controlling spindle using python scripts and Modbus TCP
import linuxcnc and hal into the Python script, then create HAL pins to receive the spindle commands from HAL.
Load the Python script at load-time with a "loadusr" command in the HAL.
Load the Python script at load-time with a "loadusr" command in the HAL.
Please Log in or Create an account to join the conversation.
Time to create page: 0.070 seconds