110 likes | 364 Views
Power PMAC Data Structures January 2012. Power PMAC Data Structures. Main provided method of organizing Power PMAC information Both hardware (I/O) and software (memory) registers Includes saved setup elements (like old I-variables) Includes unsaved control elements
E N D
Power PMAC Data Structures • Main provided method of organizing Power PMAC information • Both hardware (I/O) and software (memory) registers • Includes saved setup elements (like old I-variables) • Includes unsaved control elements • Includes read-only status elements • Mostly replaces I & M-variable use of PMAC/Turbo PMAC • Pre-defined by Delta Tau • User cannot create own data structures/elements in Script environment • No need to know numerical addresses of structure elements • Mostly replaces “memory & I/O map” of PMAC/Turbo PMAC • Accessible through on-line commands, Script and C programs • IDE has “intellisense” database of structure names • Automatically presents possible “completions” as you type • Can select from list to finish name • F1 function key “help” provides full manual description
Script Environment Access • From both on-line commands and buffered program commands • Structure and element names are not case sensitive • No need to “include” any header files for access • No need to declare these pre-defined elements • Script environment automatically performs type-matching • No need to worry about element data length or format • Power PMAC prevents user changes to “write-protected” elements • Error returned for on-line command attempt • Buffered program attempt results in “no-op” (no error reported, no abort) • Power PMAC prevents out-of-range values from being assigned • Error returned for on-line command attempt • Buffered program attempt results in “no-op” (no error reported, no abort)
Classes of Data Structure Elements • Saved setup elements • Have factory default values set on re-initialization ($$$***) command, or on power-up/reset with a fault or configuration change • Last-saved values copied from flash memory on normal power-up or reset • Present active values copied to flash memory on a save command • Non-saved control elements • Have default values (usually 0) set on power-up, reset, re-initialization • User can set values at any time in application • Not affected by save command • Status elements • Values automatically set by Power PMAC • Most are write-protected in Script environment • Some permit user writing for special operations • Each class of element has a separate chapter in Software Reference
Important Data Structures • Sys. Global “system” elements • Motor[x]. Motor elements, indexed by Motor # • Motor[x].Servo. Motor servo algorithm elements • Coord[x]. Coordinate-system elements, indexed by CS # • EncTable[n]. Encoder table elements, indexed by entry # • CompTable[m]. Comp table elements, indexed by table # • Gate1[i]. DSPGATE1 Servo IC elements, by IC # • Gate1[i].Chan[j]. DSPGATE1 channel elements, by channel # • Gate2[i]. DSPGATE2 MACRO IC elements, by IC # • Gate2[i].Chan[j]. DSPGATE2 channel elements, by channel # • Gate3[i]. DSPGATE3 Servo IC elements, by IC # • Gate3[i].Chan[j]. DSPGATE3 channel elements, by channel # • GateIo[i]. IOGATE I/O IC elements, by IC # • Gather. Data gathering elements • Macro. MACRO ring elements
Specifying Data Structure Indices • 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)
Specifying the Address of an Element • The “.a” suffix added to the end of an element name specifies the “address of” the element • Generally do not need to know the numerical value of this address • Actual numerical value can vary with system type and compilation • Can get numerical value by querying {element name}.a • A “p” at the beginning of an element name specifies “pointer to” • These elements are set to an address value • When queried, Power PMAC reports back element name with “.a” suffix (if the address is that of a known element) • Examples: Motor[1].pDac=Gate1[4].Chan[0].Pwm[0].a // Set motor output pointer Motor[2].pDac // Query motor output pointer Gate1[4].Chan[1].Pwm[0].a // Power PMAC response Gate1[4].Chan[0].Pwm[0].a // Query element address $d5700008 // Power PMAC response
C Access to Data Structures • Must include header file in C compilation build: #include <RtGpShm.h> • Must access software elements with pshm->{data structure element} • C functions have pshm declared automatically • Independent C applications must declare: e.g. struct SHM *pshm; • Sys structure name is implicit: e.g. pshm->ServoPeriod (for Sys.ServoPeriod) • Other structure names must be used: e.g. pshm->Motor[1].JogSpeed • Must respect variable type of each element according to C rules • Element names in C are case-sensitive • No write-protection or out-of-range/saturation protection • Some “internal use” elements not accessible (in lieu of write protection) • For hardware elements, only “full-word” (32-bit) structure elements can be accessed from C program • Full-word elements often contain multiple partial-word elements • e.g. Gate1[i].PwmCtrl contains Gate1[i].PwmPeriod and Gate1[i].PwmDeadTime • Must mask (and maybe shift) to isolate “partial-word” element • Script full-word element of same name may be less than 32 bits • e.g. in script, Gate1[i].PwmCtrl is 24 bits (high 24 of 32)
C Access to Hardware Data Structures • Hardware (I/O) data structures not part of “pshm” shared memory • Two methods of C access to hardware data structures • 1st (recommended) method: define your structure variable • Use API function provided by Delta Tau – e.g.: GateArray1 MyFirstGate1IC; // Declaration of structure variable MyFirstGate1IC = GetGate1MemPtr(4); // Assignment to address • Now use element(s) in this structure – e.g.: MyFirstGate1IC->Chan[0].CompA = MyCompPos << 8; MyTriggerFlag = MyFirstGate1IC->Chan[3].Status & 0x80000 >> 19; • 2nd (slightly faster) method: define int pointers to structure & element • Use base address offsets auto-detected by Power PMAC – e.g.: MyFirstGate1Ptr = pshm->OffsetGate1[4]; • Compute absolute address of particular element pointer – e.g.: MyFirstGate1Ch0CompAPtr = (int *) piom + ((MyFirstGate1Ptr + 0x3C) >> 2); • Use this pointer variable – e.g.: *MyFirstGate1Ch0CompAPtr = MyCompPos << 8;