iec61131-3structured-text

How do I program an Interpolated Position Mode sequence in IEC-61131 Structured Text using the Maxon EPOS Libraries?


The Maxon EPOS libraries define some Function Blocks that seemingly handle Interpolated Position Mode, however there are no samples, as far as I can determine, that specify how to use them.

Here is what I have so far but at the moment it just skips right through it when called with Execute set to TRUE

FUNCTION_BLOCK FB_MAIN_Routine1

TYPE
    POSITIONS: ARRAY[1..64] OF DINT;
    VELOCITIES: ARRAY[1..64] OF DINT;
    TIME_VALUES: ARRAY[1..64] OF USINT;
END_TYPE

VAR_EXTERNAL
    Axis1: AXIS_REF;
END_VAR

VAR_INPUT
    Execute: BOOL;
END_VAR

VAR_OUTPUT
    Done: BOOL;
END_VAR

VAR

    Start: BOOL := FALSE;    
    LoadPointsAx1: BOOL := FALSE;

    fbClearIpmBufferAx1: MU_ClearIpmBuffer;
    fbAddPvtValuesAx1: MU_AddPvtValues;
    fbStartIpmTrajectoryAx1: MU_StartIpmTrajectory;
    fbGetIpmStatusAx1: MU_GetIpmStatus;
    fbGetIpmTrajectoryStatusAx1: MU_GetIpmTrajectoryStatus;

    PositionsAx1:  POSITIONS  := [49500, 47703, 45906, 44109, 42312, 40516, 38719, 36922, 35125, 33329, 31532, 29735, 27938, 26142, 24345, 22548, 20751, 21834, 23037, 24240, 25443, 26646, 27848, 29051, 30254, 31457, 32660, 33863, 35065, 36268, 37471, 38674, 39877, 41080, 42282, 43485, 44688, 45891, 47094, 48297, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500, 49500];    
    VelocitiesAx1: VELOCITIES  := [-216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, -216, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
    TimeValuesAx1: TIME_VALUES := [250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 250, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];

END_VAR

fbGetIpmStatusAx1(Axis := Axis1, Enable := Execute);

fbClearIpmBufferAx1(Axis := Axis1, Execute := Execute);

If fbClearIpmBufferAx1.Done Then    
    LoadPointsAx1 := TRUE;
END_IF;

fbAddPvtValuesAx1(Axis := Axis1, Execute := LoadPointsAx1, Position := PositionsAx1, Velocity := VelocitiesAx1, TimeValue := TimeValuesAx1);

If fbAddPvtValuesAx1.Done Then    
    Start := TRUE;
End_If; 

fbStartIpmTrajectoryAx1(Axis := Axis1, Execute := Start);

fbGetIpmTrajectoryStatusAx1(Axis := Axis1, Enable := fbStartIpmTrajectoryAx1.Done);

If (Execute = FALSE) Or fbGetIpmTrajectoryStatusAx1.TargetReached Then
    Done := Execute;
    Start := FALSE;
    LoadPointsAx1 := FALSE;
    fbAddPvtValuesAx1(Axis := Axis1, Execute := FALSE);
    fbStartIpmTrajectoryAx1(Axis := Axis1, Execute := FALSE);
    fbGetIpmTrajectoryStatusAx1(Axis := Axis1, Enable := FALSE);
End_If;

END_FUNCTION_BLOCK

Solution

  • Unlike other moves of operation (e.g. Velocity Mode or Position Mode), Interpolated Position Mode needs to be initialised.

    A call to MU_ActivateInterpolatedPositionMode solves this.