ProgrammingStyleguidey06/2015ProgrammingStyleguideforS7-1200/S7-1500TIAPortal:81318674,V1.1,06/20152¤SiemensAG2015AllrightsreservedWarrantyandLiabilityNoteTheprogrammingguidelinesdonotpurporttocoveralldetailsorvariationsinequipment,nordotheyprovideforeverypossiblecontingency.Theprogrammingguidelinesdonotrepresentcustomer-specificsolutions.Theyareonlyintendedtoprovidesupportfortypicalapplications.Youareresponsibleforthecorrectoperationofthedescribedproducts.Theseprogrammingguidelinesdonotrelieveyouoftheresponsibilityofsafelyandprofessionallyusing,installing,operatingandservicingequipment.Whenusingtheseprogrammingguidelines,yourecognizethatwecannotbemadeliableforanydamage/claimsbeyondtheliabilityclausedescribed.Wereservetherighttomakechangestotheseprogrammingguidelinesatanytimeandwithoutpriornotice.IfthereareanydeviationsbetweentherecommendationsprovidedinthisprogrammingguidelineandotherSiemenspublications–e.g.catalogs–thecontentsoftheotherdocumentshavepriority.Wedonotacceptanyliabilityfortheinformationcontainedinthisdocument.Anyclaimsagainstus–basedonwhateverlegalreason–resultingfromtheuseoftheexamples,information,programs,engineeringandperformancedataetc.,describedinthisprogrammingguidelinewillbeexcluded.Suchanexclusionwillnotapplyinthecaseofmandatoryliability,e.g.undertheGermanProductLiabilityAct(“Produkthaftungsgesetz”),incaseofintent,grossnegligence,orinjuryoflife,bodyorhealth,guaranteeforthequalityofaproduct,fraudulentconcealmentofadeficiencyorbreachofaconditionwhichgoestotherootofthecontract(“wesentlicheVertragspflichten”).Thecompensationfordamagesduetoabreachofafundamentalcontractualobligationis,however,limitedtotheforeseeabledamage,typicalforthetypeofcontract,exceptintheeventofintentorgrossnegligenceorinjurytolife,bodyorhealth.Theaboveprovisionsdonotimplyachangeoftheburdenofprooftoyourdetriment.AnyformofduplicationordistributionoftheseprogrammingguidelinesorexcerptshereofisprohibitedwithouttheexpressedconsentofSiemens.Securityinforma-tionSiemensprovidesproductsandsolutionswithindustrialsecurityfunctionsthatsupportthesecureoperationofplants,solutions,machines,equipmentand/ornetworks.Theyareimportantcomponentsinaholisticindustrialsecurityconcept.Withthisinmind,Siemens’productsandsolutionsundergocontinuousdevelopment.Siemensrecommendsstronglythatyouregularlycheckforproductupdates.ForthesecureoperationofSiemensproductsandsolutions,itisnecessarytotakesuitablepreventiveaction(e.g.cellprotectionconcept)andintegrateeachcomponentintoaholistic,state-of-the-artindustrialsecurityconcept.Third-partyproductsthatmaybeinuseshouldalsobeconsidered.Formoreinformationaboutindustrialsecurity,visit://support.industry.siemens.com.TableofContentsProgrammingstyleguideforS7-1200/S7-1500EntryID:81318674,V1.1,06/20153¤SiemensAG2015AllrightsreservedTableofContentsWarrantyandLiability.................................................................................................21Introduction........................................................................................................42ExplanationofTerms........................................................................................63GeneralSpecifications......................................................................................83.1Specificationsandcustomerrequirement............................................83.2SettingsinTIAPortal............................................................................93.3Identifier..............................................................................................113.3.1Formatting..........................................................................................113.3.2Abbreviations......................................................................................124PLCProgramming...........................................................................................134.1Programblocksandsources..............................................................134.1.1Blocknameandnumbers...................................................................134.1.2Formatting..........................................................................................144.1.3Programming......................................................................................144.1.4Comments..........................................................................................154.1.5Formalparameters:Input,OutputundInOut.....................................164.2Tagdeclaration...................................................................................184.2.1Staticandtemp..................................................................................184.2.2Constants..................................................................