8/17/2022 7:23 PM | |
Joined: 3/30/2020 Last visit: 8/6/2024 Posts: 4669 Rating: (969) |
Hello. The short answer: No, constants cannot be used outside the entity in which it was created. Longer answer: The symbols created under the CONST parameters are not tags. Those a re placeholders. In compile time the placeholders are replaced with the constants that it represents. The symbols are not in actual use in the loaded (online) program. Moving those symbols to the STAT parameters will immediately have the effect that you are looking for. But the downside is that it is also writeable. The negative I personally do not see as much of an issue. Motivation: STAT tags in an FB is per definition suppose to be 'private'. Yet we are left to have our designs enforce the rule or abuse it. I workaround (apply to S7-1200 / S7-1500) that I use: Create a UDT with the symbol names and constant values. Next I use the UDT in a TEMP tag. That temporary tag takes on the values as defined by the UDT each time the code block is scanned. Caution: this tag is also writable. The next workaround is to create a read-only DB that contains the constant values. The DB is linked to the relevant code block via an in-out tag. ~ |
Activities of this user is voluntary. There is no obligation or liability placed on this user. Though optional, your 'please' and 'thank you' is highly valued. |
|
8/18/2022 9:47 AM | |
Joined: 8/3/2021 Last visit: 8/2/2024 Posts: 120 Rating: (3) |
"I workaround (apply to S7-1200 / S7-1500) that I use: Create a UDT with the symbol names and constant values. Next I use the UDT in a TEMP tag. That temporary tag takes on the values as defined by the UDT each time the code block is scanned." Can't understand. Can you post some example? |
TIA Portal V13/14/16 |
|
8/18/2022 11:44 AM | |
Joined: 3/30/2020 Last visit: 8/6/2024 Posts: 4669 Rating: (969) |
Hi Petr. Let me know if the picture helps. |
Activities of this user is voluntary. There is no obligation or liability placed on this user. Though optional, your 'please' and 'thank you' is highly valued. |
|
This contribution was helpful to1 thankful Users |
8/18/2022 1:27 PM | |
Joined: 8/3/2021 Last visit: 8/2/2024 Posts: 120 Rating: (3) |
Ok, I think I got it: - I declare global UDT as struct with Integer parts every one with number +1 than previous one; - I use this UDT to declare TEMP variable inside my FB; - as soon as the FB starts execution TEMP variable exists and I can "call" it and use for status test; when using I select one or another part of UDT by struct part identifier "UDTvar.part1" that has defined value different than other parts; - if I want use status of my FB and test it in parent FB that calls my child FB I should transfer actual state outside my FB (by OUT for example) and declare TEMP var UDT type in interface of parent FB; that way I can use THIS status not only in child and parent FBs but globally everywhere... |
TIA Portal V13/14/16 |
|
Follow us on