RS-232 protocol

The protocol RS232 defines the signals used in communication, and the hardware to transfer signals between devices.
The time diagram of the typical signal used to transfer character ‘A’  (ASCII: 6510 or 0x41) from device A to device B is given in fig.1 and would appear on the upper line TX ‐> RX between devices

Fig.1

The standard defines voltage levels V(0) to be at least +5V at the transmitting end of the line TX, and can be degraded along the line to become at least +3V at the receiving and of the line. Similarly voltage level V(1) must be at least ‐5V at TX, and at least ‐3V at RX. The standard also defined the upper limit for these voltages to be up to ±15V. Logic high is transferred as V(0)

The connectors are typically so‐called D9 connectors, and the electric wiring in between two connectors at devices A and B is shown in Fig. 2, for two female type connectors at both devices.

Fig. 2

The standard defines the number of bits to be transferred within one pack, Fig. 1 right, as eight. The duration Tb of each bit defines the speed of transmission and is called the baud‐rate. The typical baud‐rate is 9600 bits per second (Baud, Bd), and the time Tb equals 104.16µs. Other baud rates are also common: 19200 Bd, 38400 Bd, 57600 Bd …

The beginning of the pack of bits is signaled by a so called “START bit”, which has value 0 by definition. Its duration is equal to Tb. The pack of bits is terminated by so called “STOP bit” with a typical duration of Tb, bat can also last either 0.5, 1.5 or 2 Tb, depending on the application. The complete transmission of a byte at typical baud rate of 9600 Bd therefore takes 1.0416 ms.

To verify the validity of the transmission the protocol RS232 provides a so called “parity bit”. A single bit is added by the transmitter before the stop bit, and its value is selected to give either odd or even number of ones in a string.

RS-232C INTERFACE IN CNC MACHINE

Data transfer between two electronic devices (computers and controls) requires a number of settings that use the same rules for each device. Since each device may be manufactured by a different company, there must be a certain independent standard that all manufacturers adhere to. The RS-232C is such a standard – the letters RSstand for ‘Recommended Standard’. Almost every CNC system, a computer, a tape puncher and tape reader, has a connector (known as a port) that is marked RS-232C or similar. This port exists in two forms, one with a 25 pinconfiguration, the other with a 25 socketconfiguration. One with the pins is known as the DB-25P connector, one with the socket as DB-25S connector (male/female respectively). Figure3 illustrates the typical layout.

Figure 3 Typical 25-pin RS-232C port – DB type

RS-232C port on the CNC unit is usually a standard feature and uses the DB-25S type (the letter Smeans it is a socket type). An external computer, usually a desktop computer or a laptop, together with a suitable cable and communications software is also needed to transfer CNC programs. External devices use mainly the DB-25P type connector (the letter Pmeans it is a pin type). CNC program is sent to the system memory and is stored there as long as needed to run the job. CNC operator usually makes some changes and when the job is completed, all changes that are to remain permanent are sent back to the desktop computer or a laptop computer and stored on hard disk. This method works well with a single CNC machine as well as several machines.

Although terms such as Transmit(or Send) and Receiveare more common in software, some CNC systems use the terms Punch(which is equivalent to Send) and Read(which is equivalent to Receive). These terms go back to the days of punched tape.

To make this very popular method of communications work, only a suitable cable has to be installed between the computer port and the CNC system port. Loading and configuring a communications software that runs the complete operation also has to be done first. In addition, both devices must be set in a way they can ‘talk’ to each other.

The Input/Output (I/O) port RS-232C on a CNC machine is used to send and receive data. The external sources are usually a hard disk or a paper tape. In many shops, programs are transferred through the means of DNC, which means Distributed Numerical Control. The control has features available to make data transfer possible.

To communicate between one CNC machine and one computer using the RS-232C port, all equipment required is a cable between the two devices and a software. To communicate with two or more machines, using the same single RS-232C port, each machine must be connected to a split box with a cable. Split box is available with two or more outlets, selectable by a switch. This is the simplest form of DNC. It requires well organized procedures to make it work efficiently.

Some DNC software also allows a useful feature called ‘drip-feeding’, which is a method used when the program is too large to fit into the CNC memory.

TERMINOLOGY OF COMMUNICATIONS

Communications have their own terminology. There are many terms, but five terms are commonly used in CNC:

  •  Baud Rate
  •  Parity
  •  Data Bits
  •  Start Bit
  •  Stop Bit

 Baud Rate

