a-入门培训视频及资料14 例程vc例程chapter3_ads_e_第1页
a-入门培训视频及资料14 例程vc例程chapter3_ads_e_第2页
a-入门培训视频及资料14 例程vc例程chapter3_ads_e_第3页
a-入门培训视频及资料14 例程vc例程chapter3_ads_e_第4页
a-入门培训视频及资料14 例程vc例程chapter3_ads_e_第5页
已阅读5页,还剩62页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、TwinCATThe Windows Control and Automation TechnologyTwinCAT ADSSet values profilesDefinitionExcursion: TwinCAT device concepta.) Identification of TwinCAT ADS devices b.) TwinCAT message routerADSa.) Introductionb.) Client-server relationship c.) Access typesd.) Overview of methods220.10.2018ADS (Ge

2、neral)DefinitionADS = Automation Device Specification- modular ADS devicese.g. PLC (each run time system), NC,.- message exchange by ADS via the message router320.10.2018TwinCAT Device conceptADS server unambiguously identifiable by: AdsAmsServerPortRouter unambiguously identifiable by: AdsAmsServer

3、NetID420.10.2018Identification of ADS devices- Every (TwinCAT) PC in the network can be uniquely identified by means of a TCP/IP address such as 6.- The AdsAmsServerNetID is an extension of the TCP/IP address, and identifies a message router, e.g. 6.1.1- The last two figures can be

4、 freely selected.520.10.2018Identification of ADS devicesThe ADS servers of a message router are clearly identified by a number (- AdsAmsServerPort).The following AdsAmsServerPort numbers are already assigned:801,811,821,831500100: TwinCAT PLC server, 1.-4. run-time system: TwinCAT NC server: TwinCA

5、T logger620.10.2018TwinCAT message router (I)TwinCAT message router (I)Example:An ADS client sends an ADS message to an ADS server.The TwinCAT message router (transport layer 4) carries out:- acceptance of the request from the client- forwarding the message to an router if appropriate- provision of

6、the messages to the ADS server720.10.2018TwinCAT message router (II)Existing message router:- On every TwinCAT PC- On every Embedded PC CX1000, CX1001- On every bus controller BX1000- On every bus controller (e.g. BC3100, BC8100, ., BCxxxx)Possible communication paths:- Network (TCP/IP)A PLC run-tim

7、e system sends data to another PLC on another TwinCAT PC in the network.- Fieldbus (Lightbus / Profibus)A PLC run-time system sends data to another PLC on a bus controller in the fieldbus.820.10.2018ADS - InterfaceThe ADS interface permits:Standard:- communication with other ADS devicesClient reques

8、ts data or services, server answers automaticallySpecial solutions:- implementation of an ADS server (device)PLC : Extension of the existing ADS server functions of the PLC with the PLC Library function blocks “Indication Response”Windows applications:TcSystem DLL(detailed information about ADS comm

9、unication necessary920.10.2018Client-server relationship1.) Confirmed services2.) Unconfirmed servicesADS ClientADS ServerRequestIndicationConfirmationResponse1020.10.2018Client server relationship between 2 PLC devicesExample (PLC runtime 1) requests data from PLC (runtime2)ADS-ClientPLC IADS-Serve

10、r PLC IIuses ADS FBProvides the dataRequest(FB call)IndicationConfirmation(Busy at FB)Response1120.10.2018Access types (I)1.) By addressExample:Read / write a total of 100 bytes starting from byte offset 20 of the input/output process image in the PLC server or of the flags area. (Often used in proc

11、ess visualisation)2.) By name“Example:Read / write the PLC variable temperature.1220.10.2018Access types, time flow (I)Synchronous.- Client sends a request to server- Client waits until the result is existing- Synchronous to the program line“1320.10.2018Access types, time flow (II)Asynchronous- Clie

12、nt sends a query to the server- Client continues to work without waiting- Result of the server by callbackNotification- Client registers itself at the server- Server serves the client autonomously by callback (until the client signs off from the server again)1420.10.2018ADS OCX IntroductionDefinitio

13、n OCX:ActiveX-Control according to COM-(Component Object Model) SpecificationThe OCX contains:- general ADS services- extended ADS services, that simplify the process (e.g. synchronous communication)1520.10.2018ADS OCX Introduction methods (I)AdsSyncReadBoolReq AdsSyncReadBoolVarReq AdsSyncReadInteg

