White Paper of Master, Slave Commuincation
White Paper of Master, Slave Commuincation
Communication
between two Red Lion
Modular Controllers
White Paper
(For Internal Use Only)
Contents:
Task
Hardware
Software
Objectives
Strategy
Hardware Configuration
Flowchart Of Master Program
Flowchart Of Slave Program
Software Configuration
o Master Side Program Configuration
o Salve Side Program Configuration
Problem faced and solution
Checking Configuration
References:
Task:
To establish communication between two Red-lion modular controllers
CSMSTRSX on master, slave basis using MODBUS TCP\IP protocol.
Software:
Crimson 3.0
Hardware:
Two Red-Lion modular controller CSMSTRSX
Two Digital Input/output cards CSDIO14
Communication Objectives:
We have chosen the communication task to fulfill the following
requirements:
Strategy:
o The inputs on master sides are map to soft tags which are sent to slave
side using Modbus TCP/IP protocol using holding registers.
o Similarly inputs of slave side are map to soft tags which are send to
master side using holding registers of Modbus.
o A program is written on master side which monitors if the
communication is established with slave or not.
o If communication is Ok the inputs of slave are receiving at outputs of
master side and vice versa ,If communication is not ok then the
outputs on master sides turn off after 15 seconds
o A function “IsDeviceOnline()”is used to check the status of
Communication.
o A clock signal is send to slave side from master device.
o Similarly a program is written in slave side which checks whether the
clock is receiving or not from master device.
o If Clock is receiving a function “GetUpDownData” is called which
oscillates a value between 1 and 0
o If Communication breaks and clock signal stops, timer start and turn
off the outputs on slave side after timer reaches the set point defined.
o If Communication is ok the inputs of master side are receiving at
outputs of slave side and vice versa.
Hardware Configuration:
4. Select CSDIO14 module and click ok .Now click on Data Tags and add new
flag tags
5. Similarly add tags depending on your number of input /outputs and name them
6. Add some numeric tags that will use in the program written for master device
7. The next step is to map the flag tags with modular controller input and outputs.
For this purpose click on the tag which is to be mapped with controller I/O.A
window will open, Go to Data tab and select module from source options.
Following window will open.
8. Now select particular input for your tag and press ok .The color of the tag will
change based upon your selection .For input the color is green and if you map
output for tag the color will be red and if the tag is internal the tag color will be
blue
9. Go to communication and click on network following window will open up now
click on Ethernet 1.
12. On pressing ok a new icon created under declared protocol open it and
configures it using following settings. The IP given here will be the IP address of
the slave device
13. Now right click on the device created in protocol 1 and select add block
14. Add three blocks in the same way .One block is used for sending input data,
one is for receiving data for outputs and one is used for sending communication
indication to slave.
15. Now click on block1 and select starting address by pressing pick button .A
window will open, select holding register and give address to holding register as
shown in figure:
16. Now configure the setting according to following figure. In block settings we
configure block size to 1 as we are using only one register in one block .And we
choose direction “G3 to Device ” as we are sending data to slave using this block.
The update policy is set to continuous as we want our data to be continuously
updated on slave side.
17. Now right click on holding register 400001 and click on expand bits .The
register expands, now click on data tags from resource panel and drags tags to the
bits in the register whose data is to send to slave device as shown below:
18. Now go to block 2 which is used to receive data coming from slave device .The
starting address is 400002 and we change the direction to “Device to G3”
19. Now map the tags which receive the data coming from slave device in same
way as we have done for block 1 .
20. Repeat the same process for the block 3 and map “clk” tag which is send to
slave so we choose the direction “G3 to Device”
21. Now go to Programs from navigation panel and write following program and
press “Ctrl + T” to check for possible errors in program. “GetSec(GetNow())”
This statement gets the number of seconds ,we are sending this value to slave side
using “clk” tag .“IsDeviceonline()” is used to check whether the communication is
established or not with the slave .If Communication is established the received
output data “SI1”is passed to physical output card tag “MO1”
22. Now click on “display pages” from navigation panel and click on “pages”. A
side window will open, now click on “programs” from resource panel and drag the
“program1” we make earlier to the “on tick” which is present in global actions tab
23. Save the program and select port for downloading by first going to link and
open options and selecting USB from communication port panel.
24. Now attach the controller using usb cable to computer and press update icon as
shown in the figure
3. Select CSMSTRSX from the modular controller. Now click on modules and
add new module from the menu, following window will open :
4. Select CSDIO14 module and click ok .Now click on Data Tags and add new
flag tags and numeric tags. And map the flag tags to modular controller
input/output.
7. Now click on network and select Modbus protocol and configure the device as
Modbus TCP\IP slave and set following configuration
8. Now add 3 blocks in the same manner as we have done on master side
9. The blocks which are configured for sending data in master are declared here for
receiving data and vice versa. Add holding registers to the blocks, Map tags to
holding register addresses in the same way as done on master side. Red blocks
have a direction “Device to G3” which means they are receiving data from master
and green blocks indicates they are sending data to master.
10. Now go to programs, type the following program and press “Ctrl+T” to
compile it. “GetUpDownData()” statement is used to oscillate a value between 1
and 0 till the clk value is changing .clk signal is coming from master side and is
used to check the communication status between master and slave
11. Now go to Display pages in navigation panel click on “pages” and add
program1 () to “On Tick ” and “On Startup”
12. Now save all configurations and Upload the program as we have done on
master side.
Problem Faced:
When power is reset on slave side the outputs on the slave device holds and until
the master device power resets or inputs on the master side are change.
Solution:
The blocks which are sending data from master to slave device are configured with
following settings .Update policy is set to continuous which was previously set to
automatic. The Update Policy property is used to define how the block updates. A
setting of Continuous will cause all blocks to update continuously.
Checking Configuration:
Now to check whether our configuration is working fine or not, download both the
modular controller with their respective programs and connect modular controller
using crossover cable. Then activated Input 1 at Master side to see if Output 1 at
Slave device actuate accordingly. Same drill is to be done with Slave device to
check output statuses on Master Side. If all the Inputs on one node replicate
properly on respective outputs of the other node, then your configuration is
working fine. Break Communication between devices by removing Ethernet cable.
The outputs on both sides turn off after some time. Now plug in the cable, the
outputs reappears on both sides. Now remove power from slave side and checks
whether outputs drops on both sides .If outputs drops, Power on slave device and
checks whether the inputs on master receive at slave side properly. Now repeat this
step on master device. If outputs receive at master side your configuration is ok
If your code doesn’t work well, go through all the parameters thoroughly to see if
anything is missing and check the crossover cable for proper operation.
References:
http://www.redlion.net/sites/default/files/media/crimson_3_man
ual_english_revision_2.6_5612kb.pdf