Good Morning,
I need to write a STRING type tag to a ControlLogix PLC via a web browser so lab personnel can tag contents of various storage tanks approved including the date, their initials, etc. I wrote a simple VBSCRIPT, below, to achieve this using OPC to RSLinx Gateway 2.5x running on the same PC as this script, and it works fine when I double click it, to either read OR write the PLC tag, without any Matrikon or other 3rd party software. Note that it reads/writes to a string array, a fixed value, to a SINGLE array element -- as this is just a test -- once I have it working I will tie it into a web input form.
Please bear in mind, this computer handles datalogging and a number of other tasks running under RSVIEW32 7.40, thus it is Windows XP and II 5.1. I cannot upgrade to newer windows at this time due to cost. It also handles web-based plotting using Dygraphs and Oracle mySQL, so IIS is already set up on the PC. I even have Excel functions written to query the Oracle MySql server to look up averages and tag values (poor-man's OSI PISOFT).
The problem is, when I try to run the script from a web browser, as I need to do, it throws an error on the Set objOPCServer = CreateObject("OPC.Automation") line. The error is below:
Microsoft VBScript runtime (0x800A01AD)
ActiveX component can't create object
I assume this is some sort of DCOM permissions error; but I tried to set script/directory permissions to an Administrator account and it STILL did it. This web site ONLY functions on a plant LAN, I'm not terribly concerned about security. If someone could tell me how to remedy this, it would be very helpful. Or if they could provide a free alternative way to achieve the tag write within a web browser, that would be great. Obviously, it does NOT throw this error when I double-click the same script within Windows logged in under Administrator account.
Also, I ALREADY have a 1756-eWeb ControlLogix card, and use it to read PLC values to web pages; however, I cannot use WriteLogixTag because it appears only to allow me to write values to a CPU in the same SLOT as the eWeb card; since it's on a different rack, and I cannot move it, that is NOT an option. It MIGHT be possible to use CIP Generic message on the eWeb, but I don't know enough about CIP, to build a command that would write a string tag -- so alternately if someone can provide a simple example of that it would prove invaluable. I do NOT understand why Allen-Bradley's eWeb ReadLogixTag function ACCEPTS a full path but WriteLogix only takes a 'slot' as a parameter...
If there is an easier way or alternate script language means of writing a tag than what I'm doing below, I am open to that as well. I think this might be useful to others as a free way to view plant data on a web page WITHOUT any 3rd party products (even without an eWeb card) if this minor issue could be overcome. . .
<%@ Language= "VBScript" %>
<%
response.write("Hello world! - VBScript in IIS")
'Define variables
Dim objOPCServer
Dim objOPCGroup
Dim objOPCItem1
Dim vItem
Dim vQuality
'make reference to RSLinx OPC Automation Interfaces dll and Create OPC Server object
Set objOPCServer = CreateObject("OPC.Automation")
'Connect to RSLinx
objOPCServer.Connect "RSLinx OPC Server", ""
'Define OPC Server parameters
objOPCServer.OPCGroups.DefaultGroupIsActive = True
objOPCServer.OPCGroups.DefaultGroupUpdateRate = 300
'Create OPC Group
Set objOPCGroup = objOPCServer.OPCGroups.Add("VSE")
'Add OPC item to read
'The code below assumes that opc item 'TANK_CONTENTS_ARRAY' resides on OPC topic 'Heartland'
Set objOPCItem1 = objOPCGroup.OpcItems.AddItem( "[Heartland]TANK_CONTENTS_ARRAY[0]", 1)
objOPCItem1.Read CLng(0), vItem, vQuality
objOPCItem1.Write ("TEST_STRING_CONTENTS")
'msgbox "The Value Is: " & vItem
%>