You are on page 1of 10

Chapter - Serial Communications

Devicenet

Computer

RS-232

Serial
Parallel
Network

Process
Actuators

Process
Sensors
Process

Process
Actuators
PLC
Normal I/O on PLC

Process
Sensors

Serial Communications
50 ft
RS-232c

Txd

Rxd

In

Out
com

3000 ft
RS-422a
In

Out

3000 ft
RS-423a
In

Out

Serial Bytes
true
false

before

start

data

parity

stop

idle

Cables
Modem

Computer

Null-Modem

Three wire

Computer

Computer
A

Computer
A

Computer
A

com
txd
rxd
dsr
dtr

com
txd
rxd
dsr
dtr

com
txd
rxd
cts
rts

com
txd
rxd
cts
rts

com
txd
rxd
dsr
dtr
cts
rts

com
txd
rxd
dsr
dtr
cts
rts

com
txd
rxd
cts
rts

com
txd
rxd
cts
rts

Modem

Computer
B

Computer
B

Computer
B

Serial Connectors
DB-25
1

2 3 4 5 6 7 8 9 10 11 12 13
14 15 16 17 18 19 20 21 22 23 24 25

Commonly used pins


1 - GND (chassis ground)
2 - TXD (transmit data)
3 - RXD (receive data)
4 - RTS (request to send)
5 - CTS (clear to send)
6 - DSR (data set ready)
7 - COM (common)
8 - DCD (Data Carrier Detect)
20 - DTR (data terminal ready)

DB-9
1

2
6

3
7

4
8

1 - DCD
2 - RXD
3 - TXD
4 - DTR
5 - COM
6 - DSR
7 - RTS
8 - CTS
9 - RI

5
9

RS-232 with a PLC-5

PLC

R S - 2 3 2 C a b le

com 1
T e r m in a l
E m u la t o r

channel 0

AW T
C hannel 0
s o u r c e : e x a m p le
S e r ia lP o r t C o n t r o l: s e r _ c n t
S e r ia lP o r t C o n t r o lL e n : 4

ASCII Functions
A W A ( c h a n n e l, s t r in g , c o n t r o l, le n g t h ) - a p p e n d c h a r a c t e r s t o t h e o u t p u t b u f
fe r
A B L ( c h a n n e l, c o n t r o l) - r e p o r t s t h e n u m b e r o f A S C I I c h a r a c t e r s in c lu d in g lin e e n d in g s
A C B ( c h a n n e l, c o n t r o l) - r e p o r t s t h e n u m b e r s o f A S C I I c h a r a c t e r s in b u f
fe r
A H L ( c h a n n e l, m a s k , m a s k , c o n t r o l) - d o e s d a t a h a n d s h a k in g
A R D ( c h a n n e l, d e s t , c o n t r o l, le n g t h ) - w ill g e t c h a r a c t e r s f r o m t h e A S C I I b u f
fe r
A R L ( c h a n n e l, d e s t , c o n t r o l, le n g t h ) - w ill g e t c h a r a c t e r s f r o m a n A S C I I b u f
fe r
A S R ( s t r in g , s t r in g ) - c o m p a r e s t w o s t r in g s
A W T ( c h a n n e l, s t r in g , c o n t r o l, le n g t h ) - w ill w r it e c h a r a c t e r s t o a n A S C I I o u t p u t
C O N C A T ( s t r in g , s t r in g , d e s t ) - c o n c a t e n a t e s t r in g s
D E L E T E ( s t r in g , le n , s t a r t , d e s t ) - d e le t e s c h a r a c t e r s f r o m a la r
g e r s t r in g
D T O S ( in t e g e r , s t r in g ) - c o n v e r t a n in t e g e r t o a s t r in g
F I N D ( s t r in g , s t r in g , s t a r t ) - f in d o n e s t r in g in s id e a n o t h e r
I N S E R T ( s t r in g , s t r in g , s t a r t , d e s t ) - p u t s c h a r a c t e r s in s id e a s t r in g
L O W E R ( in t e g e r , s t r in g ) - c o n v e r t a s t r in g t o lo w e r c a s e
M I D ( s t r in g , s t a r t , le n g t h , d e s t ) - t h is w ill c o p y a s e g m e n t o f a s t r in g o u t o f a la r
g e r s t r in g
R T O S ( in t e g e r , s t r in g ) - c o n v e r t a r e a l t o a s t r in g
S T O D ( s t r in g , d e s t ) - c o n v e r t A S C I I s t r in g t o in t e g e r
S T O R ( s t r in g , d e s t ) - c o n v e r t A S C I I s t r in g t o r e a l
U P P E R ( s t r in g , d e s t ) - c o n v e r t a s t r in g t o u p p e r c a s e

Example
in p u t _ c t l. E N

G EQ
S o u r c e A in p u t _ c t l. P O S
S o u rc e B 2

r e a d _ c t l. D N

A C B
C hannel 0
C o n t r o l in p u t _ c t l
A RL
C hannel 0
D e s t s t r _ in
C o n tr o l re a d _ c tl
L e n g th 2
C O N C AT
S t r in g A s t r _ p r e
S t r in g B s t r _ in
D e s t s tr_ o u t
AW T

s tr_ p re = "H I "

C hannel 0
S t r in g s t r _ o u t
C o n tr o l o u tp u t_ c tl
L e n g th 7

Another Example
STO D
S t r in g s t r _ a
D e s t in t _ a
STO D
S t r in g s t r _ b
D e s t in t _ b
ADD
S o u r c e A in t _ a
S o u r c e B in t _ b
D e s t in t _ c
DTO S
S o u r c e in t _ c
S t r in g s t r _ c

Yet Another Example


A

AC B
C hannel 1
C o n tro l c n t_ 1
ABL
C hannel 1
C o n tro l c n t_ 2

M ID
S o u r c e s tr _ a
Ind e x 5
L e n g th 2
D e s t s tr_ b

EQ U
S t r in g A s t r _ c
S t r in g B s t r _ d

s t r in g _ m a t c h

You might also like