Sunteți pe pagina 1din 4

4/13/2016

Volume3describestheuseofDBPointersandANYPointers_

3
Volume3describestheuseofDBPointersandANYPointers

DOC

PPT

TXT

PDF

XLS

VIP

Volume3describestheuseofDBPointersandANYPoint
ers
wapush789 2013-03-30

1942

TheBookofthe

SimaticTip

TipNo.VC

TheBookofthe

TheBookofthe

SIMATICTIPS

TotallyIntegratedAutomation

TheBookofthe

ApplicationNotes

VolumeTwo

Group
Automation

TopicandAuthor

Volume,diamete

PointersandIndirectAddressinginS7PLCs,Volume3DBPointers
andANYPointers

VOLUMEIIDIRE

Eddie Prince

Onthel-Functio

OverviewIndirectAddressinginS7PLCs

Onthel-function

Thisapplicationnoteisthethirdofthreenotesthatprovideanoverviewofindirect
addressingmethodsandstructuresavailableintheStatementList(STL)languageforS7PLCs.
ItdescribestheuseofDBpointers,ANYpointersandaddresspointersinSTLprograms.The
documentsalsoincludearchivedSTEP7librariescontainingfunctions(FC)thatdemonstrate
theseaddressingmethods.Thefunctionsinthelibrarydemonstratetheuseofindirect
addressingmethodstoreadfromandwritetoarraysofbytes,integers,realnumbers,andarrays
ofstructures.

TheHopfvolum

Volume1describesMemoryIndirectAddressing
Volume2describesRegisterIndirectAddressing
Volume3describestheuseofDBPointersandANYPointers

UsingPointersinFunction(FC)andFunctionBlock(FB)Calls
Thefirsttwoapplicationnotesinthisseriesfocusedmainlyontheuseofareapointers

forindirectaccesstotheoperandofastatementlistinstruction.Areapointersare32bit
structuresthatcanbestoredinastandard32bitS7doubleword.Areapointerscancontainthe
addressofastandardS7memorylocation.TheycanbeusedinSTLinstructionsfortheindirect
accessofanyofthestandardS7elementarydatatype(Bit,Byte,Char,Word,Integer,DWORD,
DINT,andRealdatatypes).
TheS7architecturealsoincludestheconceptofcomplexdatastructuressuchasDate,
String,Array,andStructure,aswellasprovisionformultipledatablockswithinanS7program.
Ingeneral,thesecomplexdatatypesrequiremorethanasingleS7memorylocation,andthe
definitionoftheiraddressrequiresapointerthatexceedsthesizeofasingleS7doubleword.
Furthermore,theSTLinstructionsetdoesnotincludetheabilitytomanipulatethesecomplex
datastructuresdirectly.However,codeblocks(SFC,SFB,FC,andFBs)canbedevelopedand
usedtomanipulatethesecomplexdataobjects.
Thisapplicationnotewilldemonstratemethodsofhandlingthesecomplexdata
structuresinaSTEP7program.Theprimarytopicsinclude:
PointersandIndirectAddressinginS7PLCs,Volume3DBPointersandANYPointers
Copyright 2000bySIEMENS

page1/1

Revision2

SIMATICNETcustomershavefreeuseoftheapplicationtips.ThesetipsareonlyageneralapproachtousingSIMATICNETwithvariousapplications.
Yourspecificapplicationmaybedifferent.ItisyourresponsibilitytouseSIMATICNETproperlyinyourapplications.

http://wenku.baidu.com/view/a1ff0432376baf1ffc4fad3b.html

1 /14

VIP,
1/4

4/13/2016

Volume3describestheuseofDBPointersandANYPointers_

PointersandIndirectAddressinginS7PLCs,Volume3DBPointersandANY
Pointers
1) ThestructureofDBPointersandANYPointers
2) UsingpointersasformalparametersinFunctionBlock(FB)calls
3) FBProgrammingtechniquesforANYPointers
4) SpecialprovisionsforPointersasparametersinFunction(FC)calls
5) ArchivedSTEP7programswithsampleFBsandFCsdemonstratingthetopics
describedinthisapplicationnote.

Pointers
PointersarespecialobjectsthatarestructuredtocontainanS7memoryaddress.Pointersmay
bestoredinmemorylocationsorinS7CPUregisters.Therearethreeclassesofpointers
containedintheS7architecture.Theseinclude:
A) AreaPointersa32bitstructurethatidentifiesaspecificaddress
B) DBPointersa48bitstructurethatcombinesanareapointeranda16bitDBnumber
C) ANYPointersan80bitstructurewithadditionalspecificationsforthevariableaddress.
ThisapplicationnotewilldescribeDBPointersandANYPointersindetail.Furtherinformation
onAreapointerscanbefoundinthecompanionapplicationnotePointersandIndirect
addressinginS7PLCs,Volume1MemoryIndirectAddressingornotePointersandIndirect
addressinginS7PLCs,Volume2RegisterIndirectAddressing

