Help in understanding Hal -d setting to VFD

More
01 Jun 2018 16:48 #111395 by javelin
Hello guys,

I blew up my huanyang vfd and I am presently looking at a wj200 so I wanted to run something by you guys before buying.

I was looking at the driver for the wj200 and I noticed that the default setting within the driver for the modbus is:

/* modbus connection settings*/
char *device = "/dev/ttyS0";

wj200 driver

Now by comparison I found this interesting. When I set up the huanyang inverter I did not realize that this driver too was coded in a similar way:

−d, −−device <path>

(default /dev/ttyS0) Set the name of the serial device node to use.

huanyang driver

Inside of my hal file on setup in order to establish modbus connection I used this to designate the device that I was using as it was recognized by LinuxMint:

-d /dev/ttyUSB0


My question is, if the Hitachi wj200 also uses the same default setting as the huanyang should I be able to do the same for the wj200 by setting my device parameter to -d /dev/ttyUSB0 and achieve modbus communication?

My concern comes from reading older posts pertaining to the wj200 and people mentioning that it was hard coded to the ttyS0 then saying they had to recompile the driver with the settings they needed. So I am missing something in my understanding. Within Hal using the -d parameter should allow for me to define what my device is for the driver to use if I am correct? Thus no need or concern to worry about with recompiling if I am seeing this right.

Thanks for the help.

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

More
02 Jun 2018 20:58 #111477 by andypugh
The WJ200 does seem to accept a "device" modparam

github.com/LinuxCNC/linuxcnc/blob/master...0_vfd/wj200_vfd.comp

I think it would be

loadusr wj200_vfd device=ttyUSB0

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

More
13 Jun 2018 00:56 #112269 by javelin

The WJ200 does seem to accept a "device" modparam

github.com/LinuxCNC/linuxcnc/blob/master...0_vfd/wj200_vfd.comp

I think it would be

loadusr wj200_vfd device=ttyUSB0


You are correct Andy. I received my WJ200 and after wiring and testing strictly between the vfd and spindle to make sure it all runs, I tried to set it up in lcnc. I tried the device=ttyUSB0 and it did load the driver. I found it interesting that so many posts online claim that this driver cannot be used with the USB due to it being hard coded to ttyS0. So I was glad that the system started.

So forgive me for being still new to all this, but learning as as quick as I can. The next problem I am having is understanding the hal wiring from this driver. I have looked at the man page for the driver and the options are not as clear to me as maybe it should be. In my last setup with the huanyang I used the following to control the spindle:

net vfd-comms halui.machine.is-on => hy_vfd.enable
net spindle-fwd motion.spindle-forward => hy_vfd.spindle-forward
net spindle-reverse motion.spindle-reverse => hy_vfd.spindle-reverse
net spindle-speed-cmd motion.spindle-speed-out-abs => hy_vfd.speed-command
net spindle-on motion.spindle-on => hy_vfd.spindle-on


So with the WJ200 I attempted the following:

net vfd-comms halui.machine.is-on => wj200-vfd.0.is-ready
net spindle-fwd motion.spindle-forward => wj200-vfd.0.run
net spindle-reverse motion.spindle-reverse => wj200-vfd.0.reverse
net spindle-speed-cmd motion.spindle-speed-out-abs => wj200-vfd.0.commanded-frequency
net spindle-on motion.spindle-on => wj200-vfd.0.enable


This had no affect and the spindle will not run. Would anyone have any ideas on the correct settings here? I will play with it more tomorrow experimenting yet there may be someone out there that has the missing pieces to the puzzle.

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

More
13 Jun 2018 09:18 - 13 Jun 2018 09:19 #112277 by andypugh

I found it interesting that so many posts online claim that this driver cannot be used with the USB due to it being hard coded to ttyS0. So I was glad that the system started.


The ability to choose the device was added in July 2016:
github.com/LinuxCNC/linuxcnc/commits/mas...0_vfd/wj200_vfd.comp

If the incorrect info appears in the Wiki then it should be corrected, and if it is in this forum it should be possible to add a post with the up to date info.

So with the WJ200 I attempted the following:

net vfd-comms halui.machine.is-on                         => wj200-vfd.0.is-ready
net spindle-fwd motion.spindle-forward                              => wj200-vfd.0.run
net spindle-reverse motion.spindle-reverse                       => wj200-vfd.0.reverse
net spindle-speed-cmd motion.spindle-speed-out-abs     => wj200-vfd.0.commanded-frequency
net spindle-on motion.spindle-on                                          => wj200-vfd.0.enable


I suspect that if you were to start linuxcnc from the command line (command "linuxcnc") you would see an error report at the first line of the above and then all subsequent lines are skipped.

wj200-vfd.0.is-ready is an output pin (to inform HAL that the VFD is happy). Instead try:
net vfd-comms halui.machine.is-on                         =>  wj200-vfd.0.enable
net spindle-on motion.spindle-on                                => wj200-vfd.0.run
net spindle-reverse motion.spindle-reverse                       => wj200-vfd.0.reverse
net spindle-speed-cmd motion.spindle-speed-out-abs     => wj200-vfd.0.commanded-frequency

The commanded frequency might need some scaling to convert rpm or rps to hertz. (But this might be set in the VFD)