14、erReq AdsSyncReadIntegerVarReq AdsSyncReadLongReq AdsSyncReadLongVarReqSynchronousAdsSyncxxyyReq - per AdresseAdsSyncxxyyVarREQ -per NameMethods for request (= Req)AdsReadIntegerReq AdsReadLongReq AdsReadSingleReq AdsReadDoubleReq AdsReadStringReqAsynchronousAdsReadIntegerConf AdsReadLongConf AdsRea

15、dSingleConf AdsReadDoubleConf AdsReadStringConfEvents at data updating (= Conf)1620.10.2018ADS OCX Introduction methods (II)NotificationReadVarConnectExAdsRe adConnectUpdateExMethod for apply NotificationAdsReadConnectUpdateExEvent after data updateAdsDisconnectExMethod for sign off NotificationNoti

16、fication. Connect?.EX?Notification is a term from the communication. Connect is a term of the ADS Ocx method.EX: means Extended. It is the extended method of the old connect method. The difference is the easier handling.(- connectEx is recommended)1720.10.2018Server Cycle(e.g. PLC send with every cy

17、cle)Server on Change(e.g.) PLC send only if variables changesClient CycleClient (ADS Ocx) writes / reads data with own cycle.1820.10.2018Notification RefreshADS OCX methods overviewSynchro- nousAsynchro- nousVariable typesAllAll except BOOLAccessBy address By nameGenerally only by address. But (with

18、 more effort, i.e. using index group/index offset) also by nameAdvantageEasy handling in the Visual Basic ProgramThe Visual Basic Program does not wait for an answer, but continues to operateDisadvantageThe user must de- termine the event himself. (Disadvantage when reading) If the answer pages are

19、long, the VB program can slow downMore administra- tive overhead in the Visual Basic program, since the answer requires reaction to an event.CommentLocal communication, fast networks, communication initiated at needSlow communication (networks) large data packetsConnectAllBy name By addressUpdating,

20、 takes place on the server (PLC)Unnecessarily high data traffic with many connect connectionsSpecify sensible refresh times, clear connections that are not needed1920.10.2018Specifying the ADS communication partnerBefore communicating with an ADS device, the following properties of the communication

21、 partner must be specified once:- AdsAmsServerNetID (e.g. 6.1.1) and- AdsAmsServerPort (e.g. 801 PLC server, 1st run-time system)A separate ADS-OCX should be used for each ADS communication partner:e.g. ADS_OCX1 for PLC server 1st run-time systeme.g. ADS_OCX2 for NC servere.g. ADS_OCX3 for

22、PLC server 2nd run-time systemFor communication between one PC and several BC (9)000 Controllers one OCX and e.g. one additional I/O task can be used.The IO task “collects”all data from the BCs and the ADS OCX access to this area.2020.10.2018ADS OCX ExamplesADS-OCX Examples:ADS-OCX in Visual Basic p

23、rojectI IILinking, simple data exchangeExamples: Synchronous and Connect“VBA I VBA II VBA IIIVBA with Graphworks synchronous data exchange VBA with Graphworks data exchange with connect VAB with excel2120.10.2018TwinCAT.Ads.Dll ExamplesTwinCAT.ADS.Dll Examples:TwinCAT.ADS.Dll with VisualS a

24、nd C#Ads.Dll C# I Ads.Dll C# IILinking, simple data exchangeExamples: Synchronous and Connect“2220.10.2018Example 15.1.b) Example Write a Variable Synchronously to the PLCThe task:PLCVisual BasicIn the PLC run-time 1The local variable iVbToPlc1 in the MAIN program is to be overwritten by the Visual

25、Basic application.An (integer) value is to be read from a text field in the Visual Basic application. This value is converted into an integer and saved in the global variables of the PLC project. Name: iVbToPlc1This global variable is written into the PLC with a command button.2320.10.2018Example 1P

26、LC:Create a PLC project, create the main program and declare a local variable iVbToPlc1Local var VbToPlc1Only dummy instruction2420.10.2018Example 1Visual Basic:Create Visual Basic, (standard.exe), link ADSOCXProject - components2520.10.2018Example 1Visual Basic:Create form, place control elementsTx

