Creating function block library

canaanp
2012-04-23
2012-04-26
  • canaanp - 2012-04-23

    Hello, I'm new to this forum and not sure where to ask this question...

    I am using SoMachine, and I have created a custom function block for motor control. The function block is written in CFC format. I would like to share this with other people, namely co-workers so they can use the function block in their own programs. However, I want the function block to remain unmodified. The only way I have been led to believe this is possible is by inserting it into the library? I have attempted to do this, but cannot seem to get a working result. I am wondering if there is any documentation regarding this, or if someone can give me a bit of direction. Schneider does not have very good documentation on this topic. I have also searched the forum for an example of the same issue, but I have not seen any posts for it. Any help or information is greatly appreciated.

    Thanks

     
  • pnn - 2012-04-24

    Try this way:

    File -> New -> do not select a target (leave in 'None') -> OK

    Create a new FB and paste your code, or export from another project and import in to this one.

    Then File -> SaveAs -> Codesys internal library. Click 'Edit licensing info' and configure it as you like, then save.

    I tested this with a very simple FB and it works.

     
  • canaanp - 2012-04-24

    pnn hat geschrieben:
    File -> New -> do not select a target (leave in 'None') -> OK
    Create a new FB and paste your code, or export from another project and import in to this one.
    Then File -> SaveAs -> Codesys internal library. Click 'Edit licensing info' and configure it as you like, then save.
    I tested this with a very simple FB and it works.

    You must not be using SoMachine, because there is nothing like that in this program.
    I have taken some screen shots to show what I'm working with...
    From the main screen of SoMachine, there is no file menu:

    When I start an empty project, I get to the programming screen. This is where I would normally see the project tree on the left, but since it's an empty project with no target device, I get nothing in the tree. Since there is no application, I cannot add a POU, or import an existing item... in the screen shot it looks like I can add something, however when I do, nothing appears in the tree.

    Not sure what to do here. If I start a standard project, I'm asked to choose a device first, which a version of the Modicon M258 is already selected, which is what I'm using anyway... Once that is done, I get the full tree on the left, and can import items, etc. However this is what I have already done before. What I don't understand is once my function block is in the library, when I choose it, there is no way to actually bring it into the application. All I can do is highlight it. Under the properties, where on other function blocks it shows specific details about it, mine shows nothing. I'm leaving something out here, but I can't tell where.

    IMG: SoMachine

    IMG: SoMachine

    IMG: SoMachine

     
  • pnn - 2012-04-25

    yes, I don't use SoMachine. This seems to be some vendor-customized version of Codesys, with some features changed or removed.
    Anyway, if you can't do it without selecting a target device, then try to create an empty project with target device, import your FB and save as a library.

    BTW in the last screenshot I see 'POU..' and 'External file' in the context menu, so maybe you can add or import a POU into an empty device-less project.

     
  • canaanp - 2012-04-25

    I tried that right away, it seems to allow the importing, and reports that it was successful, yet nothing shows in the tree. I will try again and then add a device afterwards to see if it then reveals the imported items. I have tried to save as a library, it that seems to work as well, however when I view the library entry in another project, the function block does not show the inputs and outputs, or graphical representation like it does for the timer TON function block, for example.

     
  • singleton - 2012-04-26

    In the last screenshot there is only the device view visible. Go to "View --> POUs" to show the POU tree.
    This is where you have to place objects for a library. After that you can sav it as *.library.

     
  • canaanp - 2012-04-26

    singleton hat geschrieben:
    In the last screenshot there is only the device view visible. Go to "View --> POUs" to show the POU tree.
    This is where you have to place objects for a library. After that you can sav it as *.library.

    Wow thank you so much! I never caught that. I changed the view to POUs and imported my function block and saved into the library. Finally, the library entry matches what other entries show as far as variables listed, documentation, etc. That made the difference. I guess it has to come from an empty project in order to work correctly in the library.

    Thanks again

     

Log in to post a comment.