Fanuc, RS232, Cables, Flow Control and easyDnc.

Information and questions about Denford CNC Control electronics, general electrical issues, cables, diagrams, stepper motors, drives etc...

Moderators: Martin, Steve, Mr Magoo

Post Reply
easydnc
Posts: 5
Joined: Wed 04 Jul , 2007 20:21 pm
Location: easydnc.com

Fanuc, RS232, Cables, Flow Control and easyDnc.

Post by easydnc » Fri 13 Jul , 2007 15:54 pm

To use any DNC or file transfer software with a Fanuc control the RS232 cable needs, as a minimum, the following connections (Receive, Transmit and DataGround)

PC25pin to CNC25pin

2 – 3
3 – 2
7 – 7

PC9Way to CNC25 way

2 – 2
3 – 3
5 - 7


On the connector at the CNC end of the cable pins 4 and 5 should be shorted to each other. Also short Pins 6, 8 and 20 to each other at the CNC. These shorting links may also be required at the computer end of the cable depending on the software you're using. They are not required at the computer end if you're using easyDnc.

The above cable will permit XonXoff flow control only.

In Windows95 and above the XonXoff flow control is handled by the operating system and, I would add, not very efficiently.

I would suggest that RTS/CTS flow control be used wherever possible. This requires a different cable layout.

If your cable only has the 3 connection (2,3 and 7) described above then you have no choice but to use the XonXoff flow control. However, many CNC controls are able to use RTS/CTS flow control even if the options and parameter settings inside the control don’t mention it anywhere. I would therefore suggest always making up your cable as follows.

PC25pin to CNC25pin
2 – 3
3 – 2
7 – 7
4 – 5
5 – 4



PC9pin to CNC 25pin

2 – 2
3 – 3
5 – 7

7 – 5
8 - 4


And at the connector at the CNC end of the cable make the shorting link between pins 6, 8 and 20


This cable will work with XonXoff as well as with RTS/CTS. Many Fanuc controls don’t have any obvious setup for RTS/CTS flow control but they still toggle their RTS pin whenever they change their flow control status. If you wire your cable for RTS/CTS then you increase your chances of error free communications.

Next thing is a change to a setting in Windows called the "FIFO buffer". I won’t go into technical reasons for this at this point but if you experience data corruption and/or buffer overflow when sending data to a fanuc then changing the FIFO in windows will often help.

If you have a ‘My Computer’ icon on your desktop click it with the right mouse button and select Properties. Then Hardware > Device Manager > Ports Com & LPT. (That’s how you get to Device manager on Windows XP. Windows95 is similar) If you don’t have the My Computer icon on your desktop then get to the device manager via the windows Control Panel > System > etc.

When you get to device manager > Com Ports, select the relevant com port, right click and select Properties > Port Settings > Advanced. In there you will see a couple of checkboxes and sliders for FIFO settings. Slide these right down to zero and disable FIFO.

Don’t bother with any of the other settings in the port properties. Just change the FIFO, save and exit. I must confess at this point that I don't know whether you need to reboot your computer at this point. Sometimes it helps, other times it doesn't seem to need it. Reboot anyway, it won't harm and then go back in check the setting to make sure it stuck after a reboot.

How to setup easyDnc. The best thing to do is to download the free trial of easyDnc at www.easydnc.com There’s also a PDF user guide so download that too. Install easyDnc and open the user guide and skip to the section about ‘Port Scan’. This is a neat feature we built into easyDnc so that it can, in many cases, set itself up without you needing to worry about settings such as Baud rate, Databits etc.


Here’s a bit of simple technical stuff which you don’t need to read unless you want to.


The most common reason for failure while sending data to a fanuc control is buffer overflow. (The result of a buffer overflow is either a buffer overflow alarm or data in the CNC is all jumbled up with bits missing) Of course flow control (XonXoff or RTS/CTS) is supposed to control the flow of data preventing buffer overflow in the control’s receive buffer. Therein lies the problem. Inside the computer is a microchip which is responsible for the actual sending and receiving of RS232 data. That chip has a 16 character buffer.

XonXoff flow control only controls the movement of data from Windows into that chip. Windows has no control over the flow of data once it’s in the chip meaning once the chip is full then XonXoff can not stop those 16 bytes of data being sent to the CNC even if the CNC isn’t ready for them.

