Variable array issue!

2017-02-01
2017-02-21
  • yannickasselin1 - 2017-02-01

    Hi,

    I seem to have found some kind of bug using the new variable arrays.
    It works fine when using simple arrays or simple arrays of FBs.
    When using an array of FBs which contain another array of FBs, you start having problems.
    I'll try to be clear:
    Let's say you have an FB named FB1 and another FB named FB2.
    You create an array of FB2 inside FB1 and then you create an array of FB1.
    You also create a FB named FB_Manager which expects a variable array of FB1 as VAR_IN_OUT.
    Inside FB_Manager, if you try to iterate through every FB1, it works fine.
    But if you try to iterate through every FB2 which are inside FB1, it seems to always use the first index of the array of FB2.

    When using an FB_Manager that expects a pointer to FB1 instead of a variable array, everything works fine.

    I have included an export of a project I have done to test this. (I hope this will work as it is not clear to me what is the best way to export Codesys project. I'm used to TwinCAT 3).

    In the project, there is a fbManagerPointer (which uses a pointer) and a fbManagerVariableArray. The code inside is exactly the same. the only difference is that one of them expects a pointer to FB1 and the other expects a variable array of FB1.

    fb1_1 is passed to fbManagerPointer and fb1_2 is passed to fbManagerVariableArray.

    If you open both of these (fb1_1 and fb1_2), you will see that the results are different.
    They should NOT be different.
    fb1_1 is the expected result. fb1_2 is buggy!

    I think I'll start using pointers again until this is fixed!

    TestVariableArray.zip [10.82 KiB]

     
  • Anonymous - 2017-02-19

    Originally created by: scott_cunningham

    I cannot open your attachment. I believe your export is specific to TwinCAT, so people using other brands cannot open a TwinCAT project. As an alternative, you should be able to export the modules in question (FB1 and FB2 and a program showing the error) using PLCopenXML (software that conforms to PLCopen are required to support PLCopen export and import).

    If that is not possible, then screen shots for graphical languages or copy paste text when using ST.

    As always, try to create the simplest example with the problem to eliminate "distractions".

     
  • yannickasselin1 - 2017-02-20

    It is not a TwinCAT project. It is a Codesys project and I did an export of it. If you unzip the file, you should get a .export which you should be able to import in a new Codesys project. I'm not sure what is the best way to share projects with Codesys. In TwinCAT, I usually do a save as archive. It works fine but this feature seems to be specific to TwinCAT.

    If it still does not work I could probably zip the project folder.

     
  • Anonymous - 2017-02-20

    Originally created by: scott_cunningham

    I run an OEM version of CoDeSys but revived an error trying to import the file. Yes, I unzipped it. Sorry

     

Log in to post a comment.