Application Example 02/2016 Master-Slave Communication Via .

Transcription

Application Example 02/2016Master-Slave Communicationvia UDP BroadcastSIMATIC m/cs/ww/en/view/20983558

Warranty and LiabilityWarranty and LiabilityNoteThe Application Examples are not binding and do not claim to be complete withregard to configuration, equipment or any contingencies. The ApplicationExamples do not represent customer-specific solutions. They are only intendedto provide support for typical applications. You are responsible for the correctoperation of the described products. These Application Examples do not relieveyou of the responsibility of safely and professionally using, installing, operatingand servicing equipment. When using these Application Examples, yourecognize that we cannot be made liable for any damage/claims beyond theliability clause described. We reserve the right to make changes to theseApplication Examples at any time and without prior notice. If there are anydeviations between the recommendations provided in this Application Exampleand other Siemens publications – e.g. Catalogs – the contents of the otherdocuments shall have priority.We do not accept any liability for the information contained in this document. Siemens AG 2016 All rights reservedAny claims against us – based on whatever legal reason – resulting from the use ofthe examples, information, programs, engineering and performance data etc.,described in this Application Example shall be excluded. Such an exclusion shallnot apply in the case of mandatory liability, e.g. under the German Product LiabilityAct (“Produkthaftungsgesetz”), in case of intent, gross negligence, or injury of life,body or health, guarantee for the quality of a product, fraudulent concealment of adeficiency or breach of fundamental contractual obligations (“wesentlicheVertragspflichten”). The compensation for damages due to a breach of afundamental contractual obligation is, however, limited to the foreseeable damage,typical for the type of contract, except in the event of intent or gross negligence orinjury to life, body or health. The above provisions do not imply a change of theburden of proof to your detriment.Any form of duplication or distribution of these Application Examples or excerptshereof is prohibited without the expressed consent of Siemens AG.SecurityinformationSiemens provides products and solutions with industrial security functions thatsupport the secure operation of plants, solutions, machines, equipment and/ornetworks. They are important components in a holistic industrial securityconcept. With this in mind, Siemens’ products and solutions undergo continuousdevelopment. Siemens recommends strongly that you regularly check forproduct updates.For the secure operation of Siemens products and solutions, it is necessary totake suitable preventive action (e.g. cell protection concept) and integrate eachcomponent into a holistic, state-of-the-art industrial security concept. Third-partyproducts that may be in use should also be considered. For more informationabout industrial security, visit http://www.siemens.com/industrialsecurity.To stay informed about product updates as they occur, sign up for a productspecific newsletter. For more information, lave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/20162

1 TaskTable of ContentsWarranty and Liability . 21Task . 42Solution. 52.12.22.32.3.12.3.23Basics . 103.13.23.34Configuration of the station . 29Using the LBC library . 30Installation and Commissioning . 34 Siemens AG 2016 All rights reserved6.16.26.2.16.2.27General overview . 14User interface . 17Functionality as master . 19Adopting master function. 19Sending message frames. 20Slave management . 23Time measurement . 26Functionality as slave . 27Receiving of frames. 27Acknowledging frames . 27Time measurement . 27Performance characteristics . 28Cycle time as the master . 28Reaction time of the slaves . 28Configuration and Settings. 295.15.26Basic terms . 10UDP . 11Connections for SIMATIC controllers . 11Mode of Operation . .54.5.14.5.25Overview. 5Description of the core functionality . 6Hardware and software components . 9Validity . 9Components used . 9Installing the hardware . 34Installing the software . 34Preparation . 34Loading the S7 project into the CPU . 35Operating the Application . 377.17.27.2.17.2.27.2.37.2.47.3Station as slave scenario . 37Station as master scenario . 38Adopting master function. 38Generating test data . 39Sending a send frame . 40Sending request frame . 40Diagnostics . 418Related literature . 429History. 42Master-Slave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/20163

1 Task1TaskIntroductionA frequent requirement in many applications is sending a data record quickly andsimultaneously to several stations.This could be the case in a conveyor and transport system, for example. In freemoving transport units a quasi-synchronous reaction can be initiated with only oneframe. A frame could contain the information to turn all units to the left by 15 .Figure 1-1FührendeGuidingTransporteinheittransport ittransport unit(Slave)(slave)Variable )VariableTransporteinheitVariabletransport unit(Slave)(slave) Siemens AG 2016 All rights reservedA combination of transport units often consists of variably combined units. Hence, itshould be possible during runtime to disconnect a unit from the combination oftransport units and to connect another unit.Requirements Transfer of user-specific data from one master to all slaves using a broadcast Acknowledging the received data from the slaves to the master Uniform software package for master and slaves Efficient transfer of the data Adding further stations has to be possible at any time without having to modifyalready existing stations. Each station can become guiding station during operation (master-slaveswitchover).Master-Slave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/20164

