yl620-a vfd rs485 modbus spindle control

More
27 Aug 2023 11:37 - 27 Aug 2023 11:38 #279088 by handsomebeast
 hi guys, im new to linuxcnc and all things linux, im running linuxcnc 2.8.2 on the axis gui, and have built a printnc cnc thats made from a kit that came with a vfd and spinde kit yl620-a and 2.2kw water cooled spindle. i am using this 

www.waveshare.com/usb-to-rs485.htm

usb to rs485 adapter, and have managed to setup the vfd to control the spindle with classic ladder following this github tutorial

github.com/xsnoopy/LinuxCNC-Yalang-yl620...Modbus-ClassicLadder

i can get the spindle to start with the and - buttons or an mdi command " m3 s***** " ect and stop, forward or reverse ect, and have a very stable modbus connection with the adsapter to vfd, so it should be great for running gcode, but the PYVCP panel that has a dial for speed feedback and a light to indicate spindle at speed and rs485 connection are not working!  i cannot get them to work, ive tried looking in HALSHOW and the spindle at speed is permanently on regardless for some reason, the other pins for the spindle are giving feedback also when turning on and off the spindle the brake pin goes on and of, theres a pin and a readout for the speed and hz and that seems to be working but the funny thing is if i turn the vfd off and start the spindle the pins still show feedback in halshow, i would love to get this working properly and have been reading up on the basics of HAL and PYVCP python virtual control panels, and from what i can understand the vfd.clp file is the file that classicladder uses to control the vfd with the rs485 adapter, the vfd.xml file is what creates the PYVCP panel and the vfd.hal file tels the panel how to connect the pins to the panel, but ive spent hours trying to get my head around it and its took me months to get this far, i at least can run the vfd via modbus with the adapter through linuxcnc which most people with this vfd have just given up on trying to get it to work, so a big thankyou to mbender for getting it to this point im very grateful for the tutorial, if i post my files can someone take a look and see why the panel isnt working 
Last edit: 27 Aug 2023 11:38 by handsomebeast.

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

More
28 Aug 2023 09:39 - 28 Aug 2023 16:43 #279143 by handsomebeast
ok i got it working all the lights and dial work great now giving feedback, the tutorial was a little misleading but i learned a lot about hal and pyvcp panels and pins in the process, i take no credit for the tutorial as i say as mBender was the person who did all the work i just got it working for me also this should help others who got stuck with this vfd combo and rs485 connection 

the readme file from the files in the github repository

github.com/xsnoopy/LinuxCNC-Yalang-yl620...Modbus-ClassicLadder

says to add this to the end of your .ini file which is incorrect it is meant to be put at the end of your .hal file without the last line
" POSTGUI_HALFILE = vfd.hal" which belongs in your ini file in the [hal section]
========================================================================================================
loadrt classicladder_rt numS32out=100
addf classicladder.0.refresh servo-thread
loadusr classicladder --modmaster vfd.clp
net spindle-on          classicladder.0.in-00   spindle.0.on
net spindle-brake       classicladder.0.in-01   spindle.0.brake
net spindle-forward     classicladder.0.in-02   spindle.0.forward
net spindle-reverse     classicladder.0.in-03   spindle.0.reverse
net spindle-cmd-rpm     <= spindle.0.speed-out
net spindle-cmd-rpm-abs <= spindle.0.speed-out-abs
net spindle-cmd-rps     <= spindle.0.speed-out-rps
net spindle-cmd-rps-abs <= spindle.0.speed-out-rps-abs classicladder.0.floatin-00
POSTGUI_HALFILE = vfd.hal 
===============================================================================================================
so copy and paste this excluding the last line into your .hal file

and as mentioned above the last line belongs in your .ini file so in your machine .ini file edit these sections:

in the [DISPLAY] section add "PYVCP = vfd.xml"
in the [HAL] section add "POSTGUI_HALFILE = vfd.hal"

www.waveshare.com/usb-to-rs485.htm

