Jump to content
OMRON Forums

Index into structures


daves

Recommended Posts

Is it the intention that I cannot index structure elements by Global (P) variable in a pmc file?

 

e.g.

global MyEnc;

Motor[14].pEnc = EncTable[MyEnc].a;

 

It seems to allow

 

global MyEnc;

local enc = MyEnc;
Motor[14].pEnc = EncTable[enc].a;

 

I need this for flexible code for different machine configurations and using the local variable feels like a waste.

 

I cannot find this mentioned in the user guide in the computational features area discussing element indexing.

Link to comment
Share on other sites

  • Replies 9
  • Created
  • Last Reply

Top Posters In This Topic

You're right, my search in the PDFs for "index" quickly lost my attention!

 

Although it does explicitly say the index to the 'Motor' (I also now see it mentioned in comptable[m].data for i, coord[x], sys.cdata etc). No mention in EncTable[n].

 

Can I assume this is the case for all [] access in script code?

 

Perhaps it should be explained in POWER PMAC COMPUTATIONAL FEATURES - Pre-Defined Data Structures where indexing is described, and in the same area as the other quirks of the script language.

 

Ultimately I think it would be nice to allow P-variable indexing. It seems natural to want to define a machine configuration (e.g. FrontMotor=1) in a global variable then refer to this throughout the code without worrying about its type.

Link to comment
Share on other sites

This is part of the training slides, chapter 6. It should also be in the User Manual.

 

Index is in square brackets, not in parentheses

Index must be integer constant or local L-variable

No expressions, no fractions

If calculating index value, must do this in separate program command that assigns value to L-variable, e.g.

L0=Ldata.Motor;

Motor[L0].JogSpeed=100;

Indices always start at 0

Motor[x]. index value matches Motor number (#x)

Coord[x]. index value matches C.S. number (&x)

ASIC index value matches ASIC number (but ASIC numbering scheme different from Turbo PMAC)

ASIC channel index (0 – 3) is one less than ASIC channel number (1 – 4)

Constant index values can range from 0 to Sys.MaxItems - 1

Variables used for index can range from L0 to L(1022 – Sys.MaxItems)

 

You are correct, It would be nice, but when we designed this there were several technical reasons why P-vars and expressions could not be used in indecies so we had to do it this way.

Link to comment
Share on other sites

  • 7 years later...

You can use numbered L-Variables like L0 or or named local variables for looping over Motor[index]. Looping over global variables arrays works with either.

 

Ldata.motor can be used to specify a single motor jog commands that don't otherwise specify a number go to. It would probably be clearer to include the motor number in the jog commands (even if as a loop variable).

Link to comment
Share on other sites

Eric, can you explain why following code in kinematic script:

 

open forward (1)      // Put Coordinate System number inside "(cs)"
   LOCAL mot;
   local ax;
   LOCAL ratio;
   ax = 1;
   mot = 1;
   ratio = Motor[mot].CoordSf[ax];
close

 

... raises following compiler error:

 

...
Total Project download time = 3.344 seconds.
Total Project build and download time = 3.344 seconds.
There were errors during the download process and the download process has stopped.
The following errors were found:
   1 Error(s)

C:\job\.....\PMAC Script Language\Kinematic Routines\Forward1.kin(18,1) : Error : ( error #31)  invalid data :   L322 = Motor[L320].CoordSf[L321]

 

What is wrong? How to fix it?

 

Roman

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

×
×
  • Create New...