8/9/2018 10:46 AM | |
Posts: 6 Rating: (0) |
Hi, The machine I'm programming has over 200 valves and motors. To provide the "data" I use InOut of the function block so it works with pointers, lot faster for big amounts of data But I still have a lot of boolean signals (like enable) wich are the same for all blocks but need to be checked every cycle. Is it adviced to keep using a boolean as normal Input of the function block? Or is it better to create ONE UDT with that Bool inside and pass it as pointer? This is what I think:
Is my logic correct? Or does the compiler do some work for you? ------------------------------------------------------------------------------------------ |
Last edited by: BenDevos at: 8/9/2018 10:50:16 AMLast edited by: Jen_Moderator at: 8/9/2018 12:26:21 PMNew subject after splitting |
|
8/9/2018 3:27 PM | |
Joined: 7/7/2010 Last visit: 5/17/2024 Posts: 14751 Rating: (2377)
|
Are you having problems with scan time and want to optimize, or are you optimizing without a problem just because you want to achieve the fastest possible scan time even if your project does not require it? The reason I ask is optimizing without a need is a waste of energy. The compiler helps us out greatly by performing many optimizations for us (at least for s7-1200/1500) since it does not compile to STL and run that. It compiles down to the CPU level for us. That said, I understand you want to know the answer to a question and with > 200 valves and 200 motors, you can easily check for yourself the answer to your question. Is it faster to have bool's passed as Input parameters to multi-instance FBs, or as part of some shared UDT InOut to those same FBs? Personally, I think for this, it might come down to which option tells whoever is looking at the logic what the FB does. To me, passing InOut's means they _could_ be changed within the FB, so extra care must be taken if they are not to be changed. Passing them as Inputs increases the programming data security because the FB cannot change those inputs no matter how hard it tries. Is this at all useful to your question? Is this a scholarly question, or do you really have a need to optimize to this level because your PLC is under-powered? It is far less expensive to upgrade to the next higher level PLC than to spend time (and money) developing the logic to support an obfuscation of intent with a related potential loss of data integrity.
|
science guy |
|
This contribution was helpful to1 thankful Users |
8/10/2018 1:22 PM | |
Joined: 3/27/2012 Last visit: 6/9/2023 Posts: 32 Rating: (10) |
Dear BenDevos, if you ask, how is it adviced to make your code, please read this document. The main idea is: code should be error-free and fast for understanding by other programmer. |
Last edited by: Jen_Moderator at: 8/13/2018 8:44:04 AMOptimized link. |
|
This contribution was helpful to1 thankful Users |
Follow us on