AreaPointers
Asshownbelow,anareapointerneedstocontainthreebasiccomponentstospecifyalocation
inS7memory

AddressArea

ByteAddress

BitAddress

A) AddressAreatheaddressareafielddescribeswhichmemoryareaisbeing
addressed.TheS7addressareasincludePeripheralI/O(PIandPQ),I/Oimage(Iand
Q),Marker(M),Globaldata(DBx),Instancedata(DIx),localdata(L),andlocaldataof
thecallingblock(V).PointerswithanareatypespecifiedarereferredtoasArea
CrossingPointers.
Theaddressareamayalsocontainanullspecificationmeaningthepointercontains
onlyabyte.bitvalue.Pointerswithanulladdressarea(Hex00)arereferredtoas
AreaInternalPointers.AreaInternalPointersaretheonlytypesthatcanbeusedfor
MemoryIndirectAddressing.
B) ByteAddressthebyteaddressisanumberspecifyingthebyteoffsetintothememory
area.Thebyteaddressofanaddressareastartsatbyte0
C) BitAddressthiscontainsthebitnumberoftheaddressedbyteabove.Thebitaddress
isanumberfrom0to7.
PointersandIndirectAddressinginS7PLCs,Volume3DBPointersandANYPointers
Copyright 2000bySIEMENS

page2/2

Revision2

SIMATICNETcustomershavefreeuseoftheapplicationtips.ThesetipsareonlyageneralapproachtousingSIMATICNETwithvariousapplications.
Yourspecificapplicationmaybedifferent.ItisyourresponsibilitytouseSIMATICNETproperlyinyourapplications.

PointersandIndirectAddressinginS7PLCs,Volume3DBPointersandANY
Pointers

http://wenku.baidu.com/view/a1ff0432376baf1ffc4fad3b.html

2/4

4/13/2016

Volume3describestheuseofDBPointersandANYPointers_

DBPointers

Theareapointersdescribedabovecanbeusedtoidentifyanelementaddressofan

openeddatablock.Anopeneddatablockreferstoeitherthecurrentglobaldatablock(DB),
orthecurrentinstancedatablock(DI).However,sometimesitisnecessarytoidentifyadata
blockelementthatmayormaynotbeoneofthetwocurrentlyopeneddatablocks.TheDB
Pointercanbeusedforthispurpose.

TheDBPointercontainsacompletelyspecifiedaddressofadatablockdataelement.

ThatmeansitcontainsboththeDataBlocknumberandthedataelementaddresswithinthe
datablock.ADBPointerisformedbyaddinga16bitintegervalue(containingthedesireddata
blocknumber)toa32bitareacrossingpointercontainingtheaddressofthedataelementin
thedatablock.ThestructureofaDBPointerisdiagrammedbelow:

16BitDBNumber

32BitAreaCrossingPointer

FormatsforrepresentingaDBPointerinaSTEP7programmingstatementareshownbelow.
Thefirstexampleshowstheuseofexplicitaddressingthesecondshowstheuseofsymbolic
addressing.TheexplicitaddressisprefacedbytheuseofP#toidentifyapointer,followedby
theexplicitdatablockandbyte.bitaddressinthedatablock.Insymbolicaddressing,theSTEP7
programmingsoftwarewillinterpretthecompletesymbolicname(DBsymbolname&element
symbolname)asaDBpointerwhenitisappliedtoablockparameterdefinedasaPointer

P#Data_Block_#.Data_Element_Address
DB_Symbol.Data_Element_Symbol

SampleDBpointers
PointerDescription
P#DB62.DBX12.0
P#DB62.DBX88.3

Theaddressofdatabyte.bit12.0ofdatablock62
Theaddressofdatabyte.bit88.3ofdatablock62

Motors.Oil_Pump_Motor

Theaddressofthedatabyte.bitoftheelement
Oil_Pump_MotorcontainedwithintheDataBlocknamed
Motors

ANYPointers
S7allowsforthedefinitionofcomplexdatatypesthatcontainmultipledataelementsina
singlestructure.ExamplesofthesedatatypesincludeArrays,Structures,andString
variables.TheS7architectureprovidesageneralpointer,calledtheANYpointer,tohandle
PointersandIndirectAddressinginS7PLCs,Volume3DBPointersandANYPointers
Copyright 2000bySIEMENS
page3/3

Revision2

SIMATICNETcustomershavefreeuseoftheapplicationtips.ThesetipsareonlyageneralapproachtousingSIMATICNETwithvariousapplications.
Yourspecificapplicationmaybedifferent.ItisyourresponsibilitytouseSIMATICNETproperlyinyourapplications.

08

11

http://wenku.baidu.com/view/a1ff0432376baf1ffc4fad3b.html

3/4

4/13/2016

Volume3describestheuseofDBPointersandANYPointers_

~
240

...

2016Baidu|||

http://wenku.baidu.com/view/a1ff0432376baf1ffc4fad3b.html

4/4

S-ar putea să vă placă și