Serial ports chapter 4 – Remote Processing RPC-2350 User Manual

Page 21

Advertising
background image

SERIAL PORTS

CHAPTER 4

4-2

Comm unication flow control
There are tw o methods to control transmission:
Hardware and software. Both are discussed below.

When RTS line in goes low, the RPC-2350 is held off
from transm itting out CO M2. The status of this port is
read by the BIT statement. T he example below returns
the status of the RTS line:

100 B = BIT(130,5)

If B = 1, transm ission is held off.

You should check this line before executing a PRINT #2
statement. If transmission is held off, the print buffer
can becom e full. PRIN T #2 com mand w ill ‘hang’ until
the buffer accepts all characters in the program line.
This may give the appearance of the program locking up
or running very slowly. This could also result in a
“de adly emb race” situation wher e the rec eiving device is
expecting some other condition before it will receive
character s.

The CT S line may be set high or low to control
comm unication fr om a dev ice when using RS-232 . T his
line is also used in RS-422/485 comm unication at P3 or
J3 to contro l transm itter output.

When u sing RS-232 comm unications, you may have to
initialize the CT S output to high to allow the sender to
transmit. The examples below show how this is done.
Line 400 sets CTS low and 500 sets it high.

400 BIT 128,4,1
500 BIT 128,4,0

A l ow c o nd it io n is su p po s ed to h ol d o f f a d ev ic e . So m e
devices do not recognize CTS output so this may be a
mute poin t.

CTS is used for RS-422/485 communications to turn
on/off the transm itter. Use C ONF IG BAU D to not only
set the baud rate but also the type of communication
protocol. C AMBASIC takes care of the CTS line for
RS-422 and RS-485.

The CO NFIG BAUD statement sets both serial ports for
baud rate and type (RS-232, RS-422, and RS-485) for
COM 2.

XON/XOFF
T h e so - ca l le d X ON / X O F F p r ot oc o l i s a s of tw a r e s c he m e
t o e n ab le a nd d is ab le tr a ns m it ti ng . S en d in g an X O F F

c h ar a c te r (A S C II v al ue 1 3H o r < C t r l- S > ) to th e RP C -
2350 will stop transmission until an XON (A SCII value
11H or < Ctrl-Q> ) is received. This does not over-ride
the RTS input line when RTS is low.

RS-232
The most comm on communication interface is RS-232.
Quite simply, RS-232 defines only ‘0' and ‘1' voltage
levels and transient speeds. It does not define baud rate,
start and stop bit length, parity or the pr otocol. RS-232
is available at J1(COM1) and J4 (COM 2).

Usually, when people speak of RS-232, they mean
something that is compatible with a PC. H owever, you
must make sure the baud rate, parity, and stop bits are
proper for your device. These ar e set in the CONFIG
BAUD com mand.

RS-232 is used in point-to-point communication. That
is, one device talks to one other device. Schemes have
been devised to network RS-232.

The maximum baud rate RS-232 supports depends upon
the distance and cable characteristics. As a rule of
thumb, 9600 baud w ill work r eliably to 50 feet.

RS-422
RS-422 is used for long distance (1000 meter s)
comm unication. It is similar to R S-232 in that it is
point-to-point and the communication “ protocol” is the
same.

The RS-485 port is used for RS-422 comm unication.
The transmitter is always on. If, for some reason, you
want to shut the transmitter off, execute

BIT 128,4,0

in your co de. To turn the transm itter back o n, e xecute

BIT 128,4,1

in your code.

RS-485
RS-485 is a popular networking system. T echnically,
RS-485 only defines electrical specifications, not
protocols. (See M ulti-drop Network below. ) In RS-
485, the transm itter is turne d on only long e nough to
send a message, then it turns off. Thus, RS-485 allows
multiple units to be put on a single set of wires.

Advertising