HAL Edits for RS485 / VFD Spindle Control
- Mr1576
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 1
25 Jan 2026 10:31 - 25 Jan 2026 10:33 #341891
by Mr1576
HAL Edits for RS485 / VFD Spindle Control was created by Mr1576
Bear with me:
I feel like I have read every article known to man on this subject and watched all the videos on YouTube that I can find but after several weeks cannot start my spindle via software.I am using Linuxcnc v 2.9.8, with QtDragon_hd as my GUI.
I have a 2.2kw water cooled spindle hooked up to a Huanyang HY02D223B inverter. I have a Waveshare RS485 USB connector, wired D+ to RS+ , and D- to RS- on the VFD. The shielded ground is connected to ground on the PC and COM on the VFD. The adapter shows up as ACM0.
VFD jumper has been switched to VI, and programmed as follows:-
PD001: Set to 2 (Source of run command = RS-485 communication port).
PD002: Set to 2 (Source of operating frequency = RS-485 communication port).
PD163: Set to 1 (Communication address of the VFD).
PD164: Set to 1 for 9600 baud
PD165: Set to 3 (Communication method: 8 data bits, no parity, 1 stop bit - 8N1 RTU).
While linuxcnc loads, if, after homing, I select MDI and type M3 S1000 (or any other value), nothing happens.
For a while I was questioning the wiring to the spindle/mains and had the awful thought that either the spindle or VFD were duff.
Last night I found this thread forum.linuxcnc.org/24-hal-components/310...anyang-speed-control and when I followed these steps in Terminal, voila! my spindle runs.
I have attached my HAL file and a screenshot of my procedure in Terminal in the hope that someone can explain why I can't operate the spindle from within my GUI.
Thanks in advance.
I feel like I have read every article known to man on this subject and watched all the videos on YouTube that I can find but after several weeks cannot start my spindle via software.I am using Linuxcnc v 2.9.8, with QtDragon_hd as my GUI.
I have a 2.2kw water cooled spindle hooked up to a Huanyang HY02D223B inverter. I have a Waveshare RS485 USB connector, wired D+ to RS+ , and D- to RS- on the VFD. The shielded ground is connected to ground on the PC and COM on the VFD. The adapter shows up as ACM0.
VFD jumper has been switched to VI, and programmed as follows:-
PD001: Set to 2 (Source of run command = RS-485 communication port).
PD002: Set to 2 (Source of operating frequency = RS-485 communication port).
PD163: Set to 1 (Communication address of the VFD).
PD164: Set to 1 for 9600 baud
PD165: Set to 3 (Communication method: 8 data bits, no parity, 1 stop bit - 8N1 RTU).
While linuxcnc loads, if, after homing, I select MDI and type M3 S1000 (or any other value), nothing happens.
For a while I was questioning the wiring to the spindle/mains and had the awful thought that either the spindle or VFD were duff.
Last night I found this thread forum.linuxcnc.org/24-hal-components/310...anyang-speed-control and when I followed these steps in Terminal, voila! my spindle runs.
I have attached my HAL file and a screenshot of my procedure in Terminal in the hope that someone can explain why I can't operate the spindle from within my GUI.
Thanks in advance.
Attachments:
Last edit: 25 Jan 2026 10:33 by Mr1576. Reason: missed some symbols
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 19793
- Thank you received: 4606
25 Jan 2026 16:48 #341904
by andypugh
Replied by andypugh on topic HAL Edits for RS485 / VFD Spindle Control
If this is your whole HAL file then the problem is that you have connected the HAL "net" to the VFD but not to the motion contoller.
This creates "nets" with names like "spindle" enable but there is nothing at the other "end"
Try:
The => are optional and ignored by the computer.
linuxcnc.org/docs/stable/html/man/man9/m....html#SPINDLE%20PINS
# Connect HAL pins to motion controller
net spindle-vel-cmd-rpm-abs hy_vfd.speed-command
net spindle-cw hy_vfd.spindle-forward
net spindle-enable hy_vfd.spindle-on
net spindle-ccw hy_vfd.spindle-reverse
net spindle-at-speed hy_vfd.spindle-at-speedThis creates "nets" with names like "spindle" enable but there is nothing at the other "end"
Try:
# Connect HAL pins to motion controller
net spindle-vel-cmd-rpm-abs spindle.0.speed-out => hy_vfd.speed-command
net spindle-cw spindle.0.forward => hy_vfd.spindle-forward
net spindle-enable spindle.0.on => hy_vfd.spindle-on
net spindle-ccw hy_vfd.spindle-reverse
net spindle-at-speed spindle.0.at-speed <= hy_vfd.spindle-at-speedThe => are optional and ignored by the computer.
linuxcnc.org/docs/stable/html/man/man9/m....html#SPINDLE%20PINS
Please Log in or Create an account to join the conversation.
- Mr1576
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 1
25 Jan 2026 19:11 #341913
by Mr1576
Replied by Mr1576 on topic HAL Edits for RS485 / VFD Spindle Control
Thanks for your reply @andypugh
I copied and pasted your suggestion into my HAL file, replacing the original erroneous text.
Unfortunately when launching Linuxcnc, an error is shown up as attached in the .png file.
Revised HAL file also attached.
Regards
Phil
I copied and pasted your suggestion into my HAL file, replacing the original erroneous text.
Unfortunately when launching Linuxcnc, an error is shown up as attached in the .png file.
Revised HAL file also attached.
Regards
Phil
Attachments:
Please Log in or Create an account to join the conversation.
- meister
- Offline
- Platinum Member
-
Less
More
- Posts: 698
- Thank you received: 428
26 Jan 2026 10:37 #341926
by meister
Replied by meister on topic HAL Edits for RS485 / VFD Spindle Control
what linuxcnc version do you have ?
in older versions you need to use: motion.spindle-speed-out
in older versions you need to use: motion.spindle-speed-out
Please Log in or Create an account to join the conversation.
- Mr1576
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 1
26 Jan 2026 12:43 - 26 Jan 2026 13:03 #341933
by Mr1576
Replied by Mr1576 on topic HAL Edits for RS485 / VFD Spindle Control
I’m on the latest version 2.8.9
oops 2.9.8, thanks
oops 2.9.8, thanks
Last edit: 26 Jan 2026 13:03 by Mr1576.
Please Log in or Create an account to join the conversation.
- meister
- Offline
- Platinum Member
-
Less
More
- Posts: 698
- Thank you received: 428
26 Jan 2026 13:01 #341935
by meister
Replied by meister on topic HAL Edits for RS485 / VFD Spindle Control
i think you mean: 2.9.8
you can try this with running linuxcnc:
halcmd show | grep spindle
and see if there are some spindle pins
you can try this with running linuxcnc:
halcmd show | grep spindle
and see if there are some spindle pins
Please Log in or Create an account to join the conversation.
- Mr1576
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 1
26 Jan 2026 15:41 - 26 Jan 2026 15:58 #341952
by Mr1576
Replied by Mr1576 on topic HAL Edits for RS485 / VFD Spindle Control
Attachments:
Last edit: 26 Jan 2026 15:58 by Mr1576.
Please Log in or Create an account to join the conversation.
- tommylight
-
- Away
- Moderator
-
Less
More
- Posts: 21247
- Thank you received: 7253
26 Jan 2026 15:46 #341953
by tommylight
Replied by tommylight on topic HAL Edits for RS485 / VFD Spindle Control
No spindle there, attach the hal and ini files here so we can have a look.
Please Log in or Create an account to join the conversation.
- Mr1576
- Offline
- New Member
-
Less
More
- Posts: 9
- Thank you received: 1
26 Jan 2026 16:10 #341956
by Mr1576
Replied by Mr1576 on topic HAL Edits for RS485 / VFD Spindle Control
HAL file (with @andypugh suggestion) attached, as well as current ini file
Attachments:
Please Log in or Create an account to join the conversation.
- andypugh
-
- Offline
- Moderator
-
Less
More
- Posts: 19793
- Thank you received: 4606
06 Feb 2026 21:03 #342570
by andypugh
Replied by andypugh on topic HAL Edits for RS485 / VFD Spindle Control
spindle.0.speed-out is clearly there in the screenshot.
Two possibilities spring to mind, one of them rather wierd.
1) You have the net commands for the spindle too early in the HAL file, ie before the motmod module has been loaded.
2) The - in speed-out is the wrong sort of dash. Though it looks right in this case. Maybe try re-typing it using the minus key. I think I typed out the example text on my Mac on a train, and it likes to be clever with typography.
Two possibilities spring to mind, one of them rather wierd.
1) You have the net commands for the spindle too early in the HAL file, ie before the motmod module has been loaded.
2) The - in speed-out is the wrong sort of dash. Though it looks right in this case. Maybe try re-typing it using the minus key. I think I typed out the example text on my Mac on a train, and it likes to be clever with typography.
Please Log in or Create an account to join the conversation.
Time to create page: 0.117 seconds