1、 STEP7使用的AR1地址寄存器来访问FC接口(包括in out 和
inout)以及FB接口的复杂型参数,如array、struct date_and_time.这就是我们为什么在FC接口中使用out型参数访问会出现错误,因为AR1寄存器不能完全描述地址,完全描述需要6长度字节。
2、 FC FB 本质上一样调用FB相当于在FC里opn di ,并使用ar2
来索引变量FB的优点是数据块里的变量可按名字使用,仅仅是显示而已,执行效率和fc一样
3、 fb中为了方便背景数据块参数的寻址,自动使用ar2寄存器,
ar2寄存器指向背景数据块的首地址p#,如果改变了这个寄存器的值,你再访问背景数据块参数时将不会得到正确的数值.所以,在fb里使用ar2寄存器要小心,对这两个寄存器改变后不要再使用背景数据块参数,当要使用背景数据块参数时要先恢复这两个寄存器的值。
有一个常用的用法是多重背景fb的接口参数的寻址用法,需要用到ar2:(因为在多重背景中,变量的地址并不是其在背景数据块中的绝对地址,而是其相对于ar2的偏移地址),所以:在多重背景fb中,如果要得到某变量variable在背景数据块中的绝对地址,可以使用以下代码: tar2
Using the following higher-language constructions may cause the contents of the DB register and address register AR1 to be modified:
Fully-qualified DB access (for example, as an actual parameter for a function (FC)
Function block (FB) and multiple-instance calls
Structure components of a formal parameter as an address within an FC or FB
Structure components of a formal parameter as an actual parameter for an FC or FB
With FB, FC, and multiple-instance calls, you should not use the RLO or accumulator 1 or 2 as additional (implicit) parameters.
The DI register and address register AR2 are used on the system side for the FB and multiple-instance calls and should not therefore be modified within FBs.
Address register AR1 is used by some of the loadable standard blocks.
The command \"L P#parameter_name\" loads the address offset of the specified parameter within an FB, relative to address register AR2. In order to determine the absolute offset in the instance data block in multiple-instance type FBs, you must also add the area-internal pointer (address only) of the AR2 register to this value.
在FC接口访问复杂数据重写了AR1和DB寄存器:
Step7英文帮助说明访问也会修改。