also to point out if you use the usb to r485 adapter linked above it will show up as /dev/ttyACMO and the classicladder configuration tab doesnt have this as a selectable option so to remedy this open the vfd.clp file towards the bottom you should see this text

MODBUS_MASTER_SERIAL_PORT=/dev/ttyUSB0
MODBUS_MASTER_SERIAL_SPEED=19200
MODBUS_MASTER_SERIAL_DATABITS=8
MODBUS_MASTER_SERIAL_STOPBITS=1
MODBUS_MASTER_SERIAL_PARITY=0
MODBUS_ELEMENT_OFFSET=0
MODBUS_MASTER_SERIAL_USE_RTS_TO_SEND=0
MODBUS_MASTER_TIME_INTER_FRAME=100
MODBUS_MASTER_TIME_OUT_RECEIPT=500
MODBUS_MASTER_TIME_AFTER_TRANSMIT=100
MODBUS_DEBUG_LEVEL=0
MODBUS_MAP_COIL_READ=0
MODBUS_MAP_COIL_WRITE=1
MODBUS_MAP_INPUT=0
MODBUS_MAP_HOLDING=0
MODBUS_MAP_REGISTER_READ=1
MODBUS_MAP_REGISTER_WRITE=0
_/FILE-com_params.txt

MODBUS_MASTER_SERIAL_PORT=/dev/ttyUSB0

(this is the line that needs editing with /dev/ttyACM0)

when you open linuxcnc and open up the config window in classicladder you will see it has changed to/dev/ttyACM0 and it will now work
also i set the vfd to 19200 8 n 1 and kept the same in the the classicladder config,

also you need to add your user to the dialout group and configure your usb adapter to the correct setting

to add user to dialout group open a terminal and type this command

sudo adduser "YOUR USERNAME" dialout

then check groups for your user with this command

sudo groups "YOUR USERNAME"

and it will list the groups your username is added to

and to configure the usb adapter i installed an app called GTKTERM by again opening a terminal and typing this command

sudo apt-get install gtkterm

when installed go to application and under accessories should now be a new application called "serial port terminal"
open it up and on the configuration tab you can now change and save a permanent configuration for your adapter and any other adapter you are using. this way i had a solid connection as some people were complaining about the vfd being noisy and dropping connection, so they gave up using the rs485 method but im not using a shielded cable from the rs485 port on the vfd, it is a jst-xh 3 pin male cable thats about 20cm long. DO NOT and i repeat DO NOT BY ANY MEANS use a usb extention cable. the adapter came with a cable that has a built in ferrite and is also shielded but if i used it, as soon as i send a command to linuxcnc the connection would drop straight away. so if your trying to get this method working DONT use an extention cable for the usb adapter. also buy the adapter i listed above as people were sayin they had to use resistors to negate noise from the vfd signal to the adapter but this has them on the adapter pcb and is also lighting proof according to the specs. i tried a cheap usb adapter previously but due to a noisy signal couldnt get that working, you may be lucky but the setup is problematic enough without adding caveats yourself.

again thankyou to mBender for the github tutorial as without it id never have gotten this working and i hope this solves your issues for anyone else having the same problems as me 

ive edited and linked the edited files including the readme file edited with the correct files and i will post it on github when i get chance unless mBender will want to edit the readme and github repo with the changes outlined in this post
p.s when i uploaded the files they have a date in the name so just rename them without the dates to
vfd.clp
vfd.xml
vfd.hal
or download from the repo i put up with the edited file

github.com/handsomebeast20/yl620-a-rs485-modbus-classicladder

or follow this tutorial on the printnc wiki for the classic ladder method

wiki.printnc.info/en/electronics/vfd/yl620a-rs485

i am using axis gui also with linuxcnc 2.8.4 and it is working
Attachments:
Last edit: 28 Aug 2023 16:43 by handsomebeast.
The following user(s) said Thank You: tommylight, Aciera

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

Time to create page: 0.151 seconds
Powered by Kunena Forum