16 bytes doesn’t sound like much but way back when Fanuc controls were first thought of a standard MicroComputer only had RS232 with a one byte transmit buffer so the Fanuc’s ability to receive 10 bytes without missing any was considered quite cutting edge stuff.

The Fanuc will send a stop signal to the computer when its buffer is almost full with only 10 bytes of space remaining. If more than 10 bytes arrives then a buffer overflow will occur. As mentioned already, the computer’s transmitter has 16 bytes and, when using XonXoff flow control nothing can stop those 16 bytes from hitting the fanuc’s receive buffer. In many cases the Fanuc will have cleared a little more space in its receive buffer before those 16 bytes arrives meaning a lot of data can be transferred successfully but other times a buffer over flow occurs causing an alarm or data corruption..

Such buffer errors can usually be prevented by:-

a) Increase the time delay between blocks of data. In easyDnc this is the BlockDelay setting. This makes the whole transmission slower giving the CNC time to clear out a bit more space before the next block of data comes in.

b) Disable the 16 byte buffer in the computer (The FIFO buffer) so that it can only stack up one byte at a time. This never slows down the overall flow of data but it gives the computer time to see and react to Xoff signals from the CNC which means that the fanuc isn’t going to get hit by 16 bytes when it’s only got room for 10.

c) Wherever possible use RTS/CTS flow control. As mentioned above you often don’t have any RTS/CTS option in the control but just by having a cable capable of using RTS/CTS means the machine ‘can’ use it if it’s able to. (You will of course need to select either XonXoff or RTS/CTS option in easyDnc’s setup whenever you switch from one method to the other.


The reason why RTS/CTS is more efficient than XonXoff is because RTS/CTS is all hardware with dedicated control lines (Pins 4 and 5 at the CNC) and is handled directly by the communications chips. There’s no software involved. Changes to the status of flow control at one end of the link will have an immediate change to the status at the other. No delay even on the slowest of computers.

XonXoff on the other hand, is software. Flow control signals are simply inserted into the RS232 data stream so, especially in a windows computer it’s a bit hit or miss how fast Windows will respond to a change in status.

Last thing I'll mention is USB. Many modern computers and most Laptops are now supplied without RS232 ports. You can however get low cost USB to RS232 adapters. If you use these you MUST install the software from the CD which came with the USB/RS232 adapter. I don't know of any computer or version of windows which is able to correctly identify such a USB/RS232 adapter and set it up correctly as a COM port. What I mean is that it will appear to Windows as a USB device but no Windows software will be able to use it as a COM port unless you install the correct drivers which makes the USB emulate a standard RS232 port.

Next thing about the USB is the size of the buffers. Above I mentioned the Windows FIFO and the 16 byte transmitter chip. Well, USB takes this even further with, in some cases, 128 bytes of buffering which will of course exagerate the problems described above. They also don't react to switching off the FIFO so this brings us back to the RTS/CTS. if you can use RTS/CTS then you'll have very few problems with USB.

If you must drip feed via USB and you can't use RTS/CTS then keep the baud rate as low as you can live with and increase the size of the delay between characters and/or block. (In easyDnc this is the Block Delay option)

I hope this has gone some way to helping get communications working with older Fanuc controls. In fact, the same goes for pretty much any CNC.

You can get a trial copy of easyDnc at www.easydnc.com but most of what I've said here about Cables, Flow control, FIFO, USB etc goes for pretty much any RS232 comms applications.

User avatar
Denford Admin
Site Admin
Posts: 3634
Joined: Fri 10 Feb , 2006 12:40 pm
Hardware/Software: Go to User Control Panel > Profile
Enter as much information about your CNC hardware and software as you can - it makes it easier for everyone to know what you're talking about then.
Location: Sunny Brighouse
Contact:

Post by Denford Admin » Mon 16 Jul , 2007 12:08 pm

Thanks for that - its nice to finally understand why stuff hasn't worked properly in the past :)

We did find a very good USB to RS232 adaptor here: http://www.easysync.co.uk/ but they must be in small demand, as the price goes up every time I look.
In fact, I would advise anyone who relies on RS232, to stock up on Interface cards or adaptors now - we are finding com ports harder to find and more costly than ever.

Post Reply