回复:simotion伺服控制实例

axg2008

  • 帖子

    627
  • 精华

    1
  • 被关注

    37

论坛等级:侠圣

注册时间:2003-07-26

白金 白金 如何晋级?

发布于 2019-04-17 15:14:33

1楼

下面的Axismove是我写的最简单的例子,可以参考  


 PROGRAM AxisMove

        //input x [1\2\3\4\5\6\7\8\29] select the axis

        //booncestart=1 active the axis then set home 0

        //setvalue mubiaoposition=100.0,then boOnceFinish=1,the axis start position

        //boOnceFinish falldown trig,then stop and inactive the axis

        

        VAR_TEMP

            

            myRetDINT : DINT;

        END_VAR

        

        VAR 

            fe1, fe2          : F_TRIG;

            re1, re2          : R_TRIG;

            

            myRetBool         : ARRAY[0..7] OF BOOL;

            

            arrayPositionAxis : ARRAY[1..29] OF posAxis;

        END_VAR

        

            arrayPositionAxis[1]  := IndexConveyor;

            arrayPositionAxis[2]  := IndexConveyor;

            arrayPositionAxis[3]  := IndexConveyor;

            arrayPositionAxis[4]  := IndexConveyor;

            arrayPositionAxis[5]  := IndexConveyor;

            arrayPositionAxis[6]  := IndexConveyor;

            arrayPositionAxis[7]  := IndexConveyor;

            arrayPositionAxis[8]  := IndexConveyor;

            arrayPositionAxis[9]  := QuickConveyor;

            arrayPositionAxis[10]  := PressConveyor1;

            arrayPositionAxis[11]  := PressConveyor2;

        

     IF xx >= 1 AND xx<= 11 AND boOnceStart THEN

         IF arrayPositionAxis[xx].control = INACTIVE THEN //轴是否已激活

    

        myRetDINT :=

    _enableaxis(

        axis := arrayPositionAxis[xx] 

        // ,enablemode := ALL

        // ,servocontrolmode := ACTIVE

        // ,servocommandtoactualmode := INACTIVE

        // ,nextcommand := IMMEDIATELY

        // ,commandid := (0,0)

        // ,forcecontrolmode := INACTIVE

        // ,stwbitset := 0

        // ,movingmode := DO_NOT_CHANGE

); 

         END_IF;

         re1( clk := arrayPositionAxis[xx].control = ACTIVE); 

     

        

         IF re1.q THEN //轴是否已激活


myRetDINT :=

    _homing(

        axis := arrayPositionAxis[xx]

         ,homingmode := DIRECT_HOMING

         ,homepositiontype := DIRECT

        // ,homeposition := 0.0

        // ,velocitytype := USER_DEFAULT

        // ,velocity := 100.0

        // ,positiveacceltype := USER_DEFAULT

        // ,positiveaccel := 100.0

        // ,negativeacceltype := USER_DEFAULT

        // ,negativeaccel := 100.0

        // ,positiveaccelstartjerktype := USER_DEFAULT

        // ,positiveaccelstartjerk := 100.0

        // ,positiveaccelendjerktype := USER_DEFAULT

        // ,positiveaccelendjerk := 100.0

        // ,negativeaccelstartjerktype := USER_DEFAULT

        // ,negativeaccelstartjerk := 100.0

        // ,negativeaccelendjerktype := USER_DEFAULT

        // ,negativeaccelendjerk := 100.0

        // ,velocityprofile := USER_DEFAULT

        // ,mergemode := SEQUENTIAL

        // ,nextcommand := IMMEDIATELY

        // ,commandid := (0,0)

);

         END_IF;

         IF arrayPositionAxis[xx].control = ACTIVE AND 

            arrayPositionAxis[xx].positioningstate.homed = yes AND

            boOnceFinish THEN //轴已激活,已归零,启动定位


myRetDINT :=

    _pos(

        axis := arrayPositionAxis[xx]

        // ,direction := USER_DEFAULT

        // ,positioningmode := ABSOLUTE//relative

        ,position := mubiaoposition

        // ,velocitytype := USER_DEFAULT

        // ,velocity := 100.0

        // ,positiveacceltype := USER_DEFAULT

        // ,positiveaccel := 100.0

        // ,negativeacceltype := USER_DEFAULT

        // ,negativeaccel := 100.0

        // ,positiveaccelstartjerktype := USER_DEFAULT

        // ,positiveaccelstartjerk := 100.0

        // ,positiveaccelendjerktype := USER_DEFAULT

        // ,positiveaccelendjerk := 100.0

        // ,negativeaccelstartjerktype := USER_DEFAULT

        // ,negativeaccelstartjerk := 100.0

        // ,negativeaccelendjerktype := USER_DEFAULT

        // ,negativeaccelendjerk := 100.0

        // ,velocityprofile := USER_DEFAULT

        // ,blendingmode := USER_DEFAULT

        // ,mergemode := SEQUENTIAL

        // ,nextcommand := IMMEDIATELY

        // ,commandid := (0,0)

);

         END_IF;

    fe1( clk := boOnceFinish);    

    

IF  arrayPositionAxis[xx].control = ACTIVE AND 

    arrayPositionAxis[xx].motionstatedata.motionstate = STANDSTILL AND 

    fe1.q THEN

myRetDINT := _stop(axis := arrayPositionAxis[xx], stopmode := STOP_AND_ABORT );

myRetDINT := _disableaxis(axis := arrayPositionAxis[xx], disablemode := ALL );

boOnceStart :=FALSE;

END_IF;


END_IF;

     ;   

    END_PROGRAM


评论
编辑推荐: 关闭

请填写推广理由:

本版热门话题

SIMOTION

共有2232条技术帖

相关推荐

热门标签

相关帖子推荐

guzhang

恭喜,你发布的帖子

评为精华帖!

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

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

  • 分享

  • 只看
    楼主

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