HY_VFD RS-485 HAL config

More
04 Jul 2025 13:10 - 04 Jul 2025 13:14 #331233 by scsmith1451
HY_VFD RS-485 HAL config was created by scsmith1451
Re-configuring my DIY Router Mill to use LinuxCNC after MACH3 began glitching on me. At this point I'm trying to get my HY_VFD to respond via RS-485.  Under Mach3 this RS-485 adapter worked great, but not getting any response now.

I found this HAL file on line for the HY-VFD RS-485 config:

# Include your custom HAL commands here
# This file will not be overwritten when you run PNCconf again
# RS-485 Spindle Control
loadusr -Wn vfd hy_vfd -n vfd -d /dev/bus/usb/004/002 -p none -r 19200
                                
net spindle-vel-cmd-rpm-abs    vfd.speed-command
net spindle-enable              vfd.spindle-on
net spindle-cw vfd.spindle-forward
net spindle-ccw vfd.spindle-reverse
net spindle-at-speed vfd.spindle-at-speed
                                
setp vfd.enable 1

having replaced the device reference with the output of lsusb for my machine.

When I issue a M3 S6000 command via MDI, nothing happens. Would someone please help me resolve this issue?

The above HAL config is in custom.hal. I'm running LCNC 2.9.4 on Debian 12.

Also, on a fairly regular basis I get the following error on startup of LCNC:

Debug file information:
Note: Using POSIX realtime
tcsetattr
: Inappropriate ioctl for device
./custom.hal:4: waitpid failed hy_vfd vfd
./custom.hal:4: hy_vfd exited without becoming ready
5241
Stopping realtime threads
Unloading hal components
RTAPI_PCI: Unmapped 65536 bytes at 0x7f1e95251000
Note: Using POSIX realtime
Last edit: 04 Jul 2025 13:14 by scsmith1451.

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

More
04 Jul 2025 23:37 #331286 by Hakan
Replied by Hakan on topic HY_VFD RS-485 HAL config
Maybe you can find something in this old thread www.forum.linuxcnc.org/24-hal-components...b485-to-huanyang-vfd
at least to make sure the communication works.
It was a long time ago this so I doubt I can answer any questions.

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

More
08 Jul 2025 12:29 #331514 by scsmith1451
Replied by scsmith1451 on topic HY_VFD RS-485 HAL config
Thanks Hakan,

I followed that thread and tried to test hy_vfd with via halrun but still got the same results. I know the adapter is good as I was using it with Mach3 however, it required a driver and a plug-in to work. I've tried to find a linux driver for the adapter without success.

I decided to purchase a new adapter from Silicon Labs. I've downloaded the linux driver and have attempted to compile and install it. This has lead to much frustration as not all of the <include> header files are in the expected directories. To resolve this issue I renamed the original /usr/include/linux directory to linux_orig and created a new linux copying all of the contents of the linux_orig directory to the new directory then adding the missing header file to new directory in their expected locations. This resolved some issues but surface others.

To resolve the issues, I've added an additional -I path to the /usr/src directory where all of the linux realtime headers reside to the Makefile without success.

Not sure I can resolve this issue at this point.

Does anyone know of an adapter that works with hy_vfd natively?

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

More
08 Jul 2025 13:27 #331519 by Hakan
Replied by Hakan on topic HY_VFD RS-485 HAL config
Which usb devices did you try? Some links, please.
A RS485 to usb device is just a serial device to linux and there are plenty supported out of the box.
I would be very surprised f you got two that aren't supported by linux.
Plug in both of them of show here the result of the two commands
lsusb
sudo dmesg | grep serial

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

More
08 Jul 2025 15:15 #331527 by scsmith1451
Replied by scsmith1451 on topic HY_VFD RS-485 HAL config
lsusb:

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 008 Device 002: ID 10c4:ea60 Silicon Labs CP210x UART Bridge
Bus 008 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 007 Device 002: ID 1a86:7523 QinHeng Electronics CH340 serial converter
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 002: ID 0e8d:7961 MediaTek Inc. Wireless_Device
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 003: ID 413c:2003 Dell Computer Corp. Keyboard SK-8115
Bus 005 Device 002: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

