MCIO 6

Solution Explorer -> MOTION -> add new item -> click NC/PTP configuration -> OK

Axes -> add new item -> continuous Axis -> OK

Axes -> Axis 1 -> settings -> LINK to I/O -> select channel -> OK

RUN in Human interface

Axes -> Axis 1 -> online -> Enable: set all -> F8 reset -> RUN(F1/F2/F3/F4)

Import library

Solution Explorer -> PLC-> project -> REFERENCEs -> add library -> MOTION -> PTP -> add Tc2-NC & Tc2-MC2

---------------------------------
PROGRAM MAIN
VAR
    btn_1 AT %I* : BOOL;
    btn_2 AT %I* : BOOL;

    Axis_B : AXIS_REF;

    McPower : MC_Power;
    McReset : MC_Reset;
    McJoggin : MC_Jog;

    iState : DINT;
END_VAR
---------------------------------

McPower(Axis:=Axis_B , Enable:=TRUE, Enable_Positive:=TRUE, Enable_Negative:=TRUE);
McReset(Axis:=Axis_B);
McJoggin(Axis:=Axis_B);

CASE iState OF
    0: // Initial

        iState := 10;

    10: // Start Drive Reset

        McReset(Axis:=Axis_B, Execute:=TRUE);
        IF McReset.Done THEN
            iState := 20;
        ELSIF McReset.Error THEN
            iState := 999;
        END_IF

    20: // Wait for Drive to Reset

        IF McPower.Status THEN
            iState := 30;
        END_IF

    30: // Wait for Drive command

        McJoggin(Axis:=Axis_B, JogForward:=btn_1);

    999: // Error handle

END_CASE
---------------------------------

series 7 @ 7:47

QUESTION:

  1. remove POUs

  2. restore motor controller when it is error.

  3. after McVelocity stop, it is still rotating.

---------------------------------
PROGRAM MAIN
VAR    
    btn_1 AT %I* : BOOL;

    Axis_B : AXIS_REF;

    McPower : MC_Power;
    McReset : MC_Reset;
    McJoggin : MC_Jog;

    McVelocity : MC_MoveVelocity;
    McStop : MC_Stop;

    CurrentVelocityCMD : DINT;

    iState : DINT;
END_VAR

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

CurrentVelocityCMD := 10;

McPower(Axis:=Axis_B , Enable:=TRUE, Enable_Positive:=TRUE, Enable_Negative:=TRUE);
McReset(Axis:=Axis_B);
McJoggin(Axis:=Axis_B);

CASE iState OF
    0: // Initial

        iState := 10;

    10: // Start Drive Reset

        McReset(Axis:=Axis_B, Execute:=TRUE);
        IF McReset.Done THEN
            iState := 20;
        ELSIF McReset.Error THEN
            iState := 999;
        END_IF

    20: // Wait for Drive to Reset

        IF McPower.Status THEN
            iState := 40;
        END_IF

    30: // Wait for Drive JOG command

        McJoggin(Axis:=Axis_B, JogForward:=btn_1);

    40: // Wait for velocity command

        McVelocity(
            Axis:=Axis_B,
            Velocity:=CurrentVelocityCMD,
            Acceleration:=10000,
            Deceleration:=10000,
            Jerk:=1000000,
            Direction:=MC_Direction.MC_Positive_Direction,
            Execute:=btn_1,
        );

        IF NOT btn_1 THEN
            McVelocity(Axis:=Axis_B,Execute:=FALSE);
            iState := 900;
        END_IF

    900: // stop servor

        McStop(Axis:=Axis_B, Execute:=TRUE);
        IF btn_1 THEN
            McStop(Axis:=Axis_B, Execute:=FALSE);
            iState := 40;
        END_IF

    999: // Error handle

END_CASE

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

Last updated

Was this helpful?