0% found this document useful (0 votes)
84 views10 pages

Serial Communication

The document discusses asynchronous serial communication, which involves sending data one bit at a time over a communication channel. It describes how serial communication works, including start/stop bits and baud rate. It also discusses RS-232 standards, cables, handshaking methods, and other terminology related to serial communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views10 pages

Serial Communication

The document discusses asynchronous serial communication, which involves sending data one bit at a time over a communication channel. It describes how serial communication works, including start/stop bits and baud rate. It also discusses RS-232 standards, cables, handshaking methods, and other terminology related to serial communication.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Serial Communication (RS232)

(Wikipedia)

In telecommunication and data transmission, serial communication is the process of


sending data one bit at a time, sequentially, over a communication channel or computer bus.
This is in contrast to parallel communication, where several bits are sent as a whole, on a
link with several parallel channels.

One of the earliest forms of serial communication was paper tape. About 25mm wide, one
inch in old money, Upto 8 holes were punched across the tape in rows, each row
represented one character based on its binary value.

Currently we serial communications to transfer programs from a host PC into a machine


controller that is non-Windows based. In others words, it has no possibility of being
networked and also has not portable media such as a disk drive or USB.

Asynchronous serial communication is a form of serial communication in which the


communicating endpoints' interfaces are not continuously synchronized by a common clock
signal. Instead of a common synchronization signal, the data stream contains
synchronization information in form of start and stop signals, before and after each unit of
transmission, respectively. The start signal prepares the receiver for arrival of data and
the stop signal resets its state to enable triggering of a new sequence.

In this diagram, two bytes are sent, each consisting of a start bit, followed by eight data bits
(bits 0-7), and one stop bit, for a 10-bit character frame. The last data bit is sometimes used
as a parity bit (odd or even).
So the method of communication used to transmit programs to a machine is Asynchronous
serial communication, although we generally refer to it simply as serial comms.

Programs are sent using an application, for Lantek there are a few of these available, some
for specific protocols. The most common one is called DNCSTD, it can only transmit
programs but is also capable of handling remote requests. There is a more basic one called
WLTCom, this can both transmit and receive programs but has no remote capabilities.

In addition to an application we also need a cable, no surprise there. RS232 cable is similar
to network cable but is shielded to help prevent electrical interference. It is available in
various multi-core forms, we generally order 5 core cable, although most commonly we only
connect three of these cores between the two ends.

Terminology

There is quite a lot of terminology involved in serial communication, starting with the type or
method. There are various standards, RS232, RS422, RS485 and current loop (20mA). We
only get involved with RS232.

I am by no means an expert on RS232 communications, so you can probably consider this


document as a Dummies Guide to RS232. Primarily because it has been written by one!

As you would expect there is standard for the pin connections, although there is no such
thing a standard RS232 cable. In others word, you can’t walk into Maplins and buy one off
the shelf. There is however a fairly standard configuration that we typically use, so this if
anything is what we would consider as a standard cable.

Handshaking – This is nothing to do with personal greetings or social pleasantries. Because


serial communications is a very basic method of communicating, it needs a method of telling
the other end to stop or start, this is handshaking. There are two methods, software
handshaking and hardware handshaking.

Software handshaking sends a signal or character within the data stream, one to stop
sending data the other to start. They are referred to as control characters. Control characters
have an ASCII value below 32, for example LF (line feed) has an ASCII value of 10 and CR
(carriage return) is 13.

