Are there macros in codeis 3.5?

Papik
2021-01-18
2021-01-19
  • Papik

    Papik - 2021-01-18

    Hello everybody.

    I recently migrated from codesys 2.3 to codesys 3.5.
    In codesys 2.3, I used macros to organize my project, I hid some parts of my code that perform a similar function in macros, so there were only a few macros in PLC_PRG that contained the code. Therefore, the program worked quickly.

    Now for codesys 3.5, I have all the code in PLC_PRG at once and I did not find a way to create a macro in it and place parts of the code that perform similar functions there to optimize the project. Therefore, when I connect to the PLC, the codesys freezes for 10 minutes. Please tell me how this is done in codesys 3.5? And is it possible?

     
  • i-campbell

    i-campbell - 2021-01-18

    Which language are you using?
    In SFC you right click one of the objects and select insert macro after.
    For ST, you would right click in the device tree and add an action or method. Really this works for any of the languages.

     
    • Papik

      Papik - 2021-01-18

      I use CFC language

       
    • Papik

      Papik - 2021-01-18

      as I understand there are no macros in 3.5 at all. For cfc, do I need to hide parts of the code in action? Will the action in another action work? What other tips for optimizing project performance can you give?

       
      • dFx

        dFx - 2021-01-19

        No idea if it is ok with CFC, but with ST/LD/SFC you can split your code in different routines and then call each one when needed (for exemple, do a Main PRG, and call conditionnaly every other PRG from there).

         
        • Papik

          Papik - 2021-01-19

          At the moment, I did as the first person advised. I split my program into actions that perform similar functions. If this is the only way to optimize the body of the program in codesys 3.5.

          It's just not very convenient, to get inside the block you need to find it in the project tree. In codesys 2.3, I used macros and when the project was running, you could go inside and so get to the right place.

          I could also give a name as a comment to the macro and it was very convenient. Why did they remove this functionality?

           

Log in to post a comment.