相同逻辑的程序做成FB后总是异常出错

已锁定

mkas

  • 帖子

    125
  • 精华

    2
  • 被关注

    12

论坛等级:侠士

注册时间:2013-08-04

普通 普通 如何晋级?

相同逻辑的程序做成FB后总是异常出错

384

3

2018-09-10 20:27:33

整个项目和MES对接,有20个工位在加工前都要扫码请求MES查询能不能加工,做完都要将做的结果和过程数据上传给MES,本来是将查询 和 上传做成两个FB,结果有时候收不到MES的响应。后来就直接写在工位的自动流程中,就没有出现收不到响应的情况。我反复研究了自己程序,感觉都不应该出问题。请大家看看,FB查询的程序如下:

TYPE "UDT_ACC_LOAD"

VERSION : 0.1

   STRUCT

      PLC : Struct   // PLC -> ACC - Part type changeover control flags

         PartTypeID : Int;   // Part type ID extracted from part type description

         Component_0 : String[100];   // Serial number - Housing(string -> struct)

         Component_1 : String[100];   // Serial number - Component(string -> struct)

         Component_2 : String[100];   // Serial number - Component(string -> struct)

         Component_3 : String[100];   // Serial number - Component(string -> struct)

         Component_4 : String[100];   // Serial number - Component(string -> struct)

      END_STRUCT;

      ACC : Struct   // ACC -> PLC - Loading process control flags

         ErrorCode : Int;   // Process error code

         ErrorMsg : String[50];   // Error message(string -> struct)

         StatusBits : DInt;   // The StatusBits set by the PLC and by the ACC rework PC

         Cycle_ID : DInt;   // The Cycle_ID of the machine

         Unit_ParttypeID : Int;   // The designated parttype ID for the loaded product unit in ACC

      END_STRUCT;

   END_STRUCT;


END_TYPE


FUNCTION_BLOCK "ACC_Load"

{ S7_Optimized_Access := 'TRUE' }

VERSION : 0.1

   VAR_INPUT 

      iReset : Bool;

      iPartTypeID : Int;

      iCode : String[100];

   END_VAR


   VAR_OUTPUT 

      oLoad_OK : Bool;

      oLoad_NOK : Bool;

      oLoad_ReworkOK : Bool;

      oLoad_NOKByPass : Bool;

      oLoad_TimeOut : Bool;

      oError_Code : Int;

      oLoad_Msg : String[50];

      o_Status : Int;

   END_VAR


   VAR_IN_OUT 

      ioACC_Com_PLC_Load_0 : Bool;

      ioACC_Com_ACC_Load_0 : Bool;

      ioACC_Com_ACC_Load_1 : Bool;

      ioACC_Com_ACC_Load_2 : Bool;

      ioACC_Com_ACC_Load_3 : Bool;

      ioACC_Load : "UDT_ACC_LOAD";

      ioRequest : Bool;

   END_VAR


   VAR 

      s_Step : Int;

      s_Delay : Int;

   END_VAR



BEGIN

IF #iReset AND #o_Status <> 0 THEN

    #o_Status := 0;

    #ioACC_Com_PLC_Load_0 := 0;

    #s_Step := 0;

END_IF;

CASE #s_Step OF

    0:

        #oLoad_NOK := 0;

        #oLoad_OK := 0;

        #oLoad_ReworkOK := 0;

        #oLoad_NOKByPass := 0;

        #oLoad_TimeOut := 0;

        #oError_Code := 0;

        #oLoad_Msg := '';

        #s_Delay := 0;

      

        IF #ioRequest THEN

            #ioRequest := 0;

            #s_Step := 1;

        END_IF;

    1:

        #ioACC_Com_PLC_Load_0 := 0;

        #ioACC_Com_ACC_Load_0 := 0;

        #ioACC_Com_ACC_Load_1 := 0;

        #ioACC_Com_ACC_Load_2 := 0;

        #ioACC_Com_ACC_Load_3 := 0;

        #ioACC_Load.ACC.ErrorCode := 0;

        #ioACC_Load.ACC.ErrorMsg := '';

        #ioACC_Load.PLC.Component_0 := '';

        #ioACC_Load.PLC.Component_1 := '';

        #ioACC_Load.PLC.Component_2 := '';

        #ioACC_Load.PLC.Component_3 := '';

        #ioACC_Load.PLC.Component_4 := '';

        #ioACC_Load.PLC.PartTypeID := 0;

        #s_Delay := #s_Delay + 1;

        IF #s_Delay >= 20 THEN

            #s_Delay := 0;

            #s_Step := 2;

        END_IF;

   2:     

        #ioACC_Load.PLC.PartTypeID := #iPartTypeID;

        #ioACC_Load.PLC.Component_0 := #iCode;

        #ioACC_Com_PLC_Load_0 := 1;

        #s_Step := 3;

    3:

        IF #ioACC_Com_ACC_Load_0 THEN

            #oLoad_OK := 1;

            #oError_Code := 0;

            #oLoad_Msg := 'PartType Loading OK';

            #s_Step := 4;

            

        ELSIF #ioACC_Com_ACC_Load_1 THEN

            #oLoad_NOK := 1;

            #oError_Code := #ioACC_Load.ACC.ErrorCode;

            #oLoad_Msg := #ioACC_Load.ACC.ErrorMsg;

            #s_Step := 4;

            

        ELSIF #ioACC_Com_ACC_Load_2 THEN

            #oLoad_ReworkOK := 1;

            #oError_Code := 0;

            #oLoad_Msg := 'PartType loading OK for rework';

            #s_Step := 4;

            

        ELSIF #ioACC_Com_ACC_Load_3 THEN

            #oLoad_NOKByPass := 1;

            #oError_Code := 0;

            #oLoad_Msg := 'PartType loading NOK,it is not this station part';

            #s_Step := 4;

            

        ELSE

            #s_Delay := #s_Delay + 1;

            IF #s_Delay >= 1000 THEN

                #s_Delay := 0;

                #oLoad_TimeOut := 1;

                #o_Status := 1;

                #oError_Code := 9999;

                #oLoad_Msg := 'PartType loading timeout';

                #s_Step := 5;

            END_IF;

        END_IF;

       

    4:

        

            #ioACC_Com_PLC_Load_0 := 0;

            #s_Step := 0;

END_CASE;

END_FUNCTION_BLOCK



相同逻辑的程序做成FB后总是异常出错 已锁定
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMATIC S7-1500系列

共有10587条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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