There were originally four control characters used with paper tape machines, punch on /
punch off (DC1/DC3) and reader on / reader off (DC2/DC4. We still use these but are only
interested in two of them. XON (DC1) and XOFF (DC3). By the way, DC stands for Device
Control in case you hadn’t figured that out.

XOFF Pause transmission DC3 ASCII 19 (Dec) 13 (Hex)


XON Resume transmission DC1 ASCII 17 (Dec) 11 (Hex)
There are others such as :-

ASCII Name Description Control Character

0 NUL Null character (blank) ^@


1 SOH Start of header ^A
2 STX Start of text ^B
3 ETX End of text ^C
4 EOT End of transmission ^D
5 ENQ Enquiry ^E
6 ACK Acknowledge ^F
7 BEL makes a “Bing” noise ^G
8 BS not what you think! ^H
(backspace)

17 DC1 Start Transmission ^Q


18 DC2 Start reader ^R
19 DC3 Stop transmission ^S
20 DC4 Stop reader ^T
26 EOF End of file ^Z
27 ESC Escape ^[

Pin assignment terms


TX or TXD Transmit
RX or RXD Recieve
RTS Request To Send (hardware handshaking)
CTS Clear To Send (hardware handshaking)
DSR Data Set Ready
DTR Data Terminal Ready
DCD Data Carrier Detect

RS232 uses a low voltage, 24V I think – I did say I wasn’t an expert! This can be positive or
negative, so for hardware handshaking purposes a pin would be considered high or low
(positive or negative I assume). If you want to know more try using Google!
Pin Assigment

There are two types of standard serial ports, 9 pin and 25 pin. When I say standard, I’m
referring to Asynchronous serial ports which have become as rare as Rocking Horse Shit
these days, as USB has taken over (the World).

So here are the pin assignments for both types of Asynchronous ports :-

9 Pin
1 DCD
2 RXD
3 TXD
4 DTR
5 GND
6 DSR
7 RTS
8 CTS
9 RI
25 Pin

1 GND …

2 TXD …

3 RXD 20 DTR

4 RTS 21

5 CTS 22 RI

6 DSR 23

7 GND 24

8 DCD 25
Framing

Because each character has to be broken down into bits and sent single file down the
RS232 link, there has to be a very precise format so that it can be re-assembled at the other
end. It is also useful to add a break between each set of bits (1 character) like we add
spaces between written words. Ifwedidntdothisitwouldbeimpossibletoread!

So the device at each end must use the same speed and same structure, this is referred to
as framing. The transmission speed is called the Baud Rate, it is measured in bits per
second. There are sections to each character sent, the data bits, stop bits and an optional
parity bit. Here is some text describing each, lifted from the internet:-

a. Baud rate is a speed measurement for communication. It indicates the number of bit
transfers per second. For example, 300 baud is 300 bits per second. Higher baud rates
are used when the devices are located closer together.

b. Data bits are a measurement of the actual data bits in a transmission. When the
computer sends a packet of information, the amount of actual data may not be a full 8
bits. Standard values for the data packets are 5, 7, and 8 bits. Which setting you choose
depends on what information you are transferring. For example, standard ASCII has
values from 0 to 127 (7 bits). Extended ASCII uses 0 to 255 (8 bits). If the data being
transferred is simple text (standard ASCII), then sending 7 bits of data per packet is
sufficient for communication. A packet refers to a single byte transfer, including start/stop
bits, data bits, and parity. Since the number of actual bits depend on the protocol
selected, the term packet is used to cover all instances.

c. Stop bits are used to signal the end of communication for a single packet. Typical
values are 1, 1.5, and 2 bits. Since the data is clocked across the lines and each device
has its own clock, it is possible for the two devices to become slightly out of sync.
Therefore, the stop bits not only indicate the end of transmission but also give the
computers some room for error in the clock speeds. The more bits that are used for stop
bits, the greater the lenience in synchronizing the different clocks, but the slower the
data transmission rate.

d. Parity is a simple form of error checking that is used in serial communication. There are
four types of parity: even, odd, marked, and spaced. The option of using no parity is also
available. For even and odd parity, the serial port will set the parity bit (the last bit after
the data bits) to a value to ensure that the transmission has an even or odd number of
logic high bits. For example, if the data was 011, then for even parity, the parity bit would
be 0 to keep the number of logic high bits even. If the parity was odd, then the parity bit
would be 1, resulting in 3 logic high bits. Marked and spaced parity does not actually
check the data bits, but simply sets the parity bit high for marked parity or low for spaced
parity. This allows the receiving device to know the state of a bit which enables the
device to determine if noise is corrupting the data or if the transmitting and receiving
devices' clocks are out of sync.
Cables and Pin Connections

Most machines or more specifically the control systems will have a 25 way female
connector, which means we need to make up a cable with a 25 way male connector.

The computer is unlikely to have a 25 way serial port. In fact, it’s unlikely to have any serial
ports 9 or 25 way unless it has been specified when the PC was built. Whether it has an on-
board serial port or we using a USB to Serial adaptor, it will be 9 pin male, so we need to fit
a 9 pin female connector to the PC end.

As we generally use software handshaking, we only need three cores to connect straight
though. Although we make other connections at the machine end locally on the 25 way
connector which we refer to as links. A link is where you bridge two or more connections
making a feedback loop, a bit like keeping your finger pressed on the Enter key.

This is because the controller is often using hardware handshaking as well as software
handshaking. If we did connect more cores for hardware handshaking, we would be
connecting the RTS / CTS lines. If we had two 25 way connectors, pin 4 at the PC end would
connect to pin 5 at the machine end and likewise pin 5 to pin 4. NOTE: this is assuming
BOTH ends are 25 way.

So linking pins 4 and 5 at the machine end would basically trap out the hardware
handshaking, to make it always on or always ready to send / receive.
The links we add typically are as follows:-
5, 6, 8 & 20

Links can be made by using short sections of cable to form a loop or if the pins to be linked
are next to each other, then a solder a bridge can be used.
Configuring the Devices

The first task is to establish how the receiving end is configured. As long as we know the
baud rate and the framing we can set our application to match. If we can change the
receiving end (easily) we may decide to change the baud rate, increasing it where possible
to speed up communication but in some cases, if the distance between the devices (cable
length) is greater or there is a lot of welding equipment that may cause electrical
interference, we may slow down the baud rate. Typically we would use 4800 or 9600.

WLTCom

We need to identify and configure the port number to use, if the PC has an on-board com
port, it is likely to be COM1. If it is a USB to serial or a Moxa box it is more likely to be
mapped to a different port number, say 3 or 4.
Common configurations are:-

9600, 8 data bits, 1 stop bit, No Parity

9600, 7 data bits, 1 stop bit, Even Parity

Time Out, this applies to receiving data, it will wait for the specified period, if it has not
received any data then it will time out.

End of line allows a number of characters to be entered as ASCII values, the default is 13
10, carriage return / line feed. It is not necessary to use this unless a specific set of
characters is required for end of line. Flow control (n) milliseconds every (x) characters is
also not used commonly, this would be to pad out the data will nulls.

The options to set characters for Start/End transmission or reception can be used if for
example we needed to output control characters such as STX / ETX (Start Of Text / End Of
Text).

Flow control is normally Xon/Xoff which is software handshaking, you can specify the ASCII
value for XON and XOFF although these are generally fixed as 17 and 19.
Directory and Extension are more for the application to know where to look for CNC files.

NOTE : WLTCom cannot be configured to wait for a start character, so if you click on the
transmit button and select a file, it will squirt the data out straight away. Using DNCSTD on
the other hand, it is possible to configure the application to wait for a specified start
character. The most common one being 17 (Xon).
DNCSTD

This is the standard application used for RS232 communications other than those for
specific protocols, DNCBURNY for example. These applications reside in the Expert folder
and require a license to run. If communications is required on a stand-alone computer (not
running Expert), a Comms Only license is available. The application is designed to run in the
background, so it can be launched from the Startup. It will be present in the System Tray and
can be opened and closed without actually exiting the application.

In terms of communications, the application can be used in one of two ways. It is possible to
select the file to transmit in the same way as WLTCom, either waiting for a start character or
transmitting the selected file straight away. It can also be used to respond to a remote
request.

The first method requires interaction at both ends. In other words we have got to get the
machine ready to receive then send the program from the PC or when configured to wait for
a start character, it is possible to select the program to send and then go to the machine to
enter receive mode. This of course requires the control to “send” the start character to
initiate the transmission. Both Fanuc and Bosch control can typically do this.
Configure the port settings in the same way as WLTCom, entering the correct port number. If
the specified port does not exist or is not accessible an Initialisation error will be shown.

Click the more button, ensure that Flow Control is set to Xon / Xoff and RTS/CTS is
unticked, otherwise the cable would require the additional cores to be connected.

Click on the next Tab, Transmission PC->CN.

There are two options that can be set here, firstly the Character to start manual
transmission. If you want to select the file to send prior to transmission, the application will
simply wait until it receives the incoming signal to start sending data.

The program can be requested from the machine, this is kind of remote comms as it does
not need any manual input from the PC end. This is achieved by editing a program on the
machine controller to enter the program number required (filename), this is the sent to the
host PC. The application monitors the port for any incoming data, if the data received
conforms to the format specified at the top of the dialogue, it will look for the corresponding
file and send it back.

At the machine end. The operator has got to send OUT the dummy program containing the
request and then push more buttons to reset the control into a receive mode. As the
application would process the request in milliseconds, it needs a delay time before sending
the program. So the time needed to set the control in reception needs to be set to the
required time. Say 5 – 10 seconds.

You might also like