McePosTableUpdateLoadIndex

0.2.0

Update the PosTable LoadIndex.

Version history

0.2.0

  Rioual

Changes

Changed:
  • Replace posTableMode by allowQueuing
  • Replace nQAmax by QA_MAX as a constant
show full history

0.1.0-beta

  Rioual

Changes

Added:
  • initial version

Overview

kindnametypedefaultcomment
inputallowQueuingBOOLallow queuing the next motions
inputfirstMoveBOOLcalc first move after system was reset
inputstopAfterLastEntryBOOLcontinue to the start of PosTable when searching for the next Index and LoadIndex
inputindexINTPosTable index for current motion
in_outposTableMcePosTableDatatrajectory to be processed by PosTable
in_outQAINTallowed Queueing Amount; number of motions to queue (for smooth motion)
in_outloadIndexINTPosTable index for loading next motion(s)

Details

allowQueuing

BOOL

Allow queuing the next motions.

valueexplanation
0QA is decreased at the end of each motion until 0
1QA is updated depending on the number of remaining entries until standstill

firstMove

BOOL

Must be True when calculating the first motion of the PosTable.

False otherwise.

stopAfterLastEntry

BOOL

Continue to the start of PosTable when searching for the next Index and LoadIndex if False.

index

INT

The PosTable index to update the LoadIndex from.

Trajectory to be processed by PosTable.

QA

INT

The Queueing Amount is the number of motions allowed to be queued.

Queueing motion in advance is necessary for smooth motion.

loadIndex

INT

Index of the last pre-loaded motion.

It is calculated as follow:

LoadIndex := Index + QA;

Source code

Declarations

(*Update the PosTable LoadIndex; for sending next motion*)
FUNCTION McePosTableUpdateLoadIndex

(*
 * -----------------------------------------------------------------------------
 * Name               : McePosTableUpdateLoadIndex
 * Version            : 0.2.0
 * Date               : 2024-02-29
 * Author             : Rioual
 * Family             : YaskawaMce
 * Organisation       : github.com/YaskawaEurope/mlx-examples
 * 
 * -----------------------------------------------------------------------------
 * Update the PosTable LoadIndex; for sending next motion
 * -----------------------------------------------------------------------------
 *)

VAR_INPUT
  allowQueuing : BOOL; (*allow queuing the next motions*)
  firstMove : BOOL; (*calc first move after system was reset*)
  stopAfterLastEntry : BOOL; (*continue to the start of PosTable when searching for the next Index and LoadIndex*)
  index : INT; (*PosTable index for current motion*)
END_VAR

VAR_IN_OUT
  posTable : McePosTableData; (*trajectory to be processed by PosTable*)
  QA : INT; (*allowed Queueing Amount; number of motions to queue (for smooth motion)*)
  loadIndex : INT; (*PosTable index for loading next motion(s)*)
END_VAR

VAR
  nPosTableSize : INT; (*number of entries*)
  nEntriesRemaining : INT; (*number of entries remaining*)
END_VAR

VAR CONSTANT
  QA_MAX : INT := LIMIT(1, GVL.NR_OF_INSTANCES - 1, 20); (*max Queueing Amount; max number of motions which can be queued*)
END_VAR

Logic

nPosTableSize := UINT_TO_INT(SIZEOF(PosTable) / SIZEOF(PosTable.stEntry[0]));

// -----------------------------------------------------------------------------
// calculate loadIndex
// -----------------------------------------------------------------------------

// -------------------------------------
// not using queueing
// -------------------------------------
IF (QA = 0) OR firstMove THEN
  loadIndex := index;

// -------------------------------------
// using queueing
// -------------------------------------
ELSE
  // update load index to the next valid PosTableEntry
  loadIndex := McePosTableFindEntry(loadIndex, 1, nPosTableSize, TRUE, posTable);

  // no valid result found
  IF (loadIndex < 0) THEN
    loadIndex := index;
  END_IF;
END_IF;

// -----------------------------------------------------------------------------
// calculating QA in case of firstMove
// -----------------------------------------------------------------------------
IF firstMove AND allowQueuing THEN
  // -------------------------------------
  // calculate remaining entries until standstill
  // -------------------------------------
  nEntriesRemaining := McePosTableRemainingEntries( index := index,
                                                    posTableSize := nPosTableSize,
                                                    rollOver := NOT stopAfterLastEntry,
                                                    posTable := posTable);

  // -------------------------------------
  // calculate Queueing Amount (allowed number of motions to be queued)
  // -------------------------------------
  QA := nEntriesRemaining;

  IF (nEntriesRemaining > QA_MAX) THEN
    QA := QA_MAX;
  END_IF;

  IF QA < 0 THEN
    QA := 0;
  END_IF;
END_IF;

Implementation

Snippet of the function call:
McePosTableUpdateLoadIndex(
  allowQueuing := , 
  firstMove := , 
  stopAfterLastEntry := , 
  index := , 
  posTable := , 
  QA := , 
  loadIndex := );

Pages built with Hugo - 23 Apr 2024 11:54 CEST