Modbus RTU and EMC
(2011/03/13) Update - I waited long enough to have someone else develop the software. Following these examples:
GS2
VFS11
should make it fairly easy to make an SJ200 component. modbus.c and modbus.h provide the functions that communicate with the serial port and Modbus registers. The device file just needs to create the hal pins, handle any data conversion between pin and register forms, then call the proper Modbus transfer type. I used this process to make a ModIO component detailed here:
ModIO
Original Text
I am using a VFD to drive the spindle motors on all of my CNC machines. They are all pretty much set up the same way. A DAC option on my controller drives an analog input on the VFD. Two digital lines from the controller or PC parallel port drive the Forward and Reverse VFD digital inputs. The alarm relay NC (normally closed) output on the VFD is in series with the E-stop chain. So far this is working very well.
On the Hardinge lathe, I have an Hitachi SJ200 and noticed that it has an RS-485 Modbus RTU port. I was thinking that with two wires between the PC and the VFD, I could control and monitor all features of the VFD. This page will explore this idea.
EMC2 does not support Modbus yet, but that should change in the near (or not so near) future. It's not clear yet what role Modbus should play in the EMC2 realm. EMC already has a very good means of controlling all sorts of hardware, in real and non-real time. I believe, Modbus would be most useful for controlling legacy slaves. Such as my situation, where my existing VFD has Modbus built in, or a machine being converted to EMC2, which has an existing PLC for a tool changer. (Although, I would tend to remove the PLC and go directly to EMC with some form of parallel port system.)
The Modbus specification is here: Modbus Spec
The Modbus serial line guide is here: Modbus Serial Line Guide
The Modbus home is here: Modbus Home
The Hitachi SJ200 manual is here: SJ200 Manual
SJ200 Series Inverter Quick Reference Guide: SJ200 QRG
SJ200 Series Brochure: SJ200 Brochure
SJ200 Service Manual: SJ200 SM
Here is a first pass at Modbus communication: read_Din-1b.c
Basic tasks:
- Make or buy a PC serial port to RS-485 adapter
- Find a Linux application that can be used to do a "Hello World" to the SJ200 (Classic Ladder?)
- Chris Morley enabled Modbus for Classic Ladder on EMC here: http://wiki.linuxcnc.org/cgi-bin/emcinfo.pl/emcinfo.pl?ClassicLadder_Ver_7.124.
- I found that Classic Ladder's Modbus uses termios to handle the serial communications. I searched for termios and got this page: http://en.wikibooks.org/wiki/Serial_Programming:Unix/termios. This has gotten me far enough to be able to set the basic serial port parameters and send a character string out the port. Now, I need to figure out the receive part, the Mobus protocol timing and handling the transceiver control. This should allow me to send out a a pre-formatted message and watch for a reply.
- (2008/02/20) I have a new Modbus toy. A ModIO from Homann Designs ( link to ModIO ). This has been a great help in that I don't have to disable my lathe to develop the Modbus communication. I now have a C program (see read_Din-1b.c link above) that starts with a pre-formatted command to the ModIO to read the register that contains the pin status of the digital inputs. A CRC of the command string is calculated and appended. The resulting string is sent out the serial port. If the ModIO receives the command properly, it returns a response message with the digital port status. My program waits a short time to insure the message is in the response buffer. Then it calculates a CRC and displays it and the CRC sent in the response.
- Develop a Serial Port HAL component or driver. Maybe have a serial_msg_out and a serial_msg_in component. The Modbus component would send a message string to the serial_msg_out and then poll the serial_msg_in for the response.
- Develop a Modbus protocol HAL component or driver. This would handle the protocol timing and CRC check.
- Develop an SJ200 Modbus RTU component, which would have pins for the VFD's features and corresponding message strings.
- ?
(More to come)
|