27、tValueADSOCX1CmdWrite2620.10.2018Example 1Visual Basic:Declare variable and handle for the variableGeneralDeclarations2720.10.2018Example 1Visual Basic:In FORMLOAD event set PROPERTIES for ADSOCX1Form Load Event(double click on the form)Set properties(work local)MarketingMarketingULILAKERSchulungSch

28、ulungsfolienADSOCXscreenshotsSet propertiesPLC Runtime should be 1 (=Port 801)Set propertiesEnable exception , if method call incorrect, VB stops.2820.10.2018Example IAt faulty completion of a message, a message dialog is generated automatically.In the development environment of VB can be jumped to

29、the program line along with the cause.By using the VB instructions On Error Gotohandling can be programmed. C#: Try and Catch/ Resume an own error2920.10.2018Example 1Visual Basic:Other possibility for error evaluationMethod call with evaluation(If an error occurs during execution(of the method), th

30、e return value does not equal 0.This can be used to trigger execution of an individual error handling process(here a message box).)3020.10.2018Example 1Visual Basic:The handle is provided by the PLC and is known to the Visual Basic program. This handle can now be used to demand the variable from the

31、 PLC. The Click Event of the command button is selected as the trigger (event) for this action.First therefore read the text field, and assign this value to the variable.3120.10.2018Example 1Visual Basic:The handle is provided by the PLC and is known to the Visual Basic program. This handle can now

32、be used to demand the variable from the PLC. The Click Event of the command button is selected as the trigger (event) for this action.As AdsOcx method is used AdsOcx1.AdsSyncWriteIntegerVarReq, what is the meaning of this name?Synchronous writing(Synchronous is related to the processing of the Visua

33、l Basic program. Execution of the Visual Basic program only continues when execution of this method has been completed.)A value of type integerThis value is to be written via the name variable.3220.10.2018Example 1Visual Basic:In the click event of the command button.This variable is to be written t

34、o the PLC.3320.10.2018Visual Basic:In the click event of the command button.Pay attention to Intelli Sense from Visual Basic (Studio)The VISUAL BASIC variable from which the value to be written is to be takenLength in bytes that will be required fortransmission of the variable from the PLC to theVis

35、ual Basic application (integer 2 bytes)Handle which has previously been fetched3420.10.2018Example 1Example 1Visual Basic:Summary: Click eventTest: Start PLC, save Visual Basic application and start. If everything is in order, the value in the text window of the Visual Basic program can be changed (

36、- 32768.+32767). After clicking the command button, the variable in the PLC program must have taken on this value.3520.10.2018Example 2Visual Basic Example 2Synchronous access to bitlocated address, synchronous by name, by name and connect to several variables and write arrays synchronously.(Base pr

37、oject on training PC or disk)The controls are already placed on the form. A small editing possibility has been programmed for the control Msflexgrid“. This example shows the pure using of the methods of ADS Ocx to access to the variables.The Enable Errorhandling“ is used to handle with errors.3620.1

38、0.2018Example 2Visual Basic Example 2 Form3720.10.2018Visual Basic Example 2 Form3820.10.2018Example 2Features of ADS OCX by assignmentVisual Basic Example 2 Form3920.10.2018Example 2Access to bitlocated PLC variableVisual Basic Example 2 Form4020.10.2018Example 2Access to bitlocated PLC variableVis

39、ual Basic Example 2 Form4120.10.2018Example 2Access to bitlocated PLC variableVisual Basic Example 2 Form4220.10.2018Example 2Access by nameVisual Basic Example 2 Form4320.10.2018Example 2Access by nameVisual Basic Example 2 Form4420.10.2018Example 2Access by name and connectStep 1: connectingVisual

40、 Basic Example 2 Form4520.10.2018Example 2Access by name and connectStep 2: analyse event from ADS OCXVisual Basic Example 2 Form4620.10.2018Example 2Access by name and connectStep 3: disconnectVisual Basic Example 2 Form4720.10.2018Example 2Access to an array synchronously by namefirst arrayVisual

41、Basic Example 2 Form4820.10.2018Example 2Access to an array synchronously by namesecond arrayExample 2Visual Basic Example 2 FormRequired PLC variable4920.10.2018Example VBA IExample AdsOcx with Genesis32 VBASynchronous data exchange5020.10.2018Example VBA I: Synchronized write/read of PLCvariablesSynchronized readSynchronized

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论