Axis control via ModbusTCP
- nanowhat
- Offline
- Junior Member
-
Less
More
- Posts: 21
- Thank you received: 0
09 Oct 2025 21:23 #336175
by nanowhat
Axis control via ModbusTCP was created by nanowhat
I have been fighting these iX7NH drives for several days and they still won't reliably communicate via ethercat. However, they talk ModbusTCP just fine. What's the best way to control axis drives via ModbusTCP? The machine being driven is a pallet changer for a milling machine, so path accuracy doesn't matter, only endpoint repeatability. I figure it won't matter that I can't have CSP mode.
In order to make the drive move the motor, I have to:
It seems that I could use MB2HAL to create HAL pins for coil 0x12, registers 0x6034, 0x6036, 0x6038, and 0x6025, and data from LinuxCNC's motion planner would sail right through to the drives, but what about the control word register?
I have to set and then clear bit 5 whenever I want the drives to make a movement.
In order to make the drive move the motor, I have to:
- Set coil 0x12 == 1 (SV_ON: This enables the drive output)
- Specify movement speed (register 0x6034), acceleration (register 0x6036), and deceleration (0x6038)
- Specify the target position (register 0x6025)
- Set the control word (register 0x6001) to 0x30, then immediately to 0x20 (I tried this without linuxCNC, in Python, with no delay between the statements, and the servo system executed the move correctly)
It seems that I could use MB2HAL to create HAL pins for coil 0x12, registers 0x6034, 0x6036, 0x6038, and 0x6025, and data from LinuxCNC's motion planner would sail right through to the drives, but what about the control word register?
I have to set and then clear bit 5 whenever I want the drives to make a movement.
Please Log in or Create an account to join the conversation.
- nanowhat
- Offline
- Junior Member
-
Less
More
- Posts: 21
- Thank you received: 0
09 Oct 2025 23:41 #336177
by nanowhat
Replied by nanowhat on topic Axis control via ModbusTCP
I am running LinuxCNC 2.9.4 from the official repository, but it seems that modbus functions 1 and 5 aren't available. (loading my partial mb2hal config file at halrun throws "[fnct_05_write_single_coil] out of range") I read that Linuxcnc 2.8 didn't support those functions, but that 2.9 should. What am I missing?
Please Log in or Create an account to join the conversation.
- nanowhat
- Offline
- Junior Member
-
Less
More
- Posts: 21
- Thank you received: 0
10 Oct 2025 18:59 - 10 Oct 2025 19:06 #336212
by nanowhat
Replied by nanowhat on topic Axis control via ModbusTCP
I have made some progress:
I have had to set the axis velocities to constant values (500000, where the encoder has 524288 counts per revolution), since I don't see any HAL pins from the motion planner that carry that information. I will see about writing a custom HAL component that can interpolate velocity from waypoints.
I assembled a MB2HAL config file, and loaded it as a userspace component through halrun. With that, I could control each motor, with no perceptible lag between command entry and motion.
I can control the motors through Axis, but in G1 feed mode at the MDI, I get one step every second or so. For instance, I will command one axis to G1 Z1.0 F5.0 and it will move ~60° every second or so until the move is done. In G0 rapid mode at the MDI, there is a significant delay, again roughly one second between the time I press Enter and the time the motor begins to move. While the move is in progress, distance to go changes smoothly, but actual position (and the motor shaft) move in steps.
I have had to set the axis velocities to constant values (500000, where the encoder has 524288 counts per revolution), since I don't see any HAL pins from the motion planner that carry that information. I will see about writing a custom HAL component that can interpolate velocity from waypoints.
I assembled a MB2HAL config file, and loaded it as a userspace component through halrun. With that, I could control each motor, with no perceptible lag between command entry and motion.
I can control the motors through Axis, but in G1 feed mode at the MDI, I get one step every second or so. For instance, I will command one axis to G1 Z1.0 F5.0 and it will move ~60° every second or so until the move is done. In G0 rapid mode at the MDI, there is a significant delay, again roughly one second between the time I press Enter and the time the motor begins to move. While the move is in progress, distance to go changes smoothly, but actual position (and the motor shaft) move in steps.
Last edit: 10 Oct 2025 19:06 by nanowhat.
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 19625
- Thank you received: 4528
10 Oct 2025 20:00 #336219
by andypugh
Replied by andypugh on topic Axis control via ModbusTCP
If you have proved that you can control the drive from Python then I would suggest carrying on with that.
You can "import linuxcnc" and "import hal" into your Python script then create HAL pins to recieve the position commands from HAL.
linuxcnc.org/docs/stable/html/config/python-interface.html
linuxcnc.org/docs/stable/html/config/python-hal-interface.html
You can "import linuxcnc" and "import hal" into your Python script then create HAL pins to recieve the position commands from HAL.
linuxcnc.org/docs/stable/html/config/python-interface.html
linuxcnc.org/docs/stable/html/config/python-hal-interface.html
Please Log in or Create an account to join the conversation.
- nanowhat
- Offline
- Junior Member
-
Less
More
- Posts: 21
- Thank you received: 0
13 Oct 2025 22:51 #336403
by nanowhat
Replied by nanowhat on topic Axis control via ModbusTCP
Is there any way of retrieving joint velocity from the motion planner? I have been trying to interpolate it all day and I keep getting unwanted results: velocities that vary wildly, target position changing for no apparent reason, etc.
If I can get that directly from the motion planner, that would simplify the operation considerably.
If I can get that directly from the motion planner, that would simplify the operation considerably.
Please Log in or Create an account to join the conversation.
- PCW
-
- Offline
- Moderator
-
Less
More
- Posts: 17302
- Thank you received: 5035
13 Oct 2025 23:12 #336404
by PCW
Replied by PCW on topic Axis control via ModbusTCP
joint.N.vel-cmd
Please Log in or Create an account to join the conversation.
Time to create page: 0.082 seconds