Author Topic: S7-1200 PROJECT  (Read 2713 times)

fabiocampion

  • Newbie
  • *
  • Posts: 2
    • View Profile
S7-1200 PROJECT
« on: September 06, 2016, 03:53:07 PM »
Hello!

First of all id like to thanks Archie by the amazing work that he is doing here!

I have a  cliente that need to exchange an old HMI and i am planing to use advanced HMI to do de JOB... The thing is that ADVANCED HMI do not have the drive for such PLC (Ok.... S7-1200 can handle MODBUS TCP but the client CPU is the first model FW1.0 so the modbus blocks do not work).

The question is:

Is possible to use Advanced HMI with a custom communication drive (S7.net/LIBNODAVE/SNAP7)?
What would be the best way to read and write to advanced HMI controls?
I had sucess working with S7.NET for a quickly test.

Here is the sample of the code that i used to read some values...

Code: [Select]
         private void timer1_Tick(object sender, EventArgs e)
        {
            using (var Plc = new S7.Net.Plc(S7.Net.CpuType.S71200, "192.168.1.100", 0, 1))
            {
                Plc.Open();

                bool db1Bool0 = (bool)Plc.Read("DB150.DBX0.0");
                label1.Text = System.Convert.ToString(db1Bool0);

                bool db1Bool1 = (bool)Plc.Read("DB150.DBX0.1");
                label2.Text = System.Convert.ToString(db1Bool1);

                bool db1Bool2 = (bool)Plc.Read("DB150.DBX0.2");
                label3.Text = System.Convert.ToString(db1Bool2);

                bool db1Bool3 = (bool)Plc.Read("DB150.DBX0.3");
                label4.Text = System.Convert.ToString(db1Bool3);

                ushort db150Real1 = (ushort)Plc.Read("DB150.DBW18");
                label5.Text = System.Convert.ToString(db150Real1);

               
            }
        }

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: S7-1200 PROJECT
« Reply #1 on: September 06, 2016, 04:56:27 PM »
The AdvancedHMI controls can work with any of the AdvancedHMI drivers because of a common set of properties and methods as defined by the IComComponent interface. The OpcDaCom allows OPC drivers to work by creating a wrapper that works as a converter from an OPC driver to an AdvancedHMI driver by implementing the IComComponent interface.

This can theoretically be done with any 3rd party driver. Depending on how differently the 3rd party driver work in comparison to AdvancedHMI drivers, it could potentially be a major task. The most difficult part would be implementing subscriptions because this is done on a background thread.

If you wanted to get an idea of how to do this, take a look at the OmronBase.vb file in the AdvancedHMIDrivers project. You could potentially start with a copy of this driver and modify the key routines to use a driver like SNAP7.

For example, the function BeginRead is an asynchronous read. In that function, you would use SNAP7 to perform a synchronous read. When the data is returned, create a new instance of the NfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs, put the data in that object, then call DataLinkLayerDataReceived and pass the object to it.

To complete all of this may take days to weeks, but in the end you would have an AdvancedHMI compatible driver that would allow you to build HMIs without having to write code.

fabiocampion

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: S7-1200 PROJECT
« Reply #2 on: September 07, 2016, 01:42:35 PM »
Thanks for te reply Archie!

That seens really complicated... I was thinking about try to trick the controls.

There is no way to read and write direct to a variable?


Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5262
    • View Profile
    • AdvancedHMI
Re: S7-1200 PROJECT
« Reply #3 on: September 07, 2016, 03:58:18 PM »
You could read values using the driver then set the properties of the controls with the value using code as you have in your example code. But this would not leverage anything in AdvancedHMI. Since every read and write would require code writing, your application would become very code heavy. You would also have to use timers or threads to keep the controls updated which is normally done via subscriptions.