<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to Device related functions - in library or in Main Program ?</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/31a4e4e9ea/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/31a4e4e9ea/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/31a4e4e9ea/</id><updated>2020-02-27T20:33:13.582000Z</updated><subtitle>Recent posts to Device related functions - in library or in Main Program ?</subtitle><entry><title>Device related functions - in library or in Main Program ?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/31a4e4e9ea/?limit=25#e25b" rel="alternate"/><published>2020-02-27T20:33:13.582000Z</published><updated>2020-02-27T20:33:13.582000Z</updated><author><name>balajimct</name><uri>https://forge.codesys.com/u/balajimct/</uri></author><id>https://forge.codesys.com60f3f10123405ab6ddc945ac64d2aebc01b0a7d1</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;If i want to do the same thing, I do as below&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create the complete program with all the functions required and test it first with the device&lt;/li&gt;
&lt;li&gt;Change the program to Function Block and and assign all the Inputs and Output Variables, But don't configure any device&lt;/li&gt;
&lt;li&gt;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&lt;/li&gt;
&lt;li&gt;Save all the libraries in a particular directory to avoid the confusion&lt;/li&gt;
&lt;li&gt;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&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Advantages by using as FB in LIB&lt;br/&gt;
1. You can call as many times you want depending upon the usage&lt;br/&gt;
2. You can protect all your code by using a password to library&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Device related functions - in library or in Main Program ?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/31a4e4e9ea/?limit=25#23fd" rel="alternate"/><published>2020-02-27T20:33:11.920000Z</published><updated>2020-02-27T20:33:11.920000Z</updated><author><name>shooter</name><uri>https://forge.codesys.com/u/shooter/</uri></author><id>https://forge.codesys.comb5a4b1257a80307d4886f73635eec0a61b285677</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Use the main program only to call subprograms&lt;br/&gt;
you can also use tasks when timing is needed, but in these tasks again use calls for the structure.&lt;/p&gt;
&lt;p&gt;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)&lt;/p&gt;
&lt;p&gt;have the function blocks in a library, this way if any change in a function it will be changed in every program.&lt;/p&gt;
&lt;p&gt;There is one caution on this:&lt;br/&gt;
when you have downloaded to a PLC, copy everything (including the LIBS) at that moment.&lt;br/&gt;
This is the only way you can get online with the PLC the program and the libs must be complete equal&lt;br/&gt;
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)&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>Device related functions - in library or in Main Program ?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/31a4e4e9ea/?limit=25#04e5" rel="alternate"/><published>2020-02-27T20:33:10.012000Z</published><updated>2020-02-27T20:33:10.012000Z</updated><author><name>naganathas</name><uri>https://forge.codesys.com/u/naganathas/</uri></author><id>https://forge.codesys.com7ed9cc77424d13a5c52c1ea13573f770f004943c</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;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.&lt;br/&gt;
 If I remove the device topology from the library the  functions like EtherCAT_Master.xConfigured are not linked to the device.&lt;/p&gt;
&lt;p&gt;Kindly, suggest me where I should have the (PLC) device related functions Eg: EtherCAT_Master.FirstSlave ? &lt;br/&gt;
 in library or in Main calling program ?&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>