PLC Master / Slave Example
PLC Master / Slave Example
PLC Master / Slave Example
Master / Slave
Example
! %
#&$
1A
+ ) #
+ $ &%
"'$ &#%
+ &# %! & &("$
+ &# & &
"
'!&"! &&!%
+ &#
$& &
"
'!&"!% $"$
+ &# &$& & &("$
+ & %"' " & %!& ("$! "$$&*
Appendix A
Master / Slave Example
A2
The Example
This chapter provides an example of a PLC master / slave network and is designed
for the experienced user. This chapter does not provide detailed descriptions of
network concepts and communications parameters. If youre unfamiliar with
networking concepts, or if you want to know more detailed information about
DirectNET, you may want to read Chapters 2 5 before setting up the example
network.
Example
Equipment
A PLC master with a DCM interface connected to one or more PLC or DCM slaves is
the most popular type of network. The PLC is the network master and uses the DCM
to initiate all communication requests. The DCM or PLC slave stations respond to
the master station requests for data.
This chapter provides an example that allows you to quickly and easily set up a small
master / slave network.
Master Station
Slave Station #1
Slave Station #2
Normally, you can install the modules in any manner. However, wed like to keep our
examples consistent between the different configurations. Install the equipment in
the following order.
WARNING: To minimize the risk of electrical shock, personal injury, or equipment
damage, always disconnect the system power before installing or removing any
system component.
1. Install the CPU in the far left side of the base in the position marked
CPU/Power Supply. When inserting components into the base, tilt the
component slightly forward sliding the tab on the bottom of the component
into the slot in the base. Push the top of the component into the base until it
is seated firmly, then tighten the securing screw at the top of the
module/unit.
Each unit has a plastic tab at the
bottom and a screw at the top.
With the unit tilted slightly
forward, hook the modules
plastic tab on the base.
Gently push the top of the unit
back until it is firmly installed in
the base.
Secure the unit to the base by
tightening the top screw.
You can connect the power wiring now (if its not already connected), but
dont connect the source power yet.
2. For the master station and slave stations #1 and #2, reserve slot 0 for the
DCM. (Slot 0 is the slot next to the CPU.) Set the DCMs aside for now. (You
need to set the dipswitches and station addresses first.)
3. Install the I/O Simulator in slot 1, next to the DCM slot.
Appendix A
Master / Slave Example
Install the
Equipment
A3
Request
Response
Appendix A
Master / Slave Example
A4
A5
The Example
Configuration
In this chapter well use the following example configuration to create a simple
master slave network.
WARNING: These examples are for illustration purposes only and are not intended
for use in actual applications. This is because there may be many aspects of your
system safety precautions that are not addressed in the examples. If you use these
examples in actual applications, you are increasing the risk of personal injury and/or
property damage.
Goal:
1. Write a bit pattern from an input module (X0 X7) to Slave #1
2. Read 1 V memory location from Slave #2.
Appendix A
Master / Slave Example
Appendix A
Master / Slave Example
A6
Slave#1 DCM
Slave#2 PLC
7
10
11
12
13
GND
+RTS
RTS
+CTS
CTS
7
10
11
12
13
GND
+RTS
RTS
+CTS
CTS
7
19
18
11
23
GND
+RTS
RTS
+CTS
CTS
14
15
16
17
+OUT
OUT
IN
+IN
17
16
15
14
+IN
IN
OUT
+OUT
9
10
16
14
+IN
IN
OUT
+OUT
22
23
24
25
+OUT
OUT
IN
+IN
25
24
23
22
+IN
IN
OUT
+OUT
Resistor
(optional for
this example)
A7
The next step is to set the master station DCM communication parameters. We will
use the following settings in our example.
S On-line / Off-line On-line position
S Address 0 (hexadecimal)
S Baud Rate 19.2K
S Parity None
S Response Delay Time 0
S Network Protocol DirectNET Master
S Mode HEX
OFF ON
Switch Positions
Time*
6
7
8
0 OFF OFF OFF
2 ON OFF OFF
5 OFF ON OFF
10 ON ON OFF
20 OFF OFF ON
50 ON OFF ON
100 OFF ON ON
500 ON ON ON
1
2
3
4
5
6
7
8
NO Parity
Set to OFF
Delay Time
Baud Rate
ODD Parity
Self Test
SW 4
1
2
3
4
SW 5
Network
Protocol
Switch Positions
Baud
1
2
3
300 ON OFF OFF
600 OFF ON OFF
1200 ON ON OFF
2400 OFF OFF ON
4800 ON OFF ON
9600 OFF ON ON
19200 ON ON ON
38400 OFF OFF OFF
Switch Positions
Protocol
1
DirectNET Slave
OFF
DirectNET Master
OFF
DirectNET Peer
ON
Modbus RTU Slave ON
2
OFF
ON
OFF
ON
Appendix A
Master / Slave Example
Appendix A
Master / Slave Example
A8
Slave station #1 is a DL405 PLC with a DCM as the network interface. Set the DCM
address to 1. Set the communication parameters to match the master station.
S Address 1 (hexadecimal)
S On-line / Off-line On-line position
S Baud Rate 19.2K
S Parity None
S Response Delay Time 0
S Network Protocol DirectNET Slave
S Mode HEX
Install the DCM and Install the DCMs in the slots next to the CPU for the master station and slave station
#2. Connect the communication cables to the appropriate units.
Connect the
Cables
NOTE: Remember that the pinout diagrams are different for the DCMs and the
bottom CPU port. Make sure the cables are connected to the proper device.
Set the PLC
Switches for
the Slave #2
DL405 PLC
Rear View
DirectSOFT
DL405
Handheld
Programmer
Select AUX 56
CLR
CLR
AUX
ENT
ENT
ENT
CLR
OK
Appendix A
Master / Slave Example
A9
Appendix A
Master / Slave Example
A10
In the example network, well use 8 switches on the input simulator in the master
system to set a bit pattern that will be written to an output module on the slave
station #1. Also, well read the current value of a timer from slave station #2. Our
example requires a program in both the master and slave stations.
Goal:
1. Write a bit pattern from an input module (X0 X7) to Slave #1
2. Read one V-memory location (V0000 two bytes) from Slave #2, store in
V2000.
MSB
V2000
LSB
15
MSB
V0
15
LSB
0
Connect the
The example provides the instructions needed for the DirectSOFT programming
Programing Device package and for the DL405 Handheld Programmer. In either case, you should
connect the programming device to the top port on the DL405 CPU. We assume you
understand how to use the DirectSOFT Programming Package and/or the
Handheld Programmer. If you arent familiar with these, you should probably review
those product manuals prior to trying to enter these programs.
The program examples on the following pages show both RLL and RLL PLUS
examples. The RLL PLUS approach eliminates the need for the interlocking relays
and is generally a much more straightforward programming method.
The following diagram shows the RLL instructions used in the communications
program. Chapter 5 provides detailed descriptions of the instructions. You should
always use the interlocking relays to ensure that the DCM has adequate time to
finish a communication task.
SP120 C0
LD
K0001
K0001
LD
LDA
O40400
WX
Y0
Set
C0
SP120 C0
LD
K0002
LD
K0002
LDA
O2000
RX
V0
RST
C0
END
Appendix A
Master / Slave Example
RLL Instructions
A11
Appendix A
Master / Slave Example
A12
Master Program
RLL Example
DirectSOFT
SP120 C0
DL405 HP Mnemonics
LD
K0001
LD
K0001
LDA
O40400
WX
Y0
Set
C0
SP120 C0
LD
K0002
LD
K0002
LDA
O2000
RX
V0
RST
C0
END
$0
STRN SP120
$1
ANDN C0
$2
LD K0001
$3
LD K0001
$4
LDA O40400
$5
WX Y0
$6
SET C0
$8
STRN SP120
$9
AND C0
$10
LD K0002
$11
LD K0002
$12
LDA O2000
$13
RX V0
$15
RST C0
$16
END
DirectSOFT
DL405 HP Mnemonics
ISG 0
SP120
LD
K0001
LD
K0001
LDA
O40400
WX
Y0
JMP
S1
SG 1
SP120
LD
K0002
LD
K0002
LDA
O2000
RX
V0
JMP
S0
END
$0
ISG S0
$1
STRN SP120
$2
LD K0001
$3
LD K0001
$4
LDA O40400
$5
WX Y0
$6
JMP S1
$8
SG S001
$9
STRN SP120
$10
LD K0002
$11
LD K0002
$12
LDA O2000
$13
RX V0
$15
JMP S0
$16
END
Appendix A
Master / Slave Example
Master Program
RLL PLUS Example
A13
Appendix A
Master / Slave Example
A14
Slave Station #2
Program
RLL Example
Our example requires a program in slave station #2. The slave station program is
much easier because the master station program controls the communication. In the
slave station, were just using a self-resetting timer to provide a data value.
DirectSOFT
T0
DL405 HP Mnemonics
TMR
T0
K9999
END
Slave Station #2
Program
RLL PLUS Example
DirectSOFT
DL405 HP Mnemonics
ISG 0
T0
$0
STRN T0
$1
TMR 0
$2
K9999
$3
END
TMR
T0
K9999
END
$0
ISG S0
$1
STRN T0
$2
TMR 0
$3
K9999
$4
END
CPU/POWER 110/220VAC
RUN
PWR
BATT
TERM
RUN
I/O
STOP
CPU
COM
Appendix A
Master / Slave Example
A15
Appendix A
Master / Slave Example
A16
Check the DCM indicators to verify that the network is operating correctly. shows the
proper indicator conditions. The ENQ, HDR, and DATA indicators should be
flashing.
Self Test Indicator: ON
Module Power: ON
Master Mode:
ON if master
OFF if slave
Send/Receive Enquiry:
FLASHING
Send/Receive Header:
FLASHING
Send/Receive Data
Packet: FLASHING
DirectSOFT
DL405
Handheld
Programmer
Monitor a V Location
CLR
CLR
WD ST ENT
ENT
Appendix A
Master / Slave Example
A17
Appendix A
Master / Slave Example
A18
If the network does not seem to be working correctly, check the following items.
1. Cable and connections. Incorrectly wired cables and loose connectors
cause the majority of problems. Verify that youve selected the proper cable
configuration and check that the cable is wired correctly.
2. Dipswitch settings. Make sure youve set the switches to allow the same
communication settings for both stations.
3. Communications program. Verify that the program has been entered as
shown in the example.
4. If the network still doesnt work correctly go to Chapter 7, Network
Operation and Troubleshooting, and use the troubleshooting charts.