[Home]VFD Modbus

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

VFD and Modbus

So far, there are two options for using a Modbus VFD interface. One option is to create a HAL component as a driver. This would present the VFD's I/O as halpins. modbus.c and modbus.h are used to support the driver. Another option is to use Classic Ladder which has Modbus built in.

Below are links to some example configurations using VFD's with Modbus:

VF-S11

http://www.toshiba.com/ind/product_display.jsp?id1=7&id2=19
http://wiki.linuxcnc.org/cgi-bin/wiki.pl?ContributedComponents#Toshiba_VF_S11_VFD_driver_vfs11_vfd

GS2

http://www.automationdirect.com/adc/Overview/Catalog/Drives/GS2_%28115_-z-_230_-z-_460_-z-_575_VAC_V-z-Hz_Control%29
http://www.linuxcnc.org/docview/html/drivers_GS2.html
http://git.linuxcnc.org/gitweb?p=emc2.git;a=blob;f=src/hal/user_comps/gs2_vfd.c;h=17ed97b78e681c673ab768eb2e0e62bb0b7daf73;hb=e0fbe2669c1bc7b320b738f72ee15abe868aa5a9

Altivar

http://products.schneider-electric.us/products-services/products/ac-drives-and-soft-starts/
http://git.mah.priv.at/gitweb/emc2-dev.git/shortlog/refs/heads/altivar-vfd-comp

SJ200

http://www.hitachi-america.us/products/business/inverters/products/ac_variable_speed_drives/sj200/
http://www.wallacecompany.com/machine_shop/EMC2/sj200rtu-ft/
http://www.wallacecompany.com/machine_shop/EMC2/sj200rtu/

MVX9000

http://www.eaton.com/Electrical/USA/ProductsandServices/AutomationandControl/AdjustableFrequencyDrives/MVX/index.htm
http://www.wallacecompany.com/machine_shop/EMC2/mvx9000/

Hardware Overview

Typically a VFD with a Modbus option will offer a half-duplex RS-485 port for use with a single twisted wire pair cable. The port may use an RJ11 or RJ45 connector, so a telephone or network cable may be used. On the PC end, the cable connects to an RS-485 to RS-232 adapter on a serial port. Most half-duplex adapters should work if the RS-232 RTS signal is used to control the send/receive mode of the adapter. The adapter I've used cost just under $5 and is powered by the serial port pins. For long cable runs, an adapter with external power connection may be better.

Driver Method

The software consists of an HAL user component and libmodbus. libmodbus contains the functions needed talk to a serial port, convert serial data into Modbus packets and control the communication. The HAL component provides an interface between LinuxCNC and libmodbus. On the linuxcnc side, it creates HAL input or output pins for sending or receiving VFD control signals. On the VFD side, using libmodbus, it controls the serial port connection. In between, the HAL pin data is converted from or to VFD usable form, such as converting the HAL pin, motion.spindle-speed-out from a float to an unsigned integer then scale from RPM to frequency. Being a user component, it runs as a user process in Linux and not RTAI. Some functions of the component may run only once, such as initializing and reading VFD configuration data. During normal operation, a loop regularly reads the VFD pins, processes the new data, then sends new data out to the VFD. Typically the loop can run up to ten times a second, depending on the serial port Baud rate and the amount of data to send and receive.

Because each VFD maker implements Modbus differently, a custom HAL component will most likely be needed for each VFD model. Typical VFD HAL components will not be .comp files, which can be compiled and documented with the comp utility, but a C file needing its own Makefile and manual documentation. For compiling the C file, the emc2-dev (or linuxcnc-dev) package will need to be installed. This should be available using Synaptic. A Makefile can be copied from an existing sample and modified to use the new component name. The mobus.c and modbus.h files may be copied from existing examples, but it may be better to download the latest libmodbus package from the libmodbus website:
http://packages.ubuntu.com/search?keywords=libmodbus
http://libmodbus.org

Roughly, the procedure might be...
Create a directory under "/home/my_home/emc2" such as "/home/my_home/emc2/my_vfd"
Copy into "my_vfd" a sample vfd.c, modbus.c, modbus.h, and Makefile
Edit my_vfd-x.c and Makefile
Run "cp my_vfd-x my_vfd.c", "make", "sudo make install"
Copy sample linuxcnc config files in "/home/my_home/emc2/configs/myCNC/"
Edit the .hal file in "...myCNC/myCNC.hal" to "loadusr my_vfd ..." and connect HAL pins
Invoke emc2 and enjoy

Notes on using vfs11_vfd.c as the base for a new Modbus device C component -> New file from vfs11.

Classic Ladder Method

I know nothing about CL. If you know how to use Classic Ladder with a VFD using Modbus, now is your chance to become famous.

(Draft 2011/03/01 Kirk Wallace)

(Update 2014/02/21 Zeeshan M.)

Sumitomo HF-430 | Hitachi SJ300 | Hitachi L300P

These drives can be communicated using a python userspace component. First ensure the files comms.py and vfd.py are placed in $PATH.

Here is a typical configuration that needs to be added to custom.hal:

#vfd
loadusr -W vfd.py
loadrt scale count=1
addf scale.0 servo-thread
setp scale.0.gain 0.0767
setp scale.0.offset 0

net spindle-on <= vfd.spdvfd.run
net spindle-cw <= vfd.spdvfd.forward
net spindle-vel-cmd-rpm-abs => scale.0.in
net spindle-speed vfd.spdvfd.freqset <= scale.0.out

These drives use a custom serial protocol. The minimalmodbus library has been modified to include this custom protocol. Set the serial mode to MODE_CUSTOM. BCC checks are automatically performed.

The following function codes are supported:
00 - forward/rev/stop/start/run
01 - set frequency
03 - read entire monitoring data (this data cannot be accessed with function code 06!)
06 - read data from a specific register

Additionally, vfd.py demonstrates how to communicate with NFX9000 VFDs using the standard modbus protocol over ascii.

vfd.py

upload:vfd.py

comms.py

upload:comms.py

NFX9000RTU

This is a driver written in c. It is based off the MVX9000rtu code above.
upload:nfx9000rtu.zip

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited February 21, 2015 1:05 pm by Zeeshan Munir (diff)
Search:
Published under a Creative Commons License