Using Python for axis motion control
- mh300
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 3
16 Feb 2022 06:32 - 16 Feb 2022 06:33 #235014
by mh300
Using Python for axis motion control was created by mh300
Hello LinuxCNC Community,
I recently bought an old Industrial Mill (Maho MH 300 P), it's already sort of CNC, but with just one Motor that drives all three axes (one axis at the time). Since the old feed motor is worth more on the replacement market than a brand new Siemens Servo Drive + Motor, I already retrofitted the machine with a Siemens Servo controller and a small PLC.
Long term, I plan to do a full CNC conversion, with one servo motor per axis - I would like to use two additional Siemens servo drives (Siemens SINAMICS V90). As the CNC Control, I would like to use Linux CNC - but here I need to communicate with the drives via some specific protocols that are not supported by LinuxCNC as far as I know (Profinet/Profidrive).
I would like to use Python to interface with the drives. Are there any good examples for doing axis motion control using a python module?
Alternatively, if there is no way to do the axis motion control from python, are there any good C examples?
I recently bought an old Industrial Mill (Maho MH 300 P), it's already sort of CNC, but with just one Motor that drives all three axes (one axis at the time). Since the old feed motor is worth more on the replacement market than a brand new Siemens Servo Drive + Motor, I already retrofitted the machine with a Siemens Servo controller and a small PLC.
Long term, I plan to do a full CNC conversion, with one servo motor per axis - I would like to use two additional Siemens servo drives (Siemens SINAMICS V90). As the CNC Control, I would like to use Linux CNC - but here I need to communicate with the drives via some specific protocols that are not supported by LinuxCNC as far as I know (Profinet/Profidrive).
I would like to use Python to interface with the drives. Are there any good examples for doing axis motion control using a python module?
Alternatively, if there is no way to do the axis motion control from python, are there any good C examples?
Last edit: 16 Feb 2022 06:33 by mh300.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7777
- Thank you received: 2073
17 Feb 2022 05:03 #235096
by cmorley
Replied by cmorley on topic Using Python for axis motion control
If you want to use python for coordinated movement, that is not going to work.
C would work, it can be made realtime.
What physical interface to the computer will you use?
Do you know the protocol and can program C?
C would work, it can be made realtime.
What physical interface to the computer will you use?
Do you know the protocol and can program C?
Please Log in or Create an account to join the conversation.
- Roiki
- Offline
- Premium Member
Less
More
- Posts: 116
- Thank you received: 19
17 Feb 2022 14:05 #235133
by Roiki
Replied by Roiki on topic Using Python for axis motion control
Hal_streamer has a python api that you can use to stream component has a python api that you can use to Stream data from a queue to HAL. You can't inject it into the motion planner so the motion wouldn't be coordinated though.
Please Log in or Create an account to join the conversation.
- mh300
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 3
17 Feb 2022 14:59 #235142
by mh300
Thank you for your replies.
The Real-Time aspect is of course true, I wonder how bad it would be though, the 500mm/min moves aren't the fastest and I think the µm precision is a lost cause already. But to answer your questions:
What physical interface to the computer will you use?
The normal Ethernet Interface of the computer is used. Profinet works with standard Ethernet frames, TCP/IP is also used but only for the configuration of the devices. (Can be done with an external tool)
Do you know the protocol and can program C?
I have access to the Spec, but writing a full Profinet Controller (=Master) would be a massive undertaking. For a first test, I plan to use OPC UA, which has a pretty sophisticated C library available ( Github ). CodeSYS would take care of translating between OPC UA <-> Profinet and can be made to run in Realtime.
As for programming C: My skills are a bit rusty, but If the Linux CNC interface isn’t too complicated and on the other side I just need to work with the existing OPC UA library, I think I will manage to get it running.
In general, how do the Interfaces for the Mesa Cards or EtherCat (with Servo drives) work in Linux CNC, are they deeply embedded in the LinuxCNC build or are they more like PlugIns?
Also, does LinuxCNC run the position control loop and the drive runs the velocity control loop? In this case, could LinuxCNC just pass me the velocity set point and I pass back the actual position of each axis?
Thank you for your help so far, it is greatly appreciated.
Replied by mh300 on topic Using Python for axis motion control
Thank you for your replies.
The Real-Time aspect is of course true, I wonder how bad it would be though, the 500mm/min moves aren't the fastest and I think the µm precision is a lost cause already. But to answer your questions:
What physical interface to the computer will you use?
The normal Ethernet Interface of the computer is used. Profinet works with standard Ethernet frames, TCP/IP is also used but only for the configuration of the devices. (Can be done with an external tool)
Do you know the protocol and can program C?
I have access to the Spec, but writing a full Profinet Controller (=Master) would be a massive undertaking. For a first test, I plan to use OPC UA, which has a pretty sophisticated C library available ( Github ). CodeSYS would take care of translating between OPC UA <-> Profinet and can be made to run in Realtime.
As for programming C: My skills are a bit rusty, but If the Linux CNC interface isn’t too complicated and on the other side I just need to work with the existing OPC UA library, I think I will manage to get it running.
In general, how do the Interfaces for the Mesa Cards or EtherCat (with Servo drives) work in Linux CNC, are they deeply embedded in the LinuxCNC build or are they more like PlugIns?
Also, does LinuxCNC run the position control loop and the drive runs the velocity control loop? In this case, could LinuxCNC just pass me the velocity set point and I pass back the actual position of each axis?
Thank you for your help so far, it is greatly appreciated.
Please Log in or Create an account to join the conversation.
- cmorley
- Offline
- Moderator
Less
More
- Posts: 7777
- Thank you received: 2073
19 Feb 2022 07:25 #235313
by cmorley
Replied by cmorley on topic Using Python for axis motion control
You would need to build a HAL component to communicate through Ethernet to the drive.
For servos the usual set up is for linuxcnc to send velocity commands and read position feedback.
For servos the usual set up is for linuxcnc to send velocity commands and read position feedback.
Please Log in or Create an account to join the conversation.
- rodw
- Away
- Platinum Member
Less
More
- Posts: 10788
- Thank you received: 3554
19 Feb 2022 10:02 #235318
by rodw
Replied by rodw on topic Using Python for axis motion control
Ethercat is a standalone environment and there is a HAL driver that lets Linuxcnc to connect to it
There is a CIA402 driver which may be of interest to you
github.com/dbraun1981/hal-cia402
CIA402 is a standard for servo drives.
There is a CIA402 driver which may be of interest to you
github.com/dbraun1981/hal-cia402
CIA402 is a standard for servo drives.
Please Log in or Create an account to join the conversation.
- mh300
- Offline
- New Member
Less
More
- Posts: 10
- Thank you received: 3
08 Sep 2022 08:45 #251473
by mh300
Replied by mh300 on topic Using Python for axis motion control
Sorry, I couldn't get back to this as soon as I would have liked. Thank you again for your replies and help.
I recently made some progress by using UDP (By using jzolee/HAL2UDP , with some minor modifications). I used it for getting the encoder values into LinuxCNC and it looks promising. I think this could also work for the Drive Side, I will test if I can get it to run fast enough.
My current Setup for the encoders is:
Heidenhain LS 803 Linear Scales ---11uA Sine---> Heidenhain EXE 600 ---TTL---> ESP32 with W5500 ---Ethernet/UDP---> LinuxCNC
For the drive side I will try:
LinuxCNC ---Ethernet/UDP---> PLC (Either Siemens S7-1200 or CodeSys) ---Ethernet/PROFINET---> Servo Drive (Siemens S210/Siemens V90)
I recently made some progress by using UDP (By using jzolee/HAL2UDP , with some minor modifications). I used it for getting the encoder values into LinuxCNC and it looks promising. I think this could also work for the Drive Side, I will test if I can get it to run fast enough.
My current Setup for the encoders is:
Heidenhain LS 803 Linear Scales ---11uA Sine---> Heidenhain EXE 600 ---TTL---> ESP32 with W5500 ---Ethernet/UDP---> LinuxCNC
For the drive side I will try:
LinuxCNC ---Ethernet/UDP---> PLC (Either Siemens S7-1200 or CodeSys) ---Ethernet/PROFINET---> Servo Drive (Siemens S210/Siemens V90)
Please Log in or Create an account to join the conversation.
- Szabika78
- Offline
- New Member
Less
More
- Posts: 1
- Thank you received: 0
05 Nov 2022 22:13 #256030
by Szabika78
Replied by Szabika78 on topic Using Python for axis motion control
I'm working on a pretty similar project.
May I contact you to ask some quesions?
May I contact you to ask some quesions?
Please Log in or Create an account to join the conversation.
Time to create page: 0.061 seconds