You might also want to add
net spindle-is-at-speed motion.spindle-at-speed wj200-vfd.0.is_at_speed
to delay feed moves until the spindle has ramped up.
Last edit: 13 Jun 2018 09:19 by andypugh.

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

More
13 Jun 2018 17:47 #112301 by javelin
Interesting observation yet something is broken and I am not sure if its me (most likely is) or the dirver. I wouldnt have noticed this if it were not for Linux Mint being a pita with usb connections. In short every time I boot my pc I have to sudo chmod 666 /dev/ttyUSB0 in order to use it. Last night I had forgotten that I also had for some reason chmod 666 the /dev/ttyS0.

Today I take the above code you gave and plugged it into my hal file, then used the chmod on USB0 like I always have to do. I go to run linuxcnc and I get this error.

Debug file information:
Note: Using POSIX realtime
WARNING: unhandled arguments to wj200_vfd driver:
device="/dev/ttyUSB0"
ERROR Can't open the device /dev/ttyS0 (Permission denied)
ERROR: wj200_vfd unable to create libmodbus connection. - Permission denied
./custom.hal:4: waitpid failed wj200_vfd wj200_vfd
./custom.hal:4: wj200_vfd exited without becoming ready
3859


So in the above error obviously I had not yet used chmod on ttyS0. So I am not sure whats going on, but I found it interesting that it was still asking for ttyS0. Maybe it begins there and links with the setting in the hal file that is set?

Also another important note: I noticed when using the line loadusr -W wj200_vfd device="/dev/ttyUSB0" there is something odd to me which takes place. I began to wonder if it was picking up the device path at all due to the above error. So I changed the device path to say device="pizza" in order of hoping to create an error message. Linuxcnc loaded with no issues after starting. I am just accustomed to getting errors even if a period or dash is placed wrong. It feels like the driver is running home to mama as so to speak defaulting back to ttyS0

Despite the above concerns, at the present moment I am playing with my settings in the vfd on modbus connection settings to make sure I have everything set properly. I know you guys and the programmers are a lot smarter at this than I am and the error is most likely big fat me and nothing else. After using chmod on ttyS0 and applying the code from above there still is no fire or activity from the spindle. Im getting that loving feeling I may have to do this the old fashioned way and go from the 7i76 straight to the vfd.

I have attached my hal file for kicks but nothing is in it that is not already on this thread.

File Attachment:

File Name: custom_2018-06-13.hal
File Size:0 KB
Attachments:

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

More
13 Jun 2018 18:01 #112304 by andypugh
This almost looks like the module has forgotten how to handle the "device=" parameter

(It acts puzzled, and then falls-back to the default)

The "unhandled argument" is not due to permissions, that would be a different error.

What is the exact loadusr line for the component?

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

More
13 Jun 2018 18:06 - 13 Jun 2018 18:07 #112306 by javelin

This almost looks like the module has forgotten how to handle the "device=" parameter

(It acts puzzled, and then falls-back to the default)

The "unhandled argument" is not due to permissions, that would be a different error.

What is the exact loadusr line for the component?


loadusr -W wj200_vfd device="/dev/ttyUSB0"

I assume thats what you were asking for. Thats the exact line I use in hal to attempt loading the driver to the device.

Would there be another way to link ttyS0 to ttyUSB0 within linux itself? If it could be done on that end wouldnt the driver not care about what the loadusr line says? If there is a way I hope its easy LMAO!

Also know I am using Master 2.8
Last edit: 13 Jun 2018 18:07 by javelin.

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

More
13 Jun 2018 18:10 #112307 by javelin
Just another thought to add to the confusion.

After I use sudo chmod 666 /dev/ttyS0 in terminal for linux I start linuxcnc and it opens without errors. I just wanted to make sure you knew that because its odd that an error came up before I did this despite the error complaining about /dev/tttyUSB0 ...

If I reboot I can recreate the error by simply chmoding the USB0 and not the ttyS0

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

More
13 Jun 2018 18:19 #112309 by andypugh
Yes, but, does it actually work?

It sounds like it is connecting to ttyS0 and that won't raise any errors, but probably is not going to work.

It is possible that the device has been re-assigned to a different ttyUSB. (Though that, too, would cause a different error).

This might help:
unix.stackexchange.com/questions/66901/h...-under-a-static-name

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

More
13 Jun 2018 18:39 - 13 Jun 2018 18:40 #112312 by javelin

Yes, but, does it actually work?

It sounds like it is connecting to ttyS0 and that won't raise any errors, but probably is not going to work.

It is possible that the device has been re-assigned to a different ttyUSB. (Though that, too, would cause a different error).

This might help:
unix.stackexchange.com/questions/66901/h...-under-a-static-name


Thanks for the link I will try this next. But to answer your question, no it does not work. Also just to do a sanity check I opened terminal and used ls /dev to verify that the rs485 was still designated as ttyUSB0 and it has not changed.

So..... it appears that the driver is loading ttyS0 thus why nothing is working. I will take a crack at the link you gave me to see if I can pull something off there. If I do and it works I will post here again. If not, I hardwired the baby into the 7i76. So if I attempt that expect different questions from me LMAO!!!
Last edit: 13 Jun 2018 18:40 by javelin.

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

Time to create page: 0.086 seconds
Powered by Kunena Forum