simotion scout st语言编程 点击:3236 | 回复:5



大梅子

    
  • 精华:0帖
  • 求助:18帖
  • 帖子:25帖 | 75回
  • 年度积分:0
  • 历史总积分:71
  • 注册:2009年11月12日
发表于:2015-05-23 10:42:35
楼主

各位大侠请棒我翻译一下这个到底什么意思,最好是每行每行解释,非常感谢

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




liufile

  • 精华:0帖
  • 求助:0帖
  • 帖子:2帖 | 20回
  • 年度积分:0
  • 历史总积分:96
  • 注册:2008年11月02日
发表于:2015-09-15 11:25:37
1楼

这是个回零的功能块。功能块名称,定义接口数据类型,有SIMOTION的预设数据,也有在全局变量中自定义的结构。程序是判断与轴关联的电机情况和轴数据判断执行回零动作。

  • 精华:0帖
  • 求助:1帖
  • 帖子:1帖 | 4回
  • 年度积分:0
  • 历史总积分:132
  • 注册:2007年11月15日
发表于:2015-12-21 16:59:27
2楼

顺序执行,用MCC更简单,

估计是老外的一个标准应用,中的一个FB

武哥

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 103回
  • 年度积分:0
  • 历史总积分:81
  • 注册:2013年7月15日
发表于:2019-09-25 18:09:31
3楼

DCC能不能完成这样的功能呢 

喝喝88

  • 精华:0帖
  • 求助:0帖
  • 帖子:0帖 | 4回
  • 年度积分:0
  • 历史总积分:4
  • 注册:2016年6月12日
发表于:2019-12-18 22:40:09
4楼

FUNCTION_BLOCK FB_Incremental_Homing
        VAR_INPUT                                     //定义输入
            i_toAxis : PosAxis;                      //位置轴赋值变量i_toAxis

            i_sCMD   : StructAxisOpe;         //轴操作数据结构轴赋值给变量i_sCMD

            i_sPara  : StructAxisPara;          //轴特性数据结构轴赋值给变量i_sPara

        END_VAR                                    //结束输入变量声明
        VAR                                            //声明临时变量
            l_i16CaseCount             : INT   := 0;      //l_i16CaseCount =0       

            _MccRetDINT                : DINT;            //_MccRetDINT为双整数

            RT_increment_home_rtrig    : R_TRIG; //R_TRIG为你程序里定义点数据类型

        END_VAR

        RT_increment_home_rtrig(clk := i_sCMD.boAxisIncreHoming);

//给函数 RT_increment_home_rtrig 输入实参 i_sCMD.boAxisIncreHoming 

        CASE l_i16CaseCount OF           //case选择语句
            0:                                          //选择器0,执行下列语句
                    l_i16CaseCount := 1;    //l_i16CaseCount为1时执行选择器1

          

            1:                                       //选择器1,执行下列语句

                IF i_toAxis.control = Active AND
                      i_toAxis.actormonitoring.drivestate = Active AND 
                      i_toAxis.actormonitoring.Power = Active THEN
                   l_i16CaseCount := 10;     //l_i16CaseCount为10时执行选择器10

                END_IF;
            
            10:                                               //选择器10,执行下列语句

                IF (RT_increment_home_rtrig.q) THEN
                    l_i16CaseCount := 11;       //l_i16CaseCount为11时执行选择器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

                                 
                     
            12:                                              //选择器12,执行下列语句

                IF i_toAxis.motionstatedata.stillstandvelocity = active THEN
                    l_i16CaseCount := 16;  //l_i16CaseCount为16时执行选择器16

                END_IF;
                
            16:                                 //选择器16,执行下列语句

                l_i16CaseCount := 17; //l_i16CaseCount为17时执行选择器17

            
            17:                          //选择器17,执行下列语句

                l_i16CaseCount := 0;
                        
            END_CASE;

    END_FUNCTION_BLOCK

这个函数块看起来很简单啊,得看你里面点变量是啥,才知道干嘛用的


zsy

  • 精华:0帖
  • 求助:0帖
  • 帖子:7帖 | 64回
  • 年度积分:28
  • 历史总积分:769
  • 注册:2018年7月31日
发表于:2019-12-25 13:19:32
5楼


引用 liufile 的回复内容: 这是个回零的功能块。功能块名称,定义接口数据类型,有S...

-------------------------



热门招聘
相关主题

官方公众号

智造工程师