0% found this document useful (0 votes)
149 views

Communication To Simatic S7 Using Open Modbus

simatic s7

Uploaded by

SihamaSiham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
149 views

Communication To Simatic S7 Using Open Modbus

simatic s7

Uploaded by

SihamaSiham
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

Application Note:

Communication between CTI 2500 Series PLC and SIMATIC


S7 PLC using the Open MODBUS /TCP protocol

Application

ACTI2500SeriesorSimatic505PLCisusedtoexchangedatawithaSiemensS7PLC.
ModbusRegisterscanbewrittentoorreadfromtheCTICPU.TheS7PLCisfunctioningasa
ClientandtheCTIPLCasaServer.

Assumptions

TheCTIPLCusesthe2572A100MbitEthernetAdaptercardasanetworkinterface.
NotetheCTI257210MbitEthernetAdaptercannotbeusedsinceitdoesntsupportthe
OpenModbusTCPprotocol.
TheS7PLCusesaCP3431/4431cardwithaconfiguredactiveconnectiontotheCTI
PLCtheSiemensCPcardswhicharereleasedforthisapplicationare6GK74(3)43
1EX110XE0orlaterversions.
TheS7PLCisfunctioningasClientandtheCTIPLCasServernoprogrammisneededin
theCTIPLC
TheIPaddressfortheCP4431is192.168.0.88
TheIPaddressforthe2572Aia192.168.0.87
InthisexampletheS7PLCwillsend100wordstothemodbusregister4000140100
whichcorrepsondstoaddressV1V100intheCTIPLC.
FB100MODBUSisusedthisFunctionBlockisnotpartofthestandardStep7package
buthastobeorderedseparatelytheMODBUSlibrarycanbeorderedwiththe
Siemenspartnumber2XV94501MB00andcanbeusedinStep7V5.1orhigher

Description
AlltheconfigurationisdoneattheS7sideonlytheIPaddressinthe2572Ashouldbe
adjusted.TheS7ModbuslibrarycomeswithtwoFunctionBlocksFB100ModbusandFB101
Modb4.
FB100isappliedtoConformanceClass0withthefunctionsreadandwriteholdingregisterFC3
and16.FB101,whichisapartofConformanceClass1,suppliestheadditionalfunctionread
inputregisterFC4.InthisexampleonlyFB100isusedtosend100wordsfromtheS7totheCTI
PLC.FordatatransferbetweentheCP4431andtheS7400CPUthefunctionsFC50(AG_LSEND)
andFC60(AG_LRECV)areused.TheFB100ModbushastobecalledbothinthestartupOB100
aswellasinthecyclicOB1.ItisnotallowedtocallFB100inacyclicinterruptOB.

S7Configuration
UsingStep7,thehardwareneedstobeconfiguredincludinganEthernetnetwork.FortheCTI
PLCtheobjectOtherStationisaddedinNetProandbothareconnectedtothenetworkas
shownbelow.OntheCPU4174anactiveconnectionwiththeCTIPLCisconfiguredwhichis
usedbytheFB100Modbusfunction.

ConfiguringtheCP4431EthernetModule
TheCP4431usestheIPaddress192.168.0.88andisconnectedtotheEthernetnetworkas
shownbelow.

ConfiguringtheTCPconnectionfortheOpenModbusTCPprotocol
UnderGeneralInformationtheIDnumber1andtheCPLADDRW#16#3FFDcanberead
out.Theactiveconnectionestablishmentfeatureneedstobeselected.
FortheModbusTCPServerasastandardTCPport502isusedandfortheClientadifferentTCP
portnumberinthisexample2001.

DataandStandardFunctionsusedbytheFB100Modbus
ThefunctionblockModbusreads/storesitsdatafrom/inaninstanceDB.TheinstanceDB
containsparametersofthetypeInput,Outputaswellasstaticvariablesthatitneedsforits
execution.

Parameters of the Function Block MODBUS


Parameter

Decl.

Type

Description

Value range

ID

IN

WORD

Connection-ID
as per
configuration in
NetPro
1 to 64

W#16#1 to
W#16#40

LADDR

IN

WORD

LADDRAddress of the
CP from HW
Config

CPU
dependent

TIMER_NR

IN

TIMER

Timer number
for response
monitoring time

CPU
dependent

MONITOR

IN

WORD

Monitoring
Time: Wait for

W#16#1 to
W#16#3E7


data from
communication
partner; 100
ms units
1 to 999
DB_1

IN

WORD

Data block
number, first
range
1 to 65535

W#16#1 to
W#16#FFFF

START_1

IN

WORD

First MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

END_1

IN

WORD

Last MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

DB_2

IN

WORD
Data block
number,
second range;

NULL if not
used
1 to 65535

W#16#1 to
W#16#FFFF

START_2

IN

WORD

First MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

END_2

IN

WORD

Last MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

DB_3

IN

WORD
Data block
number, third
range;

NULL if not
used
1 to 65535

W#16#1 to
W#16#FFFF

START_3

IN

WORD

First MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

END_3

IN

WORD

Last MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

DB_4

