simotion st编程

各位大侠帮帮忙,解释一下这个功能块的作用,最好是一行一行的解释。正在学习中,实在不知道怎么办了。。
FUNCTION_BLOCK FB_Incremental_Homing
        VAR_INPUT
            i_toAxis : PosAxis;
            i_sCMD   : StructAxisOpe;
            i_sPara  : StructAxisPara;
        END_VAR
        VAR
            l_i16CaseCount             : INT   := 0;
            _MccRetDINT                : DINT;            
            RT_increment_home_rtrig    : R_TRIG;
        END_VAR

        RT_increment_home_rtrig(clk := i_sCMD.boAxisIncreHoming);

        CASE l_i16CaseCount OF           
            0: 
                    l_i16CaseCount := 1;
           

            1: 
                IF i_toAxis.control = Active AND
                      i_toAxis.actormonitoring.drivestate = Active AND 
                      i_toAxis.actormonitoring.Power = Active THEN
                   l_i16CaseCount := 10;
                END_IF;
            
            10:
                IF (RT_increment_home_rtrig.q) THEN
                    l_i16CaseCount := 11;
                END_IF;                         
                
            11:
                _MccRetDINT := _homing(axis             := i_toAxis, 
                                       homingMode       := ACTIVE_HOMING, 
                                       homePositionType := DIRECT, 
                                       homePosition     := i_sPara.r64IncZeroOffset, 
                                       velocityType     := DIRECT, 
                                       velocity         := i_sPara.r64IncHomingVelocity, 
                                       velocityProfile  := TRAPEZOIDAL, 
                                       mergeMode        := IMMEDIATELY, 
                                       nextCommand      := WHEN_BUFFER_READY, 
                                       commandId        := _getCommandId());
                l_i16CaseCount := 12;                                          
                     
            12:
                IF i_toAxis.motionstatedata.stillstandvelocity = active THEN
                    l_i16CaseCount := 16;
                END_IF;
                
            16: 
                l_i16CaseCount := 17;
            
            17: 
                l_i16CaseCount := 0;
                        
            END_CASE;

    END_FUNCTION_BLOCK

问题补充:
我知道这是类似于pascal的一种语言,整个架构我懂得,只是不明白这个功能。字面上解释是定义一个功能块,叫点动回原点。

最佳答案

FUNCTION_BLOCK FB_Incremental_Homing :定义一个功能块,类似STEP7中FB块
        VAR_INPUT                                             :定义输入变量
            i_toAxis : PosAxis;                                :这里总共定义了三个输入变量,和STEP7
            i_sCMD   : StructAxisOpe;                    :中的FB块的INPUT是一个道理。
            i_sPara  : StructAxisPara;
        END_VAR
        VAR                                                            :定义临时变量,只能在本程序段中调用
            l_i16CaseCount             : INT   := 0;        :定义一个整数类型
            _MccRetDINT                : DINT;               :定义一个双整数
            RT_increment_home_rtrig    : R_TRIG;    :定义一个上升沿
        END_VAR

        RT_increment_home_rtrig(clk := i_sCMD.boAxisIncreHoming); 上升沿由                i_sCMD.boAxisIncreHoming触发, RT_increment_home_rtrig.q只会在一个扫描周期为1
        
        CASE l_i16CaseCount OF           :case语句,
            0: 
                    l_i16CaseCount := 1;         :如果 l_i16CaseCount =0,执行
                                                                   l_i16CaseCount =1

            1:                                                :如果l_i16CaseCount =1执行下面的语句
                IF i_toAxis.control = Active AND      :IF判断语句
                      i_toAxis.actormonitoring.drivestate = Active AND 
                      i_toAxis.actormonitoring.Power = Active THEN
                   l_i16CaseCount := 10;        :满足上面三个条件时  l_i16CaseCount := 10
                END_IF;                                            
    
            10:          :如果l_i16CaseCount =10执行下面的语句
                IF (RT_increment_home_rtrig.q) THEN   :前面定义了这个上升沿的动作
                    l_i16CaseCount := 11;        执行 l_i16CaseCount := 11
                END_IF;  
                       
               
            11:  等于11时开始执行回原点,这是一个系统的功能块,直接调用
                _MccRetDINT := _homing(axis             := i_toAxis, 
                                       homingMode       := ACTIVE_HOMING, 
                                       homePositionType := DIRECT, 
                                       homePosition     := i_sPara.r64IncZeroOffset, 
                                       velocityType     := DIRECT, 
                                       velocity         := i_sPara.r64IncHomingVelocity, 
                                       velocityProfile  := TRAPEZOIDAL, 
                                       mergeMode        := IMMEDIATELY, 
                                       nextCommand      := WHEN_BUFFER_READY, 
                                       commandId        := _getCommandId());
                l_i16CaseCount := 12;  执行完,赋值 l_i16CaseCount := 12                                        
                     
            12:  这是判断上面的动作是否完成
                IF i_toAxis.motionstatedata.stillstandvelocity = active THEN
                    l_i16CaseCount := 16;  赋值16
                END_IF;
                
            16: 
                l_i16CaseCount := 17;
            
            17: 
                l_i16CaseCount := 0;  全

提问者对于答案的评价:
非常感谢

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

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2017年6月9日 下午5:17
下一篇 2017年6月9日

相关推荐