2 Solution2.1 Overview2Solution2.1OverviewSetupThe application example realizes the task with SIMATIC controllers S7-1200 andS7-1500, interconnected via PROFINET:Figure 2-1 Siemens AG 2016 All rights reservedMasterS7-1200Slave 1S7-1200Slave 2S7-1500Slave 3S7-1500Any number of controllers can participate here.The UDP protocol is used for communication. This way, the connections need notbe configured statically, but can be set up program-controlled (see also chapter 3.3“Connections for SIMATIC controllers”). Hence, the participating stations need notbe known to each other during the configuration process, and the master-slaveswitchover can be performed dynamically.Advantages Already existing PROFINET/Ethernet infrastructures can be used No additional communication processors are required, since the PROFINETports of the controllers are used Flexible topologies Simple expandability Communication bocks (TUSEND or TURCV) contained in STEP 7 are usedAssumed knowledgeThe following basic knowledge is assumed: Handling SIMATIC controllers Knowledge of STEP 7 programming Basics of industrial communicationMaster-Slave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/20165

2 Solution2.2 Description of the core functionality2.2Description of the core functionalityIntroductionA master sends data to slaves or requests data from slaves via a UDP broadcast.The slaves acknowledge the received broadcast to the master.The nodes need not be known during the configuration process and may changeduring operation. The function of the master can also be transferred to anycontroller during operation.The master can send data to slaves or request data from slaves. The applicationsends a maximum of 236 characters per send job. Siemens AG 2016 All rights reservedIf no send jobs are pending, the master periodically polls to ensure that all nodesare available. These polls are referred to as keep-alive frames in the sectionsbelow.Master-Slave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/20166

2 Solution2.2 Description of the core functionalityGraphic program flowThis section discusses the STEP 7 program flow.Figure 2-2enable1Establishingconnections2SlaveMaster orslave?Receivingframes?7ErrorYesMaster Siemens AG 2016 All rights reservedSendingacknowledgementsYesOthermaster s received?4Senddata?YesSendingdata framesto slavesNo5Requestdata?YesNoMaster-Slave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/20167

2 Solution2.2 Description of the core functionalitySequence as masterTable 2-1Action Siemens AG 2016 All rights reservedNote1.Connections are established.2.If the station shall adopt the function ofthe master, it is checked whetheranother node is already active as themaster.3.If no master is active, a keep-aliveframe is sent.4.Data is sent to the slaves with a sendcommand.5.Data is requested by the slaves using arequest command.6.If send or request commands arepending, keep-alive frames are sentperiodically.NoteIf another master is detected in thenetwork, an error is triggered. This doesnot affect the other master.If not all of the known slaves confirm the receiving of a frame, an error is output.However, this does not disrupt the send operation.Sequence as slaveTable 2-2Action1.Connections are established.2.If the station is not meant to take on thefunction as the master, it automaticallytakes on the function of a slave.7.If the station receives a frame from themaster, this will be acknowledged by aframe to the master.Master-Slave Communication via UDP BroadcastEntry ID: 20983558, V2.1, 02/2016Note8

2 Solution2.3 Hardware and software components2.3Hardware and software components2.3.1ValidityThis application is valid for2.3.2 STEP 7 V13 SP1 or higher S7-1200 with firmware version 4.1 or higher, S7-1500Components usedThe application was created with the following components:Hardware componentsTable 2-3 Siemens AG 2016 All rights reservedComponentQtyArticle numberCPU 1214C26ES7214-1AG40-0XB0CPU 151116ES7511-1AK00-0AB0CPU 151616ES7516-1AN00-0AB0SCALANCE XB00816GK5008-0BA00-1AB2Power supply 24V16EP1332-4BA00HinweisNoteFW V4.170 W 120/230 V ACThe functionality was tested with the hardware components specified. Similarproducts that are not included in the above list can also be used.Software componentsTable 2-4ComponentSTEP 7 ProfessionalQty1Artic

Master-Slave Communication via UDP Broadcast Entry ID: 20983558, V2.1, 02/2016 2 G 6 d Warranty and Liability Note The Application Examples are not binding and do not claim to be complete with regard to configuration, equipment or any contingencies. The Application Examples do not represent customer-specific solutions. They are only intended