IN

WORD

Data block
number, fourth
range; NULL if
not used
1 to 65535

W#16#1 to


W#16#FFFF

START_4

IN

WORD

First MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

END_4

IN

WORD

Last MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

DB_5

IN

WORD

Data block
number, fifth
range; NULL if
not used
1 to 65535

W#16#1 to
W#16#FFFF

START_5

IN

WORD

First MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

END_5

IN

WORD

Last MODBUS
register
address
0 to 65535

W#16#0000 to
W#16#FFFF

WRITE_ PROTECT1

IN

BOOL

Area 1 is write
protected (only
in SERVER
mode)

TRUE FALSE

WRITE_ PROTECT2

IN

BOOL

Area 2 is write
protected (only
in SERVER
mode)

TRUE FALSE

WRITE_ PROTECT3

IN

BOOL

Area 3 is write
protected (only
in SERVER
mode)

TRUE FALSE

WRITE_ PROTECT4

IN

BOOL

Area 4 is write
protected (only
in SERVER
mode)

TRUE FALSE

WRITE_ PROTECT5

IN

BOOL

Area 5 is write
protected (only
in SERVER
mode)

TRUE FALSE

ENQ_ENR

IN

BOOL
CP is Client:
Initiate request
at TRUE signal

CP is Server:
Ready to
receive at
TRUE signal

TRUE FALSE

SERVER_ CLIENT

IN

BOOL

CP/FB

TRUE FALSE


operates in
server mode or
client mode
DONE_NDR

OUT

BOOL
CP is Client:
Active request
finished
without errors

CP is Server:
Request from
the client was
executed and
answered

TRUE FALSE

ERROR

OUT

BOOL

An error has
occurred.

TRUE FALSE

STATUS

OUT

WORD

Error number

0 to FFFF

START_ ADDRESS

IN/ OUT

WORD

MODBUS start
address
(INPUT if in
CLIENT mode,
OUTPUT if in
SERVER
mode)
0 to 65535

W#16#0000 to
W#16#FFFF

LENGTH

IN/ OUT

BYTE
Number of
registers to be
processed
(INPUT if in
CLIENT mode,
OUTPUT if in
SERVER
mode)
Read function

Write function
1 to 125
B#16#1 to
B#16#7D
1 to 100

B#16#1 to
B#16#64

WRITE_ READ

IN/ OUT

BOOL

Read or write
access (INPUT
if in CLIENT
mode,
OUTPUT if in
SERVER
mode)

TRUE FALSE

TI

IN/ OUT

WORD

Transaction
Identifier
(INPUT if in
CLIENT mode,
OUTPUT if in
SERVER
mode)
0 to 65535

W#16#0 to
W#16#FFFF

UNIT

IN/ OUT

BYTE

Unit
identification
(INPUT if in
CLIENT mode,
OUTPUT if in
SERVER
mode)
0 to 255

B#16#0 to
B#16#FF

ProgrammingexamplewhentheCP4431isClient
100wordsofdataarewrittenfromDB11intheS7PLCintoV1V100intheCTIPLC.Theused
blocksintheS7programmareOB1(cyclicOBwhichexecuteseachcycle),OB100(startupOBfor
restart),DB222(datablockforControlData)andDB700(instancedatablockforModbusData).

InOB100,whichisthestartupOB,theconnectiontoDB_1is11(thismeansDB11isconnected)
andthestart_1andend_1areconfiguredas0and100resp.Herealsotheparameter
Server_ClientissettofalsewhichmeansthattheCP4431actsasClient.

InOB1,whichisthecyclicOB,thecommunicationistriggeredbytheparameterENQ_ENR.
WhenwritingdatatotheCTIPLCtheparameterWRITE_READshouldbetrue.Theamountof
datawordssenttotheCTICPUisconfiguredwiththeLENGTHparameter.Theregisterinwhich
thedataiswrittenisconfiguredintheSTART_ADDRESS(0meansModbusRegister40001this
isV1intheCTICPU).
IfalsodatashouldbereadfromtheCTIPLC,asecondMODBUSFBcallisneededwherethe
parameterWRITE_READissettofalse.IntheconnectedinstanceDBtheparametersshouldbe
filledincorrectly.

OnlineviewintheS7blocksOB1andDB222


OnlineModbuscallinOB1:thestart_addressis0whichmeansReg40001(V1intheCTIPLC),
thelengthis100(V1V100)andthewrite_readis1(whichmeansawrite).Sointhiscasethe
first100wordsfromDB11aresenttoV1V100intheCTI.


DB222istheControlDataBlockandthecompleteonlinecontentsisshownbelow

AdditionalinformationcanbefoundinthemanualwhichcomeswiththeModbussoftwareor
canbedownloadedfromtheinternetfromtheSiemenssite
https://support.automation.siemens.com

Control Technology Inc.


5734 Middlebrook Pike, Knoxville, TN 37921-5962
Phone: 865/584-0440 Fax: 865/584-5720 www.controltechnology.com
Copyright 2010 Control Technology Inc.

All rights reserved.

19JAN2010

You might also like