好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

4000通讯VBADS通讯.ppt

67页
  • 卖家[上传人]:公****
  • 文档编号:589103016
  • 上传时间:2024-09-09
  • 文档格式:PPT
  • 文档大小:2.59MB
  • / 67 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • TwinCAT Total Windows Control and Automation TechnologyTwinCAT ADS DefinitionExcursion: TwinCAT device concept a.) Identification of TwinCAT ADS devices b.) TwinCAT message router ADSa.) Introductionb.) Client-server relationshipc.) Access typesd.) Overview of methodsSet values profiles9/9/20242Josef Papenfort DefinitionADS = Automation Device Specification- modular ADS devices e.g. PLC (each run time system), NC,...- message exchange by ADS via the message routerADS (General)9/9/20243Josef Papenfort ADS server unambiguously identifiable by:AdsAmsServerPortRouter unambiguously identifiable by:AdsAmsServerNetIDTwinCAT Device concept9/9/20244Josef Papenfort - Every (TwinCAT) PC in the network can be uniquely identified by means of a TCP/IP address such as "172.1.2.16".- The AdsAmsServerNetID is an extension of the TCP/IP address, and identifies a message router, e.g. "172.1.2.16.1.1"- The last two figures can be freely selected.Identification of ADS devices9/9/20245Josef Papenfort The ADS servers of a message router are clearly identified by a number (-> AdsAmsServerPort). The following AdsAmsServerPort numbers are already assigned:801,811,821,831: TwinCAT PLC server, 1.-4. run-time system500: TwinCAT NC server100: TwinCAT loggerIdentification of ADS devices 9/9/20246Josef Papenfort 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 the messages to the ADS serverTwinCAT message router (I)9/9/20247Josef Papenfort 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-time 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.TwinCAT message router (II)9/9/20248Josef Papenfort The ADS interface permits:Standard:- communication with other ADS devices Client requests 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 communication necessaryADS - Interface9/9/20249Josef Papenfort 1.) Confirmed services2.) Unconfirmed servicesADS ClientADS ServerRequestIndication ConfirmationResponse Client-server relationship9/9/202410Josef Papenfort Example (PLC runtime 1) requests data from PLC (runtime2)ADS-ClientPLC IADS-Server PLC IIuses ADS FBProvides the dataRequestIndication(FB call)ConfirmationResponse(Busy at FB)Client – server relationship between 2 PLC devices9/9/202411Josef Papenfort 1.) "By address"Example: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 process visualisation)2.) "By name“Example:Read / write the PLC variable "temperature".Access types (I)9/9/202412Josef Papenfort Synchronous. -> Client sends a request to server-> Client waits until the result is existing-> „Synchronous to the program line“Access types, time flow (I)9/9/202413Josef Papenfort Asynchronous-> Client 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)Access types, time flow (II)9/9/202414Josef Papenfort Definition 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)ADS OCX Introduction9/9/202415Josef Papenfort AsynchronousADS OCX Introduction methods (I)SynchronousAdsSyncxxyyReq -> per AdresseAdsSyncxxyyVarREQ ->per NameAdsReadIntegerReqAdsReadLongReqAdsReadSingleReqAdsReadDoubleReqAdsReadStringReqMethods for request(= Req)AdsReadIntegerConfAdsReadLongConfAdsReadSingleConfAdsReadDoubleConfAdsReadStringConfEvents at data updating (= Conf)AdsSyncReadBoolReqAdsSyncReadBoolVarReqAdsSyncReadIntegerReqAdsSyncReadIntegerVarReqAdsSyncReadLongReqAdsSyncReadLongVarReq9/9/202416Josef Papenfort ADS OCX Introduction methods (II)NotificationReadVarConnectExAdsReadConnectUpdateExAdsReadConnectUpdateExMethod for apply NotificationEvent after data updateMethod for sign off Notification AdsDisconnectExNotification... 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)9/9/202417Josef Papenfort Notification Refresh Client (ADS Ocx) writes / reads data with own cycle.Client Cycle(e.g.) PLC send only if variables changesServer on Change(e.g. PLC send with every cycle)Server Cycle9/9/202418Josef Papenfort ADS OCX methods overview9/9/202419Josef Papenfort Before communicating with an ADS device, the following properties of the communication partner must be specified once:- AdsAmsServerNetID (e.g. "172.1.2.16.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 PLC server 2nd run-time systemFor communication between one PC and several BC (9)000 Controllersone 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.Specifying the ADS communication partner9/9/202420Josef Papenfort ADS-OCX Examples:ADS-OCX in Visual Basic projectILinking, simple data exchangeIIExamples: "Synchronous" and "Connect“VBA IVBA with Graphworks synchronous data exchangeVBA IIVBA with Graphworks data exchange with connectVBA III VAB with excelADS OCX Examples9/9/202421Josef Papenfort TwinCAT.ADS.Dll Examples:TwinCAT.ADS.Dll with VisualS and C#Ads.Dll C# ILinking, simple data exchangeAds.Dll C# IIExamples: "Synchronous" and "Connect“TwinCAT.Ads.Dll Examples9/9/202422Josef Papenfort 5.1.b) Example "Write a Variable Synchronously to the PLC"Example 19/9/202423Josef Papenfort Local varVbToPlc1Only dummyinstructionExample 1PLC:Create a PLC project, create the main program and declare a local variable iVbToPlc19/9/202424Josef Papenfort Project -> componentsExample 1Visual Basic:Create Visual Basic, (standard.exe), link ADSOCX9/9/202425Josef Papenfort TxtValueCmdWriteADSOCX1Example 1Visual Basic:Create form, place control elements9/9/202426Josef Papenfort GeneralDeclarationsExample 1Visual Basic:Declare variable and handle for the variable9/9/202427Josef Papenfort \\Marketing\Marketing\ULILAKER\Schulung\Schulungsfolien\ADSOCX\screenshotsSet properties(work local)Form Load Event(double click on the form)Set propertiesEnable exception , if method call incorrect, VB stops.Set propertiesPLC Runtime should be 1(=Port 801) Example 1Visual Basic:In FORMLOAD event set PROPERTIES for ADSOCX19/9/202428Josef Papenfort Example I At faulty completion of a message, a message dialog is generated automatically.In the development environment of VB can be jumped to the program line along with the cause.By using the VB instructions On Error Goto / Resume an own error handling can be programmed.C#: Try and Catch9/9/202429Josef Papenfort Method call with evaluation(If an error occurs during execution (of the method), the return value does not equal 0.This can be used to trigger execution of an individual error handling process (here a message box).)Example 1Visual Basic:Other possibility for error evaluation9/9/202430Josef Papenfort Example 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 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.9/9/202431Josef Papenfort AdsOcx1.AdsSyncWriteIntegerVarReq, what is the meaning of this name?As AdsOcx method is usedSynchronous writing(Synchronous is related to the processing of the Visual 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.Example 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 PLC. The "Click Event" of the command button is selected as the trigger (event) for this action.9/9/202432Josef Papenfort This variable is to be written to the PLC.Example 1Visual Basic:In the click event of the command button.9/9/202433Josef Papenfort Pay attention to Intelli Sense from Visual Basic (Studio)Handle which has previously been fetchedLength in bytes that will be required for transmission of the variable from the PLC to the Visual Basic application (integer @ 2 bytes)The VISUAL BASIC variable from which the value to be written is to be takenExample 1Visual Basic:In the click event of the command button.9/9/202434Josef Papenfort Test: 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 (-32768....+32767). After clicking the command button, the variable in the PLC program must have taken on this value.Example 1Visual Basic:Summary: Click event9/9/202435Josef Papenfort Synchronous access to bitlocated address, synchronous by name, by name and connect to several variables and write arrays synchronously.(Base project 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. Example 2Visual Basic Example 29/9/202436Josef Papenfort Example 2Visual Basic Example 2 Form9/9/202437Josef Papenfort Features of ADS OCX by assignmentVisual Basic Example 2 FormExample 29/9/202438Josef Papenfort Access to bitlocated PLC variableExample 2Visual Basic Example 2 Form9/9/202439Josef Papenfort Access to bitlocated PLC variableExample 2Visual Basic Example 2 Form9/9/202440Josef Papenfort Access to bitlocated PLC variableExample 2Visual Basic Example 2 Form9/9/202441Josef Papenfort Access by name Example 2Visual Basic Example 2 Form9/9/202442Josef Papenfort Access by nameVisual Basic Example 2 FormExample 29/9/202443Josef Papenfort Access by name and connectStep 1: connectingExample 2Visual Basic Example 2 Form9/9/202444Josef Papenfort Access by name and connectStep 2: analyse event from ADS OCX Example 2Visual Basic Example 2 Form9/9/202445Josef Papenfort Access by name and connectStep 3: disconnectExample 2Visual Basic Example 2 Form9/9/202446Josef Papenfort Access to an array synchronously by namefirst arrayVisual Basic Example 2 FormExample 29/9/202447Josef Papenfort Access to an array synchronously by namesecond arrayVisual Basic Example 2 FormExample 29/9/202448Josef Papenfort Required PLC variableExample 2Visual Basic Example 2 Form9/9/202449Josef Papenfort Example AdsOcx with Genesis32 VBASynchronous data exchangeExample VBA I9/9/202450Josef Papenfort Synchronized readPLC program changes „Poti1“Synchronized writeExample VBA I: Synchronized write/read of PLC variables9/9/202451Josef Papenfort Example VBA I: Graphworks329/9/202452Josef Papenfort TextExample VBA I: Graphworks329/9/202453Josef Papenfort Process Point with located variableExample VBA I: Graphworks329/9/202454Josef Papenfort MacrosGwxDemoReadByName_Main.DemoReadByNameExample VBA I: Graphworks329/9/202455Josef Papenfort GwxWriteString_Main.WriteStringExample VBA I: Graphworks329/9/202456Josef Papenfort Set macro properties and get handle for „Poti“ Example VBA I: Graphworks329/9/202457Josef Papenfort Macro “read poti”(„Poti lesen“)Example VBA I: Graphworks329/9/202458Josef Papenfort Macro “Write product” („Produkt schreiben“)If a variable is not written frequently, producing handle, writing value and dissolving value can be run through in a sequence.Example VBA I: Graphworks329/9/202459Josef Papenfort Delete macro handle for „Poti“ by endExample VBA I: Graphworks329/9/202460Josef Papenfort Example AdsOcx with Genesis32 VBA ConnectStart run-time-> create handle Ads Ocx -> analyse and display dataStop run-time -> delete handleExample VBA II9/9/202461Josef Papenfort Example VBA II: PLC9/9/202462Josef Papenfort „Text“Object Name ConnectVar1Object Name ConnectVar1Object Name ConnectVar1Example VBA II: VB macro handle to connection9/9/202463Josef Papenfort Example VBA II: Macro Connect9/9/202464Josef Papenfort Example VBA II: analyse event ADS OCX 9/9/202465Josef Papenfort Example VBA II: Disconnect at run-time stop9/9/202466Josef Papenfort Example AdsOcx with Exel VBAData exchange with Connect and filling the list(In preperation)Example VBA III9/9/202467Josef Papenfort 。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.