dmesg | grep serial:

[57931.173797] usbserial: USB Serial support registered for ch341-uart
 

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

More
08 Jul 2025 15:23 #331529 by scsmith1451
Replied by scsmith1451 on topic HY_VFD RS-485 HAL config
Both of these devices have drivers listed in:

/usr/lib/modules/6.1.0-23-rt-amd64/kernel/drivers/usb/serial/ch341.ko

and

/usr/lib/modules/6.1.0-23-rt-amd64/kernel/drivers/usb/serial/cp210x.ko

respectfully. Maybe they haven't been loaded? (insmod?)

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

More
08 Jul 2025 15:24 #331530 by Hakan
Replied by Hakan on topic HY_VFD RS-485 HAL config
Those two are the most common devices. That should work.
Redo that "sudo dmesg" with the search for serial. Limit to the last say 10 line though,
that should give the port name. I just plugged in a random usb-serial device I had and got this
hakan@server:~$ sudo dmesg | tail -11
[85176.404168] usb 1-9: new full-speed USB device number 2 using xhci_hcd
[85176.655288] usb 1-9: New USB device found, idVendor=1a86, idProduct=7523, bcdDevice= 2.54
[85176.655300] usb 1-9: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[85176.655304] usb 1-9: Product: USB2.0-Ser!
[85176.697428] usbcore: registered new interface driver usbserial_generic
[85176.697438] usbserial: USB Serial support registered for generic
[85176.698519] usbcore: registered new interface driver ch341
[85176.698527] usbserial: USB Serial support registered for ch341-uart
[85176.698541] ch341 1-9:1.0: ch341-uart converter detected
[85176.710753] ch341-uart ttyUSB0: break control not supported, using simulated break
[85176.710890] usb 1-9: ch341-uart converter now attached to ttyUSB0
You should hopefully get something similar and there is the device name: /dev/ttyUSB0

 

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

More
08 Jul 2025 15:27 #331531 by scsmith1451
Replied by scsmith1451 on topic HY_VFD RS-485 HAL config
Nope:

lsmod | grep ch341:

ch341 28672 0
usbserial 65536 2 cp210x,ch341
usbcore 348160 9 usbserial,ehci_pci,usbhid,cp210x,mt76_usb,ehci_hcd,ch341,uhci_hcd,mt7921u

looks like both have been loaded properly.

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

More
08 Jul 2025 15:38 #331532 by scsmith1451
Replied by scsmith1451 on topic HY_VFD RS-485 HAL config
dmesg | grep ch341
[57931.173236] usbcore: registered new interface driver ch341
[57931.173797] usbserial: USB Serial support registered for ch341-uart
[57931.173820] ch341 7-1:1.0: ch341-uart converter detected
[57931.189484] usb 7-1: ch341-uart converter now attached to ttyUSB1

alcmd: loadrt -Wn vfd hy_vfd -d /dev/ttyUSB1 -b 8 -p none -s 1 -r 9600 -n vfd
Note: Using POSIX realtime
-Wn: dlopen: /usr/lib/linuxcnc/modules/-Wn.so: cannot open shared object file: No such file or directory
<stdin>:1: waitpid failed /usr/bin/rtapi_app -Wn
<stdin>:1: /usr/bin/rtapi_app exited without becoming ready
<stdin>:1: insmod for -Wn failed, returned -1
halcmd: quit
Note: Using POSIX realtime

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

More
08 Jul 2025 15:46 #331533 by scsmith1451
Replied by scsmith1451 on topic HY_VFD RS-485 HAL config
Using the correct command:

halcmd: loadusr -Wn vfd hy_vfd -d /dev/ttyUSB1 -b 8 -p none -s1 -r 9600 -n vfd

worked.

Just having someone to bounce ideas off helps immensely.
Thank you Hakan
The following user(s) said Thank You: Hakan

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

Time to create page: 0.080 seconds
Powered by Kunena Forum