回复:外部程序或HMI访问 FB 中的static 变量

已锁定

'Razor

西门子1847工业学习平台

  • 帖子

    3208
  • 精华

    41
  • 被关注

    222

论坛等级:至圣

注册时间:2008-03-31

钻石 钻石 如何晋级?

发布于 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.


少即是多
评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-1200系列

共有15112条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

快扫描右侧二维码晒一晒吧!

再发帖或跟帖交流2条,就能晋升VIP啦!开启更多专属权限!

  • 分享

  • 只看
    楼主

top
您收到0封站内信:
×
×
信息提示
很抱歉!您所访问的页面不存在,或网址发生了变化,请稍后再试。