beautypg.com

Rpbasic-52 programming guide – Remote Processing BASIC 52 User Manual

Page 13

background image

RPBASIC-52 PROGRAMMING GUIDE

1-10

processed unless the ho st "knows" this node has just
reset. Any valid command , unless it is "E", returns a
"N2" neg ative acknowledgem ent. The host
recognizes this as a power up condition. Line 1220
checks for a valid power up flag.

Command F could return any number of status
conditions . The way it is imp lemented h ere, data is
returned to indicate the type of error. A 0 return
indicates things are just fine. The type and value of
data returned will depend upon the number of error
conditions. If error conditions were binary weighted
(1, 2, 4, 8...) then the receiver could determine
exactly what errors are in the system.

A unique a ddress in the message p acket, >99 , tells all
units using this pro gram to go to a 'safety' mode. It is
used for emergency shut down situations. Nodes do
not reply to this c omman d. The p rogram e xample
does a simple return as your application determines
approp riate respon se. The ad vantage to u sing this
command is in emergency situations all units get the
message in u nder 50 ms. It could tak e consider ably
longer, per haps 1 sec ond in a 20 node system , to poll
all units.

A networking factor is communication time. Longer
messages tak e longer to p rocess. At 9 600 ba ud, it
takes abou t 12 ms to sen d out a 10 character m essage.
This assumes the host can assemble a message string
instantaneously. Add 5 ms processing time by the
remote card (and 5 ms could be considered a
minimum) before anything is sent out. It could be
nearly 50 ms for a complete exchange. Using a
simple command structure, about 20 message
exchange s per secon d are po ssible.

Increasing the baud rate decreases message exchange
time, but there is a point of diminishing return. Going
to 19,20 0 baud c uts serial com munication time in
half. However, message processing time stays the
same. At some point in time the processing power of
the host and remote units is a major factor. RPC
cards pro cess comm ands roug hly at a rate of 1/m s.
To verify an address an d begin ca rrying out a
comma nd takes ab out 30 ms . Any additio nal data
processing increases this time.

The nex t application in Appen dix B uses a modem in
a receive ap plication. T his illustration uses a g eneric
1200 baud modem, although a higher speed modem
can be use d provid ed incom ing data do es not com e in
so fast the buffer fills an d characte rs are lost.

COM1 is set as the receive port. The modem
connects to the RPC card serial port using a VTC-9F
serial cable. Most external modems have a DB-25F
(female) connector for the serial port, therefore a DB-
9F to DB -25M adapter is ne cessary. Also , since both
the RPC card and modem are designed to plug into a
PC, a null modem adapter must be inserted between
the DB-9 connector on the VTC -9F and adapter. The
connectors are shown below:

modem > DB9F to DB-25M > null modem > VTC-9F

This can be somew hat of a kludge. A nother way is
to make a custom ca ble from the R PC card 1 0 pin
IDC con nector to a DB -25M. If you ch oose this
route, connect the pins in the following manner:

I D C

DB-25

Function on

male

RPC c ard

3

2

Tx output

4

5

RTS input

5

3

RXD input

6

4

CTS output

9

7

Ground

Your modem may have configuration switches. Set
these switches to the following conditions to use the
s a m pl e p ro g ra m :

Force DTR lead (pin 20) true to enable modem
to execute comm ands.

Modem responds to comm ands with english
word result codes.

Result codes sent to the RPC card.

Echo characters while in the command state.

Modem autom atically answers an incoming
call.

Force CD lead (pin 8) true.

Enable modem com mand recognition.

You may have to set these conditions in software.

There is a ce rtain sequence , or protocol, that is
followed when answering a phone. The steps
(CYCL E) follows:

CYCLE

Action