恭喜,你发布的帖子
发布于 2024-05-17 18:06:07
8楼
全球论坛网友给出的某回复:
In the PC programming world, you are attempting to access "private" data with a public API. The In/Out/InOut parameters of a block are supposed to define values available outside the block.
Accessing private data (static FB tags) can cause problems, and in the future, some PLC firmware and/or Portal version or service pack / hotfix may break your PLC code that has been running fine with this external messing around with private data.
There are exceptions, like certain PID block DB values - but they are documented in the PID block's Help information.
Enabling external access to static tags is there because there are times it might make sense. However, Siemens reserves the right to default that to NO ACCESS in the future and they are cautioning us against using it. They may default it to read-only, but even so, we should pass static tags to OUT parameters if we as the developers/programmers want people to access them outside the block.
The problem can be that an FB that is executed in a cyclic interrupt OB and gets interrupted by other interrupting OB that just happens to access that FB's static tags and modifies or reads it at the wrong time could make bad decisions.
Let's say at the start of the FB, the static tag is read, assigned to an FB temp tag and then set to some other value used for internal multi-step (multi network or SCL line) calculation.
Now some interrupting OB accesses that static tag right after it has been reset and acts on that value as if the FB had just completed its calculations and assigned a final value - the start value for the next call to that FB.
Bad things can happen. Now, let's say static tag was assigned to an OUT right before the FB exits.
The "Out" will have distinct and correct values and never "intermediate calculation" values.
It is predictable and can provide better deterministic operations.
请填写推广理由:
分享
只看
楼主