美文网首页
台达DVP15/50MC之FB_CamReadWrite

台达DVP15/50MC之FB_CamReadWrite

作者: TomatoTor | 来源:发表于2019-11-14 01:35 被阅读0次

    fb_CamReadWrite

    功能块声明

    范围 名称 数据类型 注释
    VAR_INPUT UsiAxisCamTable USINT 凸轮表号
    VAR_INPUT UsiCamPointCount USINT 凸轮点
    VAR_INPUT bCamReadExe BOOL 读取触发
    VAR_INPUT bCamWriteExe BOOL 写入触发
    VAR_OUTPUT bCamReadDone BOOL 读取完成
    VAR_OUTPUT bCamWriteDone BOOL 写入完成
    VAR UsiAxisNumber USINT
    VAR AxisCamReadPoint ARRAY[1..10] OF DMC_CamReadPoint 读取凸轮点功能块
    VAR AxisCamWritePoint ARRAY[1..10] OF DMC_CamWritePoint 写入凸轮点功能块
    VAR AxisCamSet DMC_CamSet 凸轮表生效功能块
    VAR UsiCamRead USINT
    VAR UsiCamWrite USINT

    功能块程序

    IF EDGEPOS(bCamReadExe) THEN
        UsiCamRead   := 1 ;
        bCamReadDone := FALSE ;
        bCamWriteExe := FALSE ;
    END_IF;
    IF  bCamReadExe THEN
        WHILE UsiCamRead < UsiCamPointCount DO 
            AxisCamReadPoint[UsiCamRead]();
            AxisCamReadPoint[UsiCamRead].CamTable        := UsiAxisCamTable ;
            AxisCamReadPoint[UsiCamRead].CamChangedPoint := TRUE ;
            AxisCamReadPoint[UsiCamRead].CamPointNum     := UsiCamRead ;
            AxisCamReadPoint[UsiCamRead].Execute         := TRUE ;
            IF AxisCamReadPoint[UsiCamRead].Done THEN
                UsiCamRead := UsiCamRead + 1 ;
            END_IF;
        END_WHILE;
        bCamReadDone := TRUE ;
        IF bCamReadDone THEN
            FOR UsiAxisNumber := 1 TO 10 BY 1 DO 
                AxisCamReadPoint[UsiAxisNumber].Execute     := FALSE ;  
            END_FOR;
        END_IF;
        bCamReadExe  := FALSE ;
    END_IF;
    
    IF EDGEPOS(bCamWriteExe) THEN
        UsiCamWrite   := 1 ;
        bCamWriteDone := FALSE ;
        bCamReadExe   := FALSE ;
    END_IF;
    IF bCamWriteExe THEN
        WHILE UsiCamWrite < UsiCamPointCount  DO 
            AxisCamWritePoint[UsiCamWrite]();
            AxisCamWritePoint[UsiCamWrite].CamTable    := UsiAxisCamTable ;
            AxisCamWritePoint[UsiCamWrite].CamPointNum := UsiCamWrite ;
            AxisCamWritePoint[UsiCamWrite].Execute     := TRUE ;
            IF AxisCamWritePoint[UsiCamWrite].Done THEN
                UsiCamWrite := UsiCamWrite + 1 ;
            END_IF;
        END_WHILE;
        AxisCamSet.CamTable := UsiAxisCamTable ;
        AxisCamSet.Execute  := TRUE ;
        IF AxisCamSet.Done THEN
            FOR UsiAxisNumber := 1 TO 10 BY 1 DO 
                AxisCamWritePoint[UsiCamWrite].Execute  := FALSE ;          
            END_FOR;
            bCamWriteDone       := TRUE ;   
            AxisCamSet.Execute  := FALSE ;
            bCamWriteExe        := FALSE;
        END_IF; 
    END_IF;
    
    AxisCamSet();
    

    Pro_CamReadWrite

    程序变量

    范围 名称 地址 数据类型
    VAR ActAxisCamRW ARRAY[1..32] OF fbCamRW
    VAR UsiAxisNumber USINT
    VAR RETAIN g_UiMasterPos %MW2000 ARRAY[1..32,1..10] OF UINT
    VAR RETAIN g_UiSlavePos %MW2500 ARRAY[1..32,1..10] OF UINT

    程序内容

    //需要多少轴就调用多少
    ActAxisCamRW[1]();
    
    IF g_bFrameCtrl_CamReadExe THEN
        ActAxisCamRW[g_UsiCamTableChoice].UsiAxisCamTable   := g_UsiCamTableChoice ; 
        ActAxisCamRW[g_UsiCamTableChoice].UsiCamPointCount  := g_UsiCamPoint ; 
        ActAxisCamRW[g_UsiCamTableChoice].bCamReadExe       := TRUE ;
        FOR UsiAxisNumber := 1 TO 10 BY 1 DO 
            g_UiMasterPos[g_UsiCamTableChoice,UsiAxisNumber] := LREAL_TO_UINT(In:= ActAxisCamRW[g_UsiCamTableChoice].AxisCamReadPoint[UsiAxisNumber].MasterPos) ;
            g_UiSlavePos[g_UsiCamTableChoice,UsiAxisNumber]  := LREAL_TO_UINT(In:= ActAxisCamRW[g_UsiCamTableChoice].AxisCamReadPoint[UsiAxisNumber].SlavePos) ;
        END_FOR;
        IF ActAxisCamRW[g_UsiCamTableChoice].bCamReadDone THEN
            ActAxisCamRW[g_UsiCamTableChoice].bCamReadExe   := FALSE ;
            g_bFrameCtrl_CamReadExe                         := FALSE ;
        END_IF;
    ELSIF g_bFrameCtrl_CamWriteExe THEN
        ActAxisCamRW[g_UsiCamTableChoice].UsiAxisCamTable   := g_UsiCamTableChoice ; 
        ActAxisCamRW[g_UsiCamTableChoice].UsiCamPointCount  := g_UsiCamPoint ; 
        FOR UsiAxisNumber := 1 TO 10 BY 1 DO 
            ActAxisCamRW[g_UsiCamTableChoice].AxisCamWritePoint[UsiAxisNumber].MasterPos := UINT_TO_LREAL(In:= g_UiMasterPos[g_UsiCamTableChoice, UsiAxisNumber]);
            ActAxisCamRW[g_UsiCamTableChoice].AxisCamWritePoint[UsiAxisNumber].SlavePos  := UINT_TO_LREAL(In:= g_UiSlavePos[g_UsiCamTableChoice, UsiAxisNumber]);       
        END_FOR;
        ActAxisCamRW[g_UsiCamTableChoice].bCamWriteExe := TRUE ;
        IF ActAxisCamRW[g_UsiCamTableChoice].bCamWriteDone THEN
            ActAxisCamRW[g_UsiCamTableChoice].bCamWriteExe := FALSE ;
            g_bFrameCtrl_CamWriteExe                       := FALSE ;   
        END_IF;
    ELSE
        g_bFrameCtrl_CamReadExe  := FALSE ;
        g_bFrameCtrl_CamWriteExe := FALSE ;
    END_IF;
    

    Log:
    2019-11-14 发布本文

    相关文章

      网友评论

          本文标题:台达DVP15/50MC之FB_CamReadWrite

          本文链接:https://www.haomeiwen.com/subject/bbdlictx.html