I have spent a long time looking for a possibility to control my system with a mobile phone. When for example I was working on the garden watering system I had to carry out my laptop. Thorough a CoDwSys visu I was opening the circuits. A standard visualization requires the possibility to run Java applets, which are unavailable in all the mobile phones I tested.
I dug through the Internet in a search for an Android SCADA application. I had installed many freeware SCADA programs to understand what it is all about and… had to give up quickly. The MODBUS communication rules were at that time too much for me.
Totally by accident I found out that my PLC can execute SSI scripts (server side includes). I managed to find a brochure (in Japanese…), which showed a few examples. After many attempts I managed to create a simple page, which can be opened in every(!) mobile phone browser and which in general can control everything.
Here are the technical details:
In the communication with the PLC the SSI scripts use the following commands:
If in the SSI file we place a code <!--READPI ADR=QX0&FORMAT=%d--> the webserver of the PLC when executing the script will replace the code with the value of the first Output.
So much for the theory. This is an example of a simple test.ssi file (extension ‘ssi’ is, as it seems, necessary for the webserver to execute the script)
<HTML> <BODY> Wyjscie 93 (5.12): Wejscie 3 (8.2): Tag 1 (MB0): Czas: </BODY> </HTML>
Voila! After you upload the file to the “webserv” directory and open it in the browser (for example at: 192.168.1.1/test.ssi) you will receive information straight from the PLC controller.
For writing data you can use the following form:
<form action="/WRITEPI" method="POST"> <input type="text" name="ADR1" value="MB0"> <input type="text" name="VALUE1" value="<!--#READPI ADR=MB0&FORMAT=%d-->" > <input type="text" name="FORMAT1" value="%d" > <input type="SUBMIT" value="ZAPISZ">
After the ‘Send’ button is pressed the value of the variable stored at MB0 will be replaced by the value of the VALUE1 field.
My app looks as follows:
In the PLC_PRG, in the variable definition part I placed:
VIS_GARDEN1 AT %MB0 :BOOL; VIS_GARDEN2 AT %MB1 :BOOL; (…) GARDEN1, GARDEN2 (…) :Fb_LatchingRelay;
Variables with ‘VIS_’ prefix are used in my system for controlling over visualizations
Variables GARDEN… are bound to the Fb_LatchingRelay function block from the building_common library
In the PLC_PRG code:
GARDEN1(xSwitch:=VIS_GARDEN1, xCentON:=Timers.Garden1_OnTrig.Q, xCentOFF:=Timers.Garden1_OffTrig.Q); OUT93:=GARDEN1.xActuator;
Variables Garden1_OnTrig i Garden1_OffTrig come from a separate proces (Timers), where I placed all time-related functions; ignore for now)
Further examples of SSI scripts can be found in the next article.