自动控制步序为什么用编码原理的疑问 点击:376 | 回复:1



eagleking68

    
  • 精华:0帖
  • 求助:2帖
  • 帖子:6帖 | 407回
  • 年度积分:44
  • 历史总积分:890
  • 注册:2010年7月15日
发表于:2019-09-02 16:51:33
楼主

以前的到过别人的一个程序,S7-1200螺丝机,程序做的确实调理和有序,做的很规范,但是不明白的是为什么在各个自动步序中也是喜欢先复制后编码译码,这样做有什么好处呢?实在是想不明白,为什么不能直接控制流程控制字或位进行自动流程控制呢?只是好监控吗?不应该吧,无论是三菱还是西门子,大点的程序,看到好多都是这么做的。顺便把编码译码的scl程序贴出来。

Input

StepIn Int 0 非保持 True True True False Step No.

Output

StepNoW1 DWord 16#0 非保持 True True True False Step word1

StepNoW2 DWord 16#0 非保持 True True True False Step word2

StepNoW3 DWord 16#0 非保持 True True True False Step word3

StepNoW4 DWord 16#0 非保持 True True True False Step word4

InOut

Static

StepMaskPos Array[0..31] of DInt 在 IDB 中设置 True True True False

Temp

MaskResult DInt

DecodingOut DInt

StepInBuff DInt

Constant

(*

STEP DECODER

STEP NUMBER:0~127

*)

#StepInBuff := INT_TO_DINT(#StepIn);

#MaskResult := #StepInBuff AND 16#001F;

#DecodingOut := #StepMaskPos[#MaskResult];

#StepNoW1 := 0;

#StepNoW2 := 0;

#StepNoW3 := 0;

#StepNoW4 := 0;

IF NOT #StepIn.%X6 AND NOT #StepIn.%X5 THEN

  // Statement section IF

  #StepNoW1 := DINT_TO_DWORD(#DecodingOut);

  #StepNoW1 := SWAP(#StepNoW1);

END_IF;

IF NOT #StepIn.%X6 AND #StepIn.%X5 THEN

  // Statement section IF

  #StepNoW2 := DINT_TO_DWORD(#DecodingOut);

  #StepNoW2 := SWAP(#StepNoW2);

END_IF;


IF #StepIn.%X6 AND NOT #StepIn.%X5 THEN

  // Statement section IF

  #StepNoW3 := DINT_TO_DWORD(#DecodingOut);

  #StepNoW3 := SWAP(#StepNoW3);

END_IF;

IF #StepIn.%X6 AND #StepIn.%X5 THEN

  // Statement section IF

  #StepNoW4 := DINT_TO_DWORD(#DecodingOut);

  #StepNoW4 := SWAP(#StepNoW4);

END_IF;

输入一个整形变量值,对应的MD中的M位就有了输出。程序调用时这么转换。




eagleking68

  • 精华:0帖
  • 求助:2帖
  • 帖子:6帖 | 407回
  • 年度积分:44
  • 历史总积分:890
  • 注册:2010年7月15日
发表于:2019-09-02 17:01:28
1楼

调用程序是这样的:

"Decoder_DB"(StepIn:="C_StepCount_AX1".CV,

             StepNoW1=>"N_StepNoWord1_AX1",

             StepNoW2=>"N_StepNoWord2_AX1",

             StepNoW3=>"N_StepNoWord3_AX1",

             StepNoW4=>_dword_out_);

其中"C_StepCount_AX1".CV是DB11里面的INT,"N_StepNoWord1_AX1"是%MD1000,"N_StepNoWord2_AX1"是%MD1004,"N_StepNoWord3_AX1"是%MD1008.


热门招聘
相关主题

官方公众号

智造工程师