RS-232 for nerds

RS232 is a serial communication standard. This standard specifies signal levels, error correction methods, and other details. RS232 is a standard developed in the 1960s and is still used in many devices.

The RS232 standard allows electronic devices to communicate with each other. This standard enables one device (for example, a computer) to send and receive data from another device (for example, a printer). RS232 performs this operation using the serial communication method.

RS232 is used in many different devices. For example, RS232 is used for a computer to send data to a printer. This standard is also used for a keyboard to send data to a computer. Today, more advanced serial communication standards are used instead of RS232.

RS-232, a protocol dating back to the 60s, is difficult for the unfamiliar to understand and use. Although it was thought to be sufficient in the years it was released, it has been updated several times over time. In its original state, synchronized data communication was made between the transmitter and receiver without any error checking. At that time data sizes were small enough to be measured in a few kilobytes or even bytes, so rates of 600 baud were quite sufficient. Of course, in those years, it was not foreseen how the future computers, printers, test equipment, post devices and other devices would develop, and the standard was shaped only then to the extent that they would do their job. (Electronic Industries Association – EIA)

Over the years, as the size of the data transferred due to technological advances has increased, higher speeds have begun to be needed. This has started to cause the data to be sent by being compressed even more. As the data transfer rate increased, data corruption started to occur due to physical conditions and the danger of sending incorrect information to the receiver emerged.

As a result, solutions such as adding the parity bit and controlling the flow with handshake were used. However, this protocol is too slow for data transfer nowadays and it is no longer its main task. However, it is possible to find this port on many devices. Even on modern devices, we can do basic console operations and debugging directly from this port. Sometimes this can be the only method in some industrial devices that do not have an IP address, or even an ethernet port, without a screen, without a keyboard, and almost like a closed box. This type of connection is also used for debugging with Arduino.

Voltage levels are important

The RS-232 standard defined voltage levels for data transmission and control signal lines corresponding to the logical one and logical zero levels as follows. Valid signals are in the range of +3 to +15 volts or -3 to -15 volts relative to the “Common Ground” (GND) pin; As a result, the range from −3 to +3 volts is not a valid RS-232 level.

±5 V, ±10 V, ±12 V and ±15 V are commonly used voltage levels. The signals between the two ends should be balanced with each other and in these ranges according to the GND pin. The two ends should be as close to each other as possible. If the distance is long, the GND voltages may be different. This becomes even more critical if the devices at the two ends are fed from different power sources. This can be solved by keeping the GND voltages as close to each other as possible. Good grounding is a good solution to this.

In the above example, it belongs to the file received via RS-232 from a Siemens CNC machine. The header, which is the first line of the file, contains some information. The first of the two examples above were taken as PC Format and the other as Punched Tape. It seems more understandable for people with punched tape.

The first line of the file is the filename, the second line is the location from which it was taken. In addition, the end of the file is determined with 25(HEX) characters. This file contains only one MPF program.

When I import the whole folder as WPD, all programs and paths are seen. These 3 programs are arranged in the same file as a continuation of the previous one.

If we restore this WPD file, it will be reinstalled on the machine with the correct directory structure.

This picture theoretically shows the shape of the signal when the letter J is sent over the RS232 interface. The real state is more in the form of curves. In the figure, the bit stream at the 0V and 5V logic levels is sent from the out pin of the microcontroller. Boosted to ±12 volts with an inverter like the MAX232. -12V corresponds to logic 1 and +12V to logic 0. Output voltages can be between ± 5V and ± 25 V. High voltage is more useful in long distance transmissions.

The period of 1 bit in this figure is 1/frequency. For 9600 bps, it is seen as 1/9600, i.e. 104,166 microseconds.

In serial communication, information is sent sequentially. RS-232 sends 8 bits of data and 1 bit of parity bit and 1 byte of information. There is no signal to indicate where the bits begin and end. Receiver and sender parties must work at the same speed. What is meant by speed here is the value known as baud rate. ex

Leave a Reply