It is possible to use Visual Basic to create a custom MMI when RSLinx Professional is available. Thismethod uses DDE (Dynamic Data Exchange) and is somewhat slow, but it is an easy way to get limited amounts of data from a PLC.
The first step is to create a topic in RSLinx Professional (must be the professional version). In the example uses here, the topic is called ‘LID_PUNCH’. You can use whatever name you wish, it is important that the topic matches the LinkTopic setup in Visual Basic. Select DDE/OPC from the menu bar in RSLinx as shown in Figure 1. Then select Topic Configuration
Figure 2 shows the actual setup for the topic that is named LID_PUNCH. The machine in example uses an Allen-Bradley SLC5/04. The Data Source is an SLC5/04 that is highlighted under IP address10.100.100.118.
Next, select the Data Collection tab, and setup the PLC type. Figure 3 shows that a SLC503+ has beenselected for the type, and the Polled essages time has been set for 1000msec. If we request the data later in Microsoft Excel, we will be updating the cell in the spreadsheet every 1000 msec according to this value.
Once the topic has been configured in RSLinx, a simple Visual Basic program can be configured that has a text box and a command button on a form. The following code can be placed in the command button Click event:
Text1.LinkTopic = ”RSLinx|LID_PUNCH”
Text1.LinkItem = ”N7:0”
Text1.LinkMode =2
Text1.LinkRequest
The above code will cause data from address N7:0 to appear in the text box whenever the command buttonis clicked.
No comments:
Post a Comment