Wednesday, August 31, 2016

SimpleHMI by Html Page - Part1

The article was created to show how create simple control based on Web Page. Fenix can share data from Modbus or S7 devices in WebBrowsers. During project creation you can include standard web template to project with all important libraries. Template is used by Fenix Server which work from one side like WebSerwer ans second side like Modbus or S7 client. We will prepare simple example how control light and look on temperature in intelligent home system.

1. Create project name "SimpleHMI"

- Open Fenix
- Click on ^File->New^, <Add Project> window will appear. Type in [Project Name] "SimpleHMI"
Important is to that during creation option [Apply Http Templates] must be checked. Fenix will create structure below.




















2. Change "index.html" file

On beginning open "index.html" from ^HttpServer->Index.html->Open^ and delete all data between <style></style> and all data between <body></body>. Code will be look like picture below:

<!doctype html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
   <title>Fenix Modbus</title>   
   <script language="javascript" type="text/javascript" src="jquery-2.2.0/jquery-2.2.0.min.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.time.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.tooltip.js"></script>
   <script language="javascript" type="text/javascript" src="jquery-ui-1.11.4/jquery-ui.js"></script>  
   <script language="javascript" type="text/javascript" src="fenixlib.js"></script>
   <script language="javascript" type="text/javascript" src="script.js"></script>    
     
   <style>
   </style>

</head> 
<body>  
</body>
 
</html>

3. Add mimic like background

We were creted "bgd.jpg" this will be main mimic. We will add it like bacground in "index.html". The size of the "bgd.jpg" will be 600x600px. To add this file to project:

- Click on ^HtmlServer->Add Files->Add Existing File^
- Select right *.jpg file.
- Add code below to index.html

<!doctype html>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
   <title>Fenix Modbus</title>   
   <script language="javascript" type="text/javascript" src="jquery-2.2.0/jquery-2.2.0.min.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.time.js"></script>
   <script language="javascript" type="text/javascript" src="flot-0.8.3/jquery.flot.tooltip.js"></script>
   <script language="javascript" type="text/javascript" src="jquery-ui-1.11.4/jquery-ui.js"></script>  
   <script language="javascript" type="text/javascript" src="fenixlib.js"></script>
   <script language="javascript" type="text/javascript" src="script.js"></script>         
   <style>
    body {
  height: 600px;
  height: 600px;
        background-image: url("bgd.jpg");
        background-repeat: no-repeat;
 }
   </style>
</head> 
<body>  
</body>
 
</html>

4. Testing page in Fenix

To test work progress:
- Click on ^HttpServer->Simulation^ 
- <HttpServer> will start
- Go to WebBrowser and type in URL "localhost" or "127.0.0.1"




To be continued

Sunday, August 21, 2016

News in ver. 3.1.9

- Fenix didn't want to write data in S7 DB blocks. Repaired
- During creating Connection default parameters was given (not from windows). Repaired
- Local Help file was replaced by WebSite help.
- Siemens S7 driver all events were connected to ComunnicationView
- CommunicationView added driver name column.
- CommunicationView added amount of record in GridView
- CommunicationView added save to CSV possibility.
- CommunicaionView added save to clipboard possibility
- CommunicationView filtering data possibility (basic)
- Database CSV file export problem with coma for values. Used dot for values only.
- Update OxyPlot 1.0.0.2176 -> 1.0.0.2182
- Update MahApps.Metro 1.3.0.166  -> 1.3.0.188
- Update SC-Script.bin 3.13.2     -> 3.14
- Update TaskScheduler          2.5.20     -> 2.5.21

Wednesday, August 17, 2016

S7 Siemens to Modbus TCP/IP


In this article I will try explain how to push data from Siemens S7 plc to Modbus device. For this purpose I will use Fenix software. To carry data between drivers we will use C# script.

We will have two remote devices:
Siemens PLC [S7Plc] -> 192.168.142.134:102
Modbus Device [ModPlc] -> 192.168.142.134:502

Issue is take data from S7Plc and push to ModPlc. Assigning addresses are shown below:
Var1 DB1.DBD0  -> HoldingRegister [40001]
Var2 DB1.DBD4  -> HoldingRegister [40003]
Var3 DB1.DBD8  -> HoldingRegister [40005]
Var4 DB1.DBD12 -> HoldingRegister [40007]

Now we will create project in Fenix. Start fenix and create new project. Picture below:


Next step is to add two connections to project:


Then we will create device and tags for S7 communication:

We will do the same for Modbus communication:


When we finished you will get something similar like picture below:


When project is created we will set all important parameters. We will create script. Script will be invoked every 50 ms. We must set time default timer for script. 

1. Click on Scripts on Solution.
2. Go to Properties. Click on filed Timers
3. CustomerTimer window will appear. Change default time from 1500 to 50 ms the click OK.

Now add Timer to script to do this:

1. Click on Script.cs on Solution
2. Go to Properties and from ComboBox 03 Script choose Timer.


Now we can write script. Open script in editor and add code:


Code:
Script have 3 methotds. Start() is invoking during start of driver. Stop() is invoking during driver stop. Cycle() is invoking by Timer every 50ms. Script have access to all Tags in project and for that you can use functions:
SetTag("TagName", Value);
GetTag("TagName");

using System;
using ProjectDataLib;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Linq;
using System.IO;

public class Script : ScriptModel
{

    public override void Start()
    {
    }

    public override void Stop()
    {
    }
    public override void Cycle()
    {
        var Var0 = GetTag("S7Var0");
        SetTag("ModVar0",Var0);

        var Var1 = GetTag("S7Var1");
        SetTag("ModVar1",Var1);
           
        var Var2 = GetTag("S7Var2");
        SetTag("ModVar1",Var1);
  
        var Var3 = GetTag("S7Var3");
        SetTag("ModVar3",Var3);
    }
}

And Start communication:

1. Click on Solution on Example1
2. Click on TableView
3. Click to start all communication drivers.