A–1 Appendix A RLL Communications Programs

A–1 Appendix A RLL Communications Programs
A–1
Appendix A
RLL Communications
Programs
A–1
A–2
Why do you need a communications program?
Since DirectNET is a master / slave network, the master station must initiate
requests for network data transfers. If you’re using a PLC as the master station, you
use simple RLL instructions to initiate the requests.
The Master
Initiates Requests
Why Ladder Logic? Since the DCM network interface does not contain a program, you have to use the
PLC to issue the commands to tell the DCM where to read or write data. The DCM
gets information from the PLC and then converts the information into the appropriate
DirectNET commands. The RLL instructions identify the following items.
1. Slot location of the DCM master and the slave station address. (LD
instruction)
2. Amount of data (in bytes) you want to transfer. (LD instruction)
3. Area of memory to be used by the master. (LDA instruction)
4. Area of memory to be used by the slave, and whether it is a read or write
operation. (RX or WX instruction)
5. Interlocks for communication timing and multiple RX and WX routines.
This example reads 3 bytes of data from Slave Address #1,(starting at Y0), into the
Master PLC starting at V40600 (Control Relays).
Example RLL Program
Master PLC
Communication Error
SP125
Set
Y50
Communication Not Busy
SP124
LD
K0201
DCM Slot
Slave Address
LD
K0003
Transfer 3 bytes
Slave Address 1
LDA
O40600
Master Starting Address
Type of Operation
RX
Y0
Slave Starting Address
Slave Address 2
A–3
A–3
This example writes 3 bytes of data from the Master Station (starting at V40600) to
Y0 – Y27 in Slave Station #1.
Master PLC
Example RLL Program
Communication Error
Y50
SP131
SET
Slave Address 1
Communication Not Busy
SP130
LD
K0401
DCM Slot
Slave
Address
LD
K0003
Slave Address 2
Transfer 3 bytes
LDA
O40600
Master Starting Address
Type of
Operation
WX
Y0
Slave Starting Address
The following paragraphs explain each operation and provide some helpful hints to
make your programs simple and easy to follow.
A–4
Identifying the master and slave
Location of Master
and Slave
The first Load (LD) instruction identifies
the slot location of the DCM master and
Valid Slot Range: 0–7
the address of the slave station.
Valid Slave Address: 1–90
(Remember, the slot numbers start at 0.)
The constant (K) portion of the instruction
actually contains two pieces (bytes) of
information. The first two digits specify
Example:
the DCM master location and the second
Master Slot: 2 HEX, 2 decimal
two digits specify the slave station
Slave Address: 1 HEX, 1 decimal
address.
It is necessary to specify both the master
slot location and slave address because HEX Format
you can have more than one DCM master
in the base and you can have up to 90
HEX 3C
slave stations for each master.
NOTE: The LD instruction K value is
entered in decimal, but the DCM master 3 C and slave addresses are in HEX. You
have to convert the HEX addresses to
their decimal equivalent for this
instruction. It’s easy to convert from HEX
to decimal.
A
A–5
A–5
Specifying the amount of data
Number of Bytes to The second LD instruction indicates the
amount of data (in bytes) that needs to be
Transfer
transferred. You have to specify the
amount of data in complete bytes. For
example, Y0 – Y27 would be three bytes
of data.
The different PLC families do not always
use the same types of memory or the
same byte boundaries. For example, the
DL305 does not use a separate data type
for input and output points.
Example:
3 bytes of data to be transferred
The number of bytes specified also depends on the type of data you want to obtain.
For example, the DL405 Input points can be accessed by V-memory locations or as
X input locations. However, if you only want X0 – X27, you’ll have to use the X input
data type because the V-memory locations can only be accessed in 2-byte
increments. The following table shows the byte ranges for the various types of
DirectLOGIC products.
DL 205 / 405 Memory
Bits per
unit
Bytes
V memory
T / C current value
16
16
2
2
Inputs (X, GX, SP)
8
1
Outputs
(Y, C, Stage, T/C bits)
8
1
Scratch Pad Memory
8
1
Diagnostic Status
8
1
Bits per
unit
Number of
bytes
Data registers
T / C accumulator
8
16
1
2
I/O, internal relays,
shift register bits, T/C
bits, stage bits
1
1
Scratch Pad Memory
8
2
Diagnostic Status
(5 word R/W)
16
10
DL305 Memory
A–6
Designating the master station memory area
Memory Area of
Master
The Load Address (LDA) instruction
specifies the V memory area of the
master that will be used. This is the
starting address. Additional sequential
locations may be used, depending on the
number of bytes that are being
transferred. Since all DL405 data is
mapped into V memory, you can easily
access the data you need.
If you are reading information from the
slave station, this is the destination area,
or, the area where the master will store
the information.
If you are writing information to the slave
station, this is the source area, or, the
area where the master will obtain the
information that will be transferred to the
slave.
NOTE: Since V memory words are
always 16 bits, you may not always use
the whole word. For example, if you only
specify 3 bytes and you are reading Y
outputs from the slave, you will only get
24 bits of data. In this case, only the 8
least significant bits of the last word
location will be modified. The remaining 8
bits are not affected.
Example:
V memory location 40600 will be the
starting point of the data transfer area
for the master. The following locations
will be used to store the data.
MSB
V40600
LSB
15
MSB
15
0
V40601
LSB
0
A–7
A–7
Identifying the slave station memory area
Memory Area of
Slave to Read or
Write
The Read Network (RX) or Write Network
(WX) is the last instruction in the routine.
Use the RX if you want to read data from
the slave, or use the WX instruction if you
want to write data to the slave.
You have to specify the data type and the
starting address (in octal) for the slave.
(Remember, you have to specify a data
type that will work correctly with the
number of bytes specified.)
If you use the RX instruction, the data will
be read from the slave starting at the
address specified. If you use the WX
instruction, the data will be written to the
slave starting at the address specified.
Example:
Read from slave starting at Y0.
NOTE: If you are using an RLL communications program to transfer data to or from a
DL305 slave station, the data type is slightly different. For example, the DL305 I/O
points are accessed with the GY data type. The DirectNET manual provides a listing
of memory types and cross references for the DL305 family.
Master PLC
Slave Address 1
Slave Address 2
A–8
Controlling the communications
Communications
Special Relays
When you execute communication with a
DCM,
chances
are
good
the
communication may take longer than the
actual PLC scan. If the DCM is busy, you
should not initiate another request until it
is finished. Fortunately, there’s an easy
solution for this.
There are two SPs for each slot in the
CPU base which are used only with the
DCM. For example, slot 0 has SP120 and
SP121. SP120 is the DCM Busy relay
and, when turned on, indicates the DCM
is busy. SP121 indicates there is a
communication error for slot 0.
You should always use the DCM Busy SP
in your RLL programs to ensure the DCM
is ready.
The communication error SP is optional,
but it’s a good way to monitor the
communication status in the RLL
program. If you use the communication
error SP, make sure you place it at the
beginning of your communication
routines.
This
is
because
the
communication error relay is always
reset (turned off) whenever an RX or WX
instruction is executed.
SP125
Y50
SET
SP124
LD
K0201
LD
K0003
LDA
O40600
RX
Y0
Special Purpose Communication Relays
A–9
A–9
Multiple Read and
Write Interlocks
If you’re using multiple reads and writes in
the RLL program, you have to interlock
the routines to make sure all the routines
are executed. If you don’t use the
interlocks, then the CPU will only execute
the first routine. This is because the DCM
can only handle one routine at a time.
In the example, once the RX instruction is
executed, C0 is set. When the DCM has
finished the communication task, the
second routine is executed and C0 is
reset.
If you’re using RLL PLUS, you can just put
each routine in a separate program stage
to ensure proper execution. In most all
cases, RLL PLUS is a much more efficient
way to create automation program.
The DirectNET manual provides a
master / slave example with both RLL and
RLL PLUS program descriptions.
SP124 C0
LD
K0201
LD
K0003
LDA
O40600
RX
Y0
C0
SET
SP124 C0
LD
K0201
LD
K0003
LDA
O40400
WX
Y0
C0
RST
A–10
DL305 / 405 Cross Reference
If you are using a DL405 Master, you will have to make some slight changes in the
way you request certain types of data. For example, the DL405 uses V-memory
references instead of Register references. This section shows the cross references.
NOTE: Not all DL305 devices offer the same memory ranges. Check your DL305
User Manual to determine the ranges for your particular model.
Data Type 31:
Register Access
To get to ...
TMR / CTR
Accumulator
in a DL305
Use
Reference
...
in a DL405
To get to ...
Register Data
in a DL305
Use
Reference
...
in a DL405
R600
V000
R401, 400*
V100
R601
V001
R403, 402
V101
———
———
———
———
R624
V024
R777, 776
V237
R677
V077
Two bytes of DL305 register data are returned with one DL405 V memory
location.
Data Type 33:
I/O Point Access
Non RLL PLUS CPUs
To get to ...
I/O Points, CRs, &
Shift Registers
in a DL305
Use
Reference
...
in a DL405
To get to ...
TMR / CNT Status Bit
in a DL305
Use
Reference
...
in a DL405
IO 000
GY000
600
GY600
IO 001
GY001
601
GY601
———
———
———
———
IO 157
GY157
677
GY677
CR160
GY160
———
———
CR 377
GY377
IO 700
GY700
IO 701
GY701
———
———
IO 1067
GY1067
SR 400
GY400
SR 401
GY401
———
———
SR 577
GY577
A–11
A–11
RLL PLUS CPUs
To get to ...
I/O Points, CRs, &
Shift Registers
in a DL305
Use
Ref.
...
in a
DL405
To get to ...
Stage Status Bit
in a DL305
Use
Ref.
...
in a
DL405
To get to ...
TMR / CNT Status
Bit
in a DL305
Use Ref.
...
in a
DL405
IO 000
GY000
000
GY200
600
GY600
IO 001
GY001
001
GY201
601
GY601
———
———
———
———
———
———
CR160
GY160
177
GY377
677
GY677
———
———
CR 277
GY277
IO 700
GY700
IO 701
GY701
IO 1067
GY1067
SR 200
GY400
SR 201
GY 401
———
———
SR 277
GY477
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertisement