Multiple applications on one device sharing variables.

clarenced
2025-02-20
2025-03-06
  • clarenced - 2025-02-20

    I am looking for an example of how to run 2 applications on 1 device that would have global variables shared between the two apps. In this case what I am trying to do is to have the main program logic run as one application and then have the visualization run as a second application. I find this https://us.store.codesys.com/media/n98_media_assets/files/000013-F/0/Multiple%20Applications_en.pdf, that talks about exactly what I want to do, but I can't find the download.

    The main reason I want to do this is for download speed. Right now it takes at least a minute to download our application to the PLC. A simple program downloads to the PLC in a very short time, but add visualization and the download time gets much longer. If I could download the program separately from the visualization I think that a simple program change would take very little time to download.

    I have tried create a GVL in the POUs view. This partly works in that both applications can see the GVL, but they each create their own instance of it and the variables are not shared between the two apps.

    There are ideas of using OPCUA but this raises problems with licensing and having to move any variable that needs to be shared into the Symbol Configuration. This adds a lot of management to keep this up to date.

    Any ideas would be appreciated thanks.

     
    • Strucc.c

      Strucc.c - 2025-02-28

      I don't exactly recall where (I think some release notes), but I read the information that this multiple application / sub application feature is to be discontinued. Please, correct me, if I'm not right about this

      I am a bit sad about that - I was using that feature with more or less success. However I understand the reason behind the change: it introduces huge complexity, especially when dealing with multicore and safety support...

      AS I understand, it's to be replaced with the new virtual plc architecture, and standard ways for synchronizing / sharing data...

      So, for now the "Add application" context menu item was removed, but behind the scene it is still supported...


      Hint: if you still want to experiment with it, might try copy-paste things within the PLCLogic tree...

       
  • ojz0r - 2025-02-20

    One thing you could do is create an object with the variable as field with a function and procedure to get the variable (read) and set the variable (write). These are then called from your program and the vizualization.

     
    • clarenced - 2025-02-20

      Sounds feasible, but how would I create this object so that both applications would use the same instance of it.

      If this did work, it's still not really the solution I am looking for as it would mean mapping every variable I want to use on the hmi through this object vs I was hopping all the GVL variables would be available.

       
  • clarenced - 2025-03-06

    I got this working using OPC UA. In the logic application I just added a Symbol Configuration. In the HMI application I added a Data Sources Manager and OPC UA Data Source.

    The one thing I don't like is the way the tags end up being named in the HMI application. In the logic application I have a program named PLC_PRG. It has a variable named testDINT. In the HMI application the name I get for this variable is DeviceSet.CODESYS_Control_Win_V3_x64.Resources.Logic.Programs.PLC_PRG.testDINT.
    This is very long and looks like it could change if I used this on a different device type. Any ideas how I could get this name shortened down to just PLC_PRG.testDINT like it is on the Logic application?

     

    Last edit: clarenced 2025-03-06
  • clarenced - 2025-03-06

    I got this working using OPC UA. In the logic application I just added a Symbol Configuration. In the HMI application I added a Data Sources Manager and OPC UA Data Source.

    The one thing I don't like is the way the tags end up being named in the HMI application. In the logic application I have a program named PLC_PRG. It has a variable named testDINT. In the logic application the name I get for this variable is DeviceSet.CODESYS_Control_Win_V3_x64.Resources.Logic.Programs.PLC_PRG.testDINT.
    This is very long and looks like it could change if I used this on a different device type. Any ideas how I could get this name shortened down to just PLC_PRG.testDINT like it is on the Logic application?

     

Log in to post a comment.