- Posts: 6
- Thank you received: 0
rs485 huanyang speed control
Using the custom Hal coding: loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600, just generates errors as it can't load /dev/ttyUSB0 or any usb#. Can someone explain in basic terms what this line is doing and what it might look like on my machine, do I need hardware support for the r485? (using linuxcnc 2.7)
Anyone get a hal mod to work for rs485 spindle speed control?
... also is there code i can 'cut and paste' for a z touch plate routine?
Please Log in to join the conversation.
sw3Dp wrote: Using the custom Hal coding: loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600, just generates errors as it can't load /dev/ttyUSB0 or any usb#. Can someone explain in basic terms what this line is doing and what it might look like on my machine, do I need hardware support for the r485?
Yes, you need some sort of hardware support for RS485. What exactly do you have the VFD plugged in to?
The way that I worked out what my USB-to-RS485 dongle was was to open a terminal and type
In my case it was ttyUSB0
If your VFD is not connected to a USB-485 converter then the correct device will be different, but it will need to be one of the devices in /dev/
The meaning of the command is described in the hy_vfd manual page
linuxcnc.org/docs/2.7/html/man/man1/hy_vfd.1.html
The syntax of the loadusr command is here:
linuxcnc.org/docs/2.7/html/man/man1/halcmd.1.html
Please Log in to join the conversation.
... I have read all the hal and linux guides but little of it makes it to understanding so apologies if 'I can't get there from here.'
settings:
PD001=2
PD002=2
PD003=400
PD004=400
PD005=400
PD011=0
PD044=3
PD045=3
PD046=4
PD072=400
PD143=2
PD144=3000
PD163=1
PD164=1
PD165=3
what I would give to get pre-configured stable full house linuxcnc/linux image to start.
Please Log in to join the conversation.
sw3Dp wrote: does usb-rs485() needs additional drivers?
Not as far as I could tell. I used an identical thing and it just worked.
I got a bit elaborate, but only for aesthetic reasons:
forum.linuxcnc.org/forum/18-computer/306...485-connection#72351
The big question is do you see the dongle in /dev/ ?
For me it all "just worked". I plugged in the dongle, a new device appeared in /dev/ and I used that in the loadusr command and there was my VFD.
You do need to configure the VFD as defined in the hy_vfd manpage.
Please Log in to join the conversation.
None of this makes sense fresh stepconf, my vfd settings match the hy_vfd listed settings with the exception of baud rate PD164=1 for 9600 as written in the custom hal, however I changed PD164=2 and it made no dif. Windows can see the dongle, /dev/ sees it but all linuxcnc gives me is the[strike] "cannot open com port errno 22."[/strike] Could it be the vfd failure to communicate or is this a dongle failure (ordered a couple to test). Shouldn't the custom hal load even if the vfd isn't powered?. Nothing more disheartening that hearing "all just worked" so something isn't working here, not the wiring just two connections, not settings, not code(loadusr -Wn vfd hy_vfd -n vfd -d /dev/ttyUSB0 -p none -r 9600)?, all I'm left with is fault with vfd or dongle I'm praying that it's the $4 dongle as this alternative is a nightmare.
Please Log in to join the conversation.
Does your ttyUSB0 disappear when you unplug the dongle?
I am a bit puzzled by the error message you are getting, unless you have paraphrased it? The error message here is different:
github.com/LinuxCNC/linuxcnc/blob/master...g-vfd/hy_comm.c#L695
It might be worth turning on debug mode. In fact it is probably worth doing some testing in a terminal window to take everything else out of the system. Using the -g flag will give more info about what is going on.
Open a terminal window and type:
Please Log in to join the conversation.
When the dongle is unplugged /dev/ is empty
halrun
loadusr -W -g hy_vfd -d /dev/ttyUSB0
loadusr: invalid option -- 'g'
then tried
loadusr -W hy_vfd -d/dev/ttyUSB0
open: permission denied
ERROR Can't open the device /dev/ttyUSB0 (errno 13)
here is boot log from linuxcnc 2.7, see error msg
RUN_IN_PLACE=no
LINUXCNC_DIR=
LINUXCNC_BIN_DIR=/usr/bin
LINUXCNC_TCL_DIR=/usr/lib/tcltk/linuxcnc
LINUXCNC_SCRIPT_DIR=
LINUXCNC_RTLIB_DIR=/usr/realtime-3.4-9-rtai-686-pae/modules/linuxcnc
LINUXCNC_CONFIG_DIR=
LINUXCNC_LANG_DIR=/usr/share/linuxcnc/tcl/msgs
INIVAR=inivar
HALCMD=halcmd
LINUXCNC_EMCSH=/usr/bin/wish8.5
LINUXCNC - 2.7.0
Machine configuration directory is '/home/user/linuxcnc/configs/sw3Dp'
Machine configuration file is 'sw3Dp.ini'
INIFILE=/home/user/linuxcnc/configs/sw3Dp/sw3Dp.ini
PARAMETER_FILE=linuxcnc.var
TASK=milltask
HALUI=halui
DISPLAY=axis
Starting LinuxCNC...
Starting LinuxCNC server program: linuxcncsvr
Loading Real Time OS, RTAPI, and HAL_LIB modules
Starting LinuxCNC IO program: io
Starting HAL User Interface program: halui
Found file(REL): ./sw3Dp.hal
Found file(REL): ./custom.hal
ERROR Can't open the device /dev/ttyUSB0 (errno 22)
vfd: ERROR: couldn't open serial device
Shutting down and cleaning up LinuxCNC...
Killing task linuxcncsvr, PID=4435
Removing HAL_LIB, RTAPI, and Real Time OS modules
Removing NML shared memory segments
Debug file information:
open: Permission denied
./custom.hal:4: waitpid failed hy_vfd vfd
./custom.hal:4: hy_vfd exited without becoming ready
4435
PID TTY STAT TIME COMMAND
Stopping realtime threads
Please Log in to join the conversation.
Odd, the manpage says that works. But never mind.sw3Dp wrote: loadusr -W -g hy_vfd -d /dev/ttyUSB0
loadusr: invalid option -- 'g'
loadusr -W hy_vfd -d/dev/ttyUSB0
open: permission denied
ERROR Can't open the device /dev/ttyUSB0 (errno 13)
Error code 13 (according to a Google search) is a permissions problem.
I wonder if you are running from a normal user account rather than an admin account?
Maybe try plugging in the dongle and
Please Log in to join the conversation.
halcmd: show pin
Component Pins:
Owner Type Dir Value Name
5 float OUT 0 hy_vfd.ACV
5 float OUT 0 hy_vfd.CNST
5 bit OUT FALSE hy_vfd.CNST-bracking
5 bit OUT FALSE hy_vfd.CNST-command-rf
5 bit OUT FALSE hy_vfd.CNST-jog
5 bit OUT FALSE hy_vfd.CNST-jogging
5 bit OUT FALSE hy_vfd.CNST-run
5 bit OUT FALSE hy_vfd.CNST-running
5 bit OUT FALSE hy_vfd.CNST-running-rf
5 bit OUT FALSE hy_vfd.CNST-track-start
5 float OUT 0 hy_vfd.CNTR
5 float OUT 0 hy_vfd.Cont
5 float OUT 0 hy_vfd.DCV
5 float OUT 0 hy_vfd.OutA
5 float OUT 0 hy_vfd.OutF
5 float OUT 0 hy_vfd.Rott
5 float OUT 0 hy_vfd.SetF
5 float OUT 0 hy_vfd.Tmp
5 bit IN FALSE hy_vfd.enable
5 float OUT 0 hy_vfd.freq-lower-limit
5 float OUT 0 hy_vfd.frequency-command
5 bit OUT FALSE hy_vfd.hycomm-ok
5 float OUT 0 hy_vfd.max-freq
5 float OUT 0 hy_vfd.rated-motor-current
5 float OUT 0 hy_vfd.rated-motor-rev
5 float OUT 0 hy_vfd.rated-motor-voltage
5 float IN 0 hy_vfd.speed-command
5 bit OUT FALSE hy_vfd.spindle-at-speed
5 float IN 0.02 hy_vfd.spindle-at-speed-tolerance
5 bit IN FALSE hy_vfd.spindle-forward
5 bit IN FALSE hy_vfd.spindle-on
5 bit IN FALSE hy_vfd.spindle-reverse
5 float OUT 0 hy_vfd.spindle-speed-fb
Please Log in to join the conversation.
I had been just running off a live disc install, seems obvious now, that didn't give me permission to really use linuxcnc, explains a lot of glitches and miss steps, now I gots speed and accuracy. No doubt the root cause of why the g540 with relay wasn't controlling the spindle but I like the simplified wiring of the rs485, like you said 'all too easy' when done properly.
Just had to really install linux first, live disc is FUBAR, but it inspired me to find simplified wiring and hook the garage to network, no more thumb drives.
Please Log in to join the conversation.
