西门子PLC寄存器AR1和AR2使用重要事项_第1页
西门子PLC寄存器AR1和AR2使用重要事项_第2页
西门子PLC寄存器AR1和AR2使用重要事项_第3页
西门子PLC寄存器AR1和AR2使用重要事项_第4页
全文预览已结束

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

.1、 STEP7使用的AR1地址寄存器来访问FC接口(包括in out 和inout)以及FB接口的复杂型参数,如array、struct date_and_time.这就是我们为什么在FC接口中使用out型参数访问DB1.DBXX会出现错误,因为AR1寄存器不能完全描述DB1.DBXX地址,完全描述需要6长度字节。2、 FC FB 本质上一样调用FB相当于在FC里opn di ,并使用ar2来索引变量FB的优点是数据块里的变量可按名字使用,仅仅是显示而已,执行效率和fc一样3、 fb中为了方便背景数据块参数的寻址,自动使用ar2寄存器,ar2寄存器指向背景数据块的首地址p#dbx0.0,如果改变了这个寄存器的值,你再访问背景数据块参数时将不会得到正确的数值.所以,在fb里使用ar2寄存器要小心,对这两个寄存器改变后不要再使用背景数据块参数,当要使用背景数据块参数时要先恢复这两个寄存器的值。有一个常用的用法是多重背景fb的接口参数的寻址用法,需要用到ar2:(因为在多重背景中,变量的地址并不是其在背景数据块中的绝对地址,而是其相对于ar2的偏移地址),所以:在多重背景fb中,如果要得到某变量variable在背景数据块中的绝对地址,可以使用以下代码:tar2/将地址寄存器装入累加器ac1(偏移量),也就是多重背景fb中第一个变量在背景数据块中的地址。addw#16#00ffffff/关闭区域idlp#variable/装载变量的地址+d/加上偏移量和变量地址lar1/将结果保存到地址寄存器ar1中Notes on Changing the Contents of RegistersIf you use the programming options below together with the registers and accumulators listed, you must make sure you restore the contents of the registers or accumulators yourself, otherwise errors may occur. 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, DB20.DBW10) as an actual parameter for a function (FC) Function block (FB) and multiple-instance callsStructure components of a formal parameter as an address within an FC or FBStructure components of a formal parameter as an actual parameter for an FC or FBWith 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 point

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论