Remote-processing RPC-52 Manuel d'utilisateur Page 13

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 36
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 12
CHAPTER 4 SERIAL PORTS
Page 11
Figure 4-3 Data packet
> 22MB1
The protocol starts w ith the < cr> character. 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 checksum . T he comm and is
terminated with a < cr> character.
A response depends upon the nature of the command.
Suppose command M means "return a digital I/O port
status". The RPC-52 could read the port and respond
with AA2< cr> . The first A is an acknow ledge, that is
no errors were detected in the message. The data, A2,
can be broken down 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.
ACCESSING SERIAL BUFFERS
You can access C OM0 and COM 1 buffers in three w ays:
1. INPUT statement. This removes all characters in
the buffer up to the term inator cha racter and puts
them into a variable.
When using the INPUT statement, program
execution is suspended until a < cr> (Enter key) is
received. W hether this is a problem depends on
your particular application.
INPUT strips bit 7. This means ASCII characters
from 0 to 127 are received. The IN PUT statement
can return a maximum string length of about 150
characters.
2. GET function. Characters ar e rem oved one at a
time as a numerical value. A 0 is returned when the
buffer is empty. Use the C OM function to
determ ine if the buffer is empty or if a 0 is a data
value.
If you don' t read the buffer an d the buffer fills, all
subsequent characters are discarded. GET m ay be
used anywhere in the program.
3. COM$(n) retrieves all characters in the buffer,
including other control codes (except CR).
ACCESSING COM0 AND COM1
The port INPUT and GE T functions retrieve data using
the UIn comm and. UI0 routes inputs to C OM0 while
UI1 routes inputs to the COM1 port. PRINT outputs are
set by the UOn com mand. UO0 p rints out COM0 while
UO1 outputs COM 1.
The following show how UIn and UOn work.
100 UI0 Set to COM0
110 INPUT A Get data from COM0 port
520 UI1 Switch to COM1 port
530 INPUT B Get data from COM1 port
800 UO0 Print to COM0
810 PRINT "Temperature:",T
900 UO1 Print to COM1
910 PRINT "Set pressure at:",CA
Power up default is set to COM0. UIn has no effect
upon COM $(n) function.
Vue de la page 12
1 2 ... 8 9 10 11 12 13 14 15 16 17 18 ... 35 36

Commentaires sur ces manuels

Pas de commentaire