程序问题3

程序                                     数据类型                  监控初值                 对应关系
L         0                                         int                           0
T     #RET_Ual_receive                     int                           0 
L     #iLADDR                                  int                          160                变频器I地352
L         8
+I                                                                                  168
T     #Startadr                                  word                        168 
L     DBNO                                                                       0
T     #Rett_DB                                  word                          0
LAR2   P##APrec                              Any                          0
L         P##PDB_L2                           pointer                87000080
LAR1                                                                         87000080
L         D[AR1,P#2.0]                                                  84000000
L         P#20.0                                                                  a0
+D                                                                             840000a0
T         LD[AR2,P#6.0]                                                 840000a0
L         W[AR1,P0.0]                                                         190                    DB400
T         #Komm_DB                                                           190
T         LW[AR2,P#4.0]                                                      190
L         20                                                                           14
T         LW[AR2,P#2.0]                                                        14 
L         W#16#1002                                                           1002
T         LW[AR2,P#0.0]                                                      1002

问题补充:
请大侠从"LAR2  P##APrec"开始每句每句解释,越详细越好。还有87000080的初值代表什么?两个“##”是什么?一个“#”是什么?越详细越好,谢谢!

最佳答案

LAR2   P##APrec       //将ANY指针下装到AR2里                      
L         P##PDB_L2                
LAR1                   //将POINTER指针下装到AR1里                                                   
L         D[AR1,P#2.0]    //  D[AR1,P#2.0] 是POINTER对应的数据地址                                       
L         P#20.0                                                          
+D                                                                      
T         LD[AR2,P#6.0]   // 加上20个字节的偏移量后给到 LD[AR2,P#6.0] 也就是ANY指针的地        址里                                           
L         W[AR1,P0.0]     //POINTER里的DB号取出                                                 
T         #Komm_DB        //传给#Komm_DB                                               
T         LW[AR2,P#4.0]   //传给ANY指针DB号                                               
L         20                                                                     
T         LW[AR2,P#2.0]    //将20传给ANY指针的数据长度                                            
L         W#16#1002         //这个值得意思是组合的16#10的是ANY首位字节固定的,02是数据的类型是字节                                         
T         LW[AR2,P#0.0]    //将 W#16#1002传给ANY的首个字   
感觉这段程序就是在根据POINTER的数据来定义ANY指针的,想了解这些程序先明白POINTER和ANY的定义,以及如何运用;
P## 这里的用的是P# 指令值,第二个#是内部变量的一个符号;p# 取指针
S7-300和S7-400寻址:这个资料先学习下,
https://support.industry.siemens.com/cs/document/79632832/s7-300和s7-400寻址?dti=0&lc=zh-CN

提问者对于答案的评价:
我不知道你的解答是不是正确的,特别是“L         P##PDB_L2                           pointer                87000080”这个你没有作答,我是作为感谢作为回报,希望得到西门子专家解答。

最佳答案作者回复:
L         P##PDB_L2    #PDB_L2 是POINTER数据,是在调用这个块时外部给定的指针;87表示是上一级赋值的;#PDB_L2  就是一个指针的存储器,与指定的指针对应起来;具体还是看看材料里的例子,你发的程序里,有POINTER的,也有ANY的。

原创文章,作者:more0621,如若转载,请注明出处:https://www.zhaoplc.com/plc187958.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2017年7月26日 上午2:19
下一篇 2017年7月26日 上午2:19

相关推荐