beautypg.com

Accessing serial buffers – Remote Processing RPC-330 User Manual

Page 16

background image

SERIAL PORTS

SECTION 4

Page 4-3 RPC -330

Figure 4-3 Data packet

Two wire RS-485

The RS-485 port on the RPC-330 is set up for 4 wire
mode. 2- wire mode w ill cause the tra nsmitted da ta to
be received. T o use the RPC-330 is this mode, your
code should "flush" the received data or otherwise
remove transm itted information.

Mechanically, to make a 2- wire system, simply connect
T+ to R+ and T- to R -. M ake sure CON FIG BAUD is
set up for RS-485 mode.

Multidrop Network

You can use the RPC-330 in a m ultidrop network by
using CO M1' s RS-422/ 485 port. You can c onnect up to
32 units (including other RPC -330' s) over a 4,000 foot
range.

Figure 4-2 shows an exam ple of a multidrop network.
This networ k includes a host and one or m ore devices.
The host transmits data packets to all of the devices, or
nodes, in the network. A data packet includes an
address, com mand, data, and a checksum. See figure 4-
3. The packe t is received by all devices, and ignored by
all except the one addressed.

The relationship described below between nodes and the
host is a maste r-slave. The host dir ects all
c o mm u ni ca ti on . N o de s " d o n o t s pe a k u n le ss sp o ke n to " .
Peer to peer com munication, while possible with the
RPC-330, is not discussed here.

Ther e are m any com municatio n protoco ls. F or this
example, a protocol might look som ething like this:

> 22M B1

The pr otocol starts w ith the < cr> charac ter. This
character synchronizes all units and alerts them that the
next few characters coming down are address and data.
In this case, "> 22" is the units address. "M " is the
comm and and " B1" is the ch ecksum . T he comm and is
terminated with a < cr> character.

The response depends upon the nature of the command.
S u pp o se th e co m m an d M me a ns " r et ur n a d ig it al I/ O
port status". T he RPC-330 could rea d the port and
respond with AA2< cr> . The first A is an
acknowledge, that is no error s were detected in the
message. The data, A2, can be broken do wn as follows:

Bit/line

7 6 5 4 3 2 1 0

Status

1 0 1 0 0 0 1 0 = A2

Lines 1, 5 and 7 are high while the others are low.

The following program fragment uses ON C OM$ and
STR in a network environment. ON C OM$ generates an
interrupt when a < CR> is received. The interr upt
progr am uses a STR fun ction to deter mine if the da ta
packet was addressed to this card.

10 STRING 200,20
20 ON COM$ 1,0,13,1000
30 $(1) = ">05"

.
.
.

1000 $(0) = COM$(1)
1010 A = STR(8,$(0),$(1))
1020 IF A = 0 THEN RETURN

.
.

Line 20 sets up ON CO M$ to interrupt on a < CR> and
branch to line 1000. Line 30 sets up this card' s address.

Line 1010 checks to see if the rece ived mess age = this
card's address. If not, the subroutine ends. When there
is a match, further processing is performed.

ACCESSING SERIAL BUFFERS