daves Posted January 29, 2014 Share Posted January 29, 2014 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 More sharing options...
bradp Posted January 29, 2014 Share Posted January 29, 2014 Yes, you can only use a local variable, that is the design. Link to comment Share on other sites More sharing options...
daves Posted January 29, 2014 Author Share Posted January 29, 2014 Thanks for the info, I altered my design to use parameters in a callsub (so effectively local in the sub) and I am happy. Link to comment Share on other sites More sharing options...
steve.milici Posted January 29, 2014 Share Posted January 29, 2014 FYI - the index value limitations are described at the beginning of "MOTOR[X]. SAVED DATA STRUCTURE ELEMENTS" in the "Power PMAC Software Reference Manual". Link to comment Share on other sites More sharing options...
daves Posted January 30, 2014 Author Share Posted January 30, 2014 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 More sharing options...
bradp Posted January 30, 2014 Share Posted January 30, 2014 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 More sharing options...
xuantran Posted August 25, 2021 Share Posted August 25, 2021 Can I use index structure L0 or Ldata.motor in a PLC? My intention is to make a loop for 8 motors in a PLC. In this loop, I need the index for Motor[index], kill, jog, etc. I also want to use the index L0 for indexing my global array. Link to comment Share on other sites More sharing options...
Omron Forums Support Posted August 25, 2021 Share Posted August 25, 2021 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 More sharing options...
teremock Posted August 26, 2021 Share Posted August 26, 2021 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 More sharing options...
Alex Anikstein Posted August 30, 2021 Share Posted August 30, 2021 Roman, We're still looking into this, but to consolidate, whenever we figure it out I will reply in the other thread. Link to comment Share on other sites More sharing options...
Recommended Posts