Device related functions - in library or in Main Program ?

naganathas
2012-07-23
2012-08-20
  • naganathas - 2012-07-23

    Hi,

    I'm trying to develop a library for a new PLC device. I had created a project (Main program) in ST for reading the Inputs from the Digital IO board of a PLC device. Now, I want to make this project as library. While doing that i'm getting errors as i have the PLC device topology in the main program and also in the library.
    If I remove the device topology from the library the functions like EtherCAT_Master.xConfigured are not linked to the device.

    Kindly, suggest me where I should have the (PLC) device related functions Eg: EtherCAT_Master.FirstSlave ?
    in library or in Main calling program ?

     
  • shooter - 2012-07-27

    Use the main program only to call subprograms
    you can also use tasks when timing is needed, but in these tasks again use calls for the structure.

    And when you program a device use a function block with some inputs /outputs as main and do all programming inside the function block (even CFC is possible)

    have the function blocks in a library, this way if any change in a function it will be changed in every program.

    There is one caution on this:
    when you have downloaded to a PLC, copy everything (including the LIBS) at that moment.
    This is the only way you can get online with the PLC the program and the libs must be complete equal
    I make a USB stick everytime i compile the program. And yes i give it to the customer (he does not have the knowledge to change but i tell him he can go anywhere to change this program when i am not in business anymore)

     
  • balajimct - 2012-08-20

    Hi,

    If i want to do the same thing, I do as below

    1. Create the complete program with all the functions required and test it first with the device
    2. Change the program to Function Block and and assign all the Inputs and Output Variables, But don't configure any device
    3. Save the program as a external library (i.e. .lib) instead of saving as .pro file, But remember all the libraries you have used in the FB
    4. Save all the libraries in a particular directory to avoid the confusion
    5. When you want to use it in the main program just add the library to Library Manager and call the same, then in the main program you can configure the device as you want

    Advantages by using as FB in LIB
    1. You can call as many times you want depending upon the usage
    2. You can protect all your code by using a password to library

     

Log in to post a comment.