CGI: key to the web-compatible PLC 

CGI (Common Gateway Interface) is a standard web- technology frequently used on web servers. CGI defines an interface on a web server that allows the execution of scripts or applications on the server itself. The result of these executable files is then usually transferred in the form of an HTML page to the calling client (browser). The normal practice is to store files that are executable via a CGI in a «cgi-bin» directory. A CGI call consists of the internet address, CGI directory specification («cgi-bin») and the desired executable file. If parameters are to be sent to the executable file, this is indicated with a «?», followed by the parameters. Multiple parameters are separated by a «+» sign.

PCD controllers from Saia-Burgess Controls Ltd have a web server with CGI interface that gives access to all the controller’s PLC data. In this way inputs/outputs, markers, data blocks, etc. can be read and modified. Data can be read with the CGI application «readVal.exe»; «writeVal.exe» can be used to write data.

A simple browser is all you need to apply this technology. For example, if you enter the URL in the browser’s address line, the browser window will display the current value of marker word 100 (in decimal format) for the controller with IP address 192.168.0.230. The actual CGI command «readVal.exe» is followed by a tag for addressing PLC data in the form of a parameter preceded by «?». This consists of a general identification key for process data (PDP), the desired PLC data (MW100 = marker word 100) and a format (d = decimal). To set the marker word at 1234, for examle, the URL should be http://192.168.0.230/cgi-bin/writeVal.exe?PDP,,MW100,d+1234. It should also be noted here that the writable value (1234) has been indicated in the form of a second parameter and preceded by a «+».



Alongside rudimentary CGI functions for reading and writing individual PLC data, PCD controllers also offer the possibility of polling or modifying several values simultaneously – with just a single access/telegram. This is done by using another CGI function for the one-off definition of records that specify the required PLC data. Once defined, they are polled with a single call and transferred with a single telegram. This is a flexible way of transferring even large volumes of data, with no communications overheads. 

It is all very well polling PLC data with a browser, but what advantage does it bring? Using precisely the same method, PLC data can be addressed from Java and .NET applications. With its WebRequest class, .NET already contains everything necessary for communication with a PLC. The user just has to give the required CGI instruction as a URL to the Web Request call. This will immediately provide him with all the necessary data inside his Visual-Basic application.It could not be simpler. Moreover, communication between the PLC and the PC or control panel does not require any special drivers, OPC servers or other added plug-in cards: everything can conveniently be managed with Windows® on-board resources. But the best part is, it always works the same, regardless of whether a web panel is connected directly to the machine with the PLC, or whether an office PC wants access to it via an intranet, or has to carry out telemaintenance via internet.