Baud rateis the data transmission speed. It is measured as the amount of data bits per second, written as bps. Baud rates are only available in fixed amounts. Typical rates for older Fanuc controls are 50, 100, 110, 200, 300, 600, 1200, 2400, 4800 and 9600 bps. Modern controls can have the baud rate set to 2400, 4800, 9600, 19200, 38400, 57600 and 76800 bps. In terms of time, the higher the rate, the faster the transmission.

A single bit transferred at 300 bps will take 0.03333 of a second, but a single bit transferred at 2400 bps will take only 0.00042 of a second. In practice, it takes about 10 bits to transfer one character (see Stop Bitssection below), so at 2400 bps setting, the transmission will be at a rate of about 240 cps (characters per second). 4800 bps is a good setting once everything is working well. Higher settings are necessary for ‘drip-feed’ methods.

 Parity

Parityis a method of checking that all transmitted data were sent correctly. Just imagine what would happen if some characters or digits of a CNC program were not transferred correctly or not transferred at all. Parity can be even, odd, or none,and evenis the most common selection for CNC communications. This is similar to punched tape parity.

 Data Bits

A bitis an acronym for Binary digit and is the smallest unit that can store information in a computer. Each binary digit can have a value of either one (1) or zero (0). One and zero represent the ON and OFF status respectively, so a bitis something like a toggle switch that can be turned on and off as needed. In the computer, every letter, digit, and symbol used in a CNC program is represented by a series of bits, eight bits to be precise, that create a unit called a byte.

 Start and Stop Bits

To prevent loss of data during communication, each byte is preceded by a special bit called the start bit, which is low in voltage level signal. This signal is sent to the data receiving device and informs it that a byte of data is coming next.

A bit similar to the start bit, but at the endof the byte, has exactly the opposite meaning. It sends a signal to the receiving device that the byte has ended or stopped being transmitted. This bit at the end of a byte is called the stop bit. Because the start and stop bits go together, they are often teamed up together as the stop bits and set the devices to two stop bits.

Many terms exist in communications. With growing interest, this is a very rich field to study.

DATA SETTING

Data used for communications must be set properly before data transfer can begin. The setting at one end (computer or the CNC system) must match the setting at the other end. For baud rate, consult the machine manual – a good start is at 2400 bps. Newer models have a higher default. Typical software setting is done through the configuration at the computer end and through the CNC system parameters at the CNC end. Settings at both ends must match. Typical Fanuc settings are:

 4800 bps baud rate

 Even parity

 7 data bits (seven data bits)

 2 stop bits (two stop bits)

Proper connection depends mainly on the configuration of connecting data cables.

CONNECTING CABLES

The most common cable for communication between a CNC machine and a computer is a shielded and grounded cable, containing several small wires (at least eight), each one enclosed in a colored plastic sleeve. Main purpose of making a communication cable is to connect the CNC port (usually 25 sockets) with the computer port (usually 25 pins), using a properly configured cable. Always use a cable of high quality. Shielded cables can reach farther distances and are generally better choice to withstand interferences during data transmission. Wires are identified by their gauge value, for example a 22-gauge or a 24-gauge wire is a good choice for communications.

The 25-pin port has each pin or socket numbered (see the first page of this chapter) and individual wires of the cable have to be connected to proper numbers at each end. It is quite common to ‘cross ‘the wires between each end. Typical crossing would be between the pin number 2 and the socket number 3, and a pin 3 and socket 2. Some numbered positions have to be connected at the same endof the cable. This is called ‘jumping’.

 Null Modem

A very common cable wiring that is used in general communications is called a null modem. Connection of the two ends follows a certain standard, shown in Figure 52-5. Each number represents the pin or socket on the DB-25 connector. Note the jumps between connections 6 and 8 at both ends. Figure 52-6shows the same null modem configuration in a graphic way. This is a very popular method showing cable configurations.

PIN DB-25PSOCKET DB-25S
11
23
32
45
54
77
6 and 820
206 and 8

Figure 52-5 Null modem pin connections

Null modem pin connections

Figure 52-6 Graphic representation of null modem connections

 Cabling for Fanuc and PC

As the most common cable communication will be between a Fanuc control and a desktop computer or a laptop, Figure 52-7illustrates a typical cable configuration. Note the similarity to the null modem configuration.

Figure 52-7 Typical cable configuration for Fanuc controls

Regardless of what cable configuration will be used, a good communication software that will run the whole operation is also needed. Some companies use a software specially designed for CNC work, others purchase very inexpensive communications software, sold by the majority of computer stores.

Leave a Reply