步进电机在1200上的使用

配置轴

  • 步进主要控制的是脉冲和方向。配置1200端,用MC指令,先配置轴的常规和驱动器。

此处若不填“使能输出”,可以在程序管脚填写。
步进电机的方向和脉冲输出点,如果是1200PLC,必须用PLC本体上的Q点。

步进主动回原点,参考点上下侧和回原点方向要一致,不然原点开关得电后,回反方向转动到零位置。

  • 细分是定义一圈的脉冲数,在规定范围内细分越大,精度越高。
  • 设置完驱动器参数,需要断电重启。
  • 步进定位识别上升沿控制。

写指令

  • 固化的FB如下,一些外围的变量作为配合HMI和控制模式使用;FB需使用还需要调用并填写接口
REGION 逻辑处理
    // 手动
    #"Jog+Hand" := #In_Mode.ManualMode AND #"In_Jog+Condition" AND #H_Collection.ButtonAndStatus."Jog+Hand";
    #"Jog-Hand" := #In_Mode.ManualMode AND #"In_Jog-Condition" AND #H_Collection.ButtonAndStatus."Jog-Hand";
    //自动
    #"Jog+Auto" := #In_Mode.AutoMode AND #"In_Jog+Condition" AND #"In_JogAuto+Condition" AND #"In_Jog+AutoStart";
    #"Jog-Auto" := #In_Mode.AutoMode AND #"In_Jog-Condition" AND #"In_JogAuto-Condition" AND #"In_Jog-AutoStart";
    //Home
    #JogHome := #In_Mode.ManualMode AND #In_HomeCondition AND (#H_Collection.ButtonAndStatus.Step_Home OR #In_Mode.HomeMode);
END_REGION

REGION 速度处理
    // JOG速度:
    IF #"Jog+Hand" OR #"Jog-Hand" OR #JogHome THEN
        #Velocity := #H_Collection.ButtonAndStatus.InputValue_JogVel;
    ELSIF #"Jog+Auto" OR #"Jog-Auto" THEN
        #Velocity := #H_Collection.ButtonAndStatus.InputValue_Set_AbsVel;
    ELSE
        #Velocity := 0;
    END_IF;
    
END_REGION

REGION 步进电机
    // Statement section REGION
    //**************************步进使能****************************
    #MC_Power_Instance(Axis := #In_Axis,
                       Enable := #In_Enable,
                       StartMode := #In_MC_Power_StartMode,
                       StopMode := #In_MC_Power_StopMode,
                       Status => #Out_Step_Enable.Status,
                       Busy => #Out_Step_Enable.Busy,
                       Error => #Out_Step_Enable.Error,
                       ErrorID => #Out_Step_Enable.ErrorID,
                       ErrorInfo => #Out_Step_Enable.ErrorInfo);

    //***************************步进复位****************************
    #MC_Reset_Instance(Axis := #In_Axis,
                       Execute := #In_Mode.Reset,
                       Restart := #In_MC_Reset_Restart,
                       Done => #Out_Step_Reset.Done,
                       Busy => #Out_Step_Reset.Busy,
                       Error => #Out_Step_Reset.Error,
                       ErrorID => #Out_Step_Reset.ErrorID,
                       ErrorInfo => #Out_Step_Reset.ErrorInfo);
    
    //*****************************步进回原点**************************
    #MC_Home_Instance(Axis := #In_Axis,
                      Execute := #JogHome,
                      Position := #In_MC_Home_Position,
                      Mode := #In_MC_Home_Mode,
                      Done => #Out_Home.Done,
                      Busy => #Out_Home.Busy,
                      CommandAborted => #Out_Home.CommandAborted,
                      Error => #Out_Home.Error,
                      ErrorID => #Out_Home.ErrorID,
                      ErrorInfo => #Out_Home.ErrorInfo,
                      ReferenceMarkPosition => #Out_Home.ReferenceMarkPosition);
    
    //*****************************步进JOG*******************************
    #MC_MoveJog_Instance(Axis := #In_Axis,
                         JogForward := (#"Jog+Hand" OR #"Jog+Auto"),
                         JogBackward := (#"Jog-Hand" OR #"Jog-Auto"),
                         Velocity := #Velocity,
                         PositionControlled := #In_MC_MoveJog_PositionControlled,
                         InVelocity => #Out_JOG.inVelocity,
                         Busy => #Out_JOG.Busy,
                         CommandAborted => #Out_JOG.CommandAborted,
                         Error => #Out_JOG.Error,
                         ErrorID => #Out_JOG.ErrorID,
                         ErrorInfo => #Out_JOG.ErrorInfo);
    
    //***************************步进绝对定位***************************
    #MC_MoveAbsolute_Instance(Axis := #In_Axis,
                              Execute := #In_MC_MoveAbsolute_Excute,
                              Position := #H_Collection.ButtonAndStatus.InputValue_Set_AbsPosition,
                              Velocity := #Velocity,
                              Direction := #In_MC_MoveAbsolute_Direction,
                              Done => #Out_Absolute.Done,
                              Busy => #Out_Absolute.Busy,
                              CommandAborted => #Out_Absolute.CommandAborted,
                              Error => #Out_Absolute.Error,
                              ErrorID => #Out_Absolute.ErrorID,
                              ErrorInfo => #Out_Absolute.ErrorInfo);
    
    //***************************暂停轴***********************************
    #MC_Halt_Instance(Axis := #In_Axis,
                      Execute := #In_Enable,
                      Done => #Out_Halt.Done,
                      Busy => #Out_Halt.Busy,
                      CommandAborted => #Out_Halt.CommandAborted,
                      Error => #Out_Halt.Error,
                      ErrorID => #Out_Halt.ErrorID,
                      ErrorInfo => #Out_Halt.ErrorInfo);
    
END_REGION

//*****************************反馈*******************************
REGION 反馈
    #Out_ActualVelocity := #In_Axis.ActualVelocity;
    #Out_ActualPosition := #In_Axis.ActualPosition;
    
END_REGION


//**********************************报警**************************

IF #In_StepAlarm THEN
    #Out_Alarm := TRUE;
ELSIF NOT #In_StepAlarm AND #In_Mode.Reset THEN
    #Out_Alarm := FALSE;
END_IF;

//**********************************HMI Collection**************************
//输出
#H_Collection.Step_Enable := #Out_Step_Enable;
#H_Collection.Step_Reset := #Out_Step_Reset;
#H_Collection.Home := #Out_Home;
#H_Collection.JOG := #Out_JOG;
#H_Collection.Absolute := #Out_Absolute;
#H_Collection.Halt := #Out_Halt;
#H_Collection.ButtonAndStatus.ActualVelocity := #In_Axis.ActualVelocity;
#H_Collection.ButtonAndStatus.ActualPosition := #In_Axis.ActualPosition;
  • 注意1:MC_POWER要一直调用才行,并保证该指令在MOTION CONTROL指令前面调用:

    • StartMode=0 : 启用位置不受控的定位轴
    • StartMode=1 : 启用位置受控的定位轴
    • StopMode=0 : 紧急停止, 轴将以组态的急停减速度进行制动
    • StopMode=1 : 立即停止,PLC会立即停止发脉冲
    • StopMode=2 : 带有加速度变化率控制的紧急停止,如果激活了加速度变化率控制,会将已组态的加速度变化率考虑在内,减速曲线变得平滑。
  • 注意2:停止轴:

    • 方法1:上升沿触发运动后,是不会停下来的。把速度写0,再触发一下上升沿指令。就可以停下来了。
    • 方法2:使用MC_Halt停止轴指令。注意一点,停止轴,可以用MC-Halt,但是用完它,必须复位MC-Reset才可以再用。
  • 本案例在实际调用时部分接口使用情况参考:

posted @ 2025-03-01 23:35  你要去码头整点薯条吗  阅读(164)  评论(0)    收藏  举报