360 likes | 876 Views
D x. D x. D x. D x. D x. Power PMAC Compensation Tables November 2013. E. M. Power PMAC Compensation Tables. Table-based corrections for machine/sensor imperfections Up to 256 total compensation tables 1D (linear), 2D (planar), or 3D (volumetric) tables
E N D
Dx Dx Dx Dx Dx Power PMAC Compensation TablesNovember 2013 E M
Power PMAC Compensation Tables • Table-based corrections for machine/sensor imperfections • Up to 256 total compensation tables • 1D (linear), 2D (planar), or 3D (volumetric) tables • Each table can be selected to roll over or not in each dimension • 1st-order or 3rd-order interpolation between table points • 1st-order: correction values always continuous • 3rd-order: rate of change of correction also continuous • Corrections computed every servo cycle (not just at move endpoints) • Correction values are floating-point, scalable units • Tables do not have to start at zero position of source motor • Direct software array access to table points • Easy to automate entry of table values • Easy to change table values dynamically • Can select how many tables to enable • Sys.CompEnable = {# of enabled tables} (Tables 0 to n-1 enabled)
Power PMAC Compensation Tables • Corrections are function of source motor desired position(s) • Do not interact with servo loop dynamics • Flexible specification of where correction is applied (“target”) • Actual position offset for position and/or velocity loops(Note that corrections do not affect feedforward) • Servo torque command offset (to compensate for cogging, etc.) • Backlash compensation offset register (for bi-directional comp) • Desired position offset (for electronic cam function*) • Can be multiple targets (up to 8) for a single table • Multiple registers for single motor (e.g. position and velocity loops) • Multiple motors (e.g. gantry pair) • Multiple tables can have same target register • Corrections should be additive in this case (first table overwrites previous cycle’s correction, subsequent tables add – as set by .OutCtrl bit) • Example: Coarse and (cyclic) fine corrections for a motor * V1.6 has separate cam table functionality
Compensation Table Data Structure Overview • Data structure elements about source(s) • CompTable[m].Source[n] // Source motor index num for this dimension • CompTable[m].Nx[n] // Number of data zones in this dimension • CompTable[m].X0[n] // Starting (min) position of source in this dim • CompTable[m].Dx[n] // Span of source in this dimension • Data structure elements about target(s) • CompTable[m].Target[q] // Address of this target register • CompTable[m].Sf[q] // Output scale factor for this target • Data structure elements for mode control • CompTable[m].Ctrl // Mode control byte (interp order & end control) • CompTable[m].OutCtrl.q //Overwrite target q (=0) or add to existing (=1) • Data structure elements for table entries • CompTable[m].Data[i] // Individual table entry value (1D) • CompTable[m].Data[j] [i] // Individual table entry value (2D) • CompTable[m].Data[k] [j] [i] // Individual table entry value (3D)
Memory for Compensation Tables • Comp tables can require significant memory (RAM and flash) • Each table entry is single-precision floating-point (4 bytes) • Table entries require 4 * (Nx[0] + 1) * (Nx[1] + 1) * (Nx[2] + 1) bytes • Table header information requires about 100 bytes • Tables are stored in a reserved area of memory • Default memory allocation of 1 MByte (1,048,576 bytes) • Part of overall 768 MByte (0.75 GByte) user RAM for standard memory • Part of overall 1.75 GByte user RAM for extended memory • Allocation can be changed in IDE Project Manager • Use “Properties” Control window • Set “Table Buffer” size in Mbytes • Resulting size stored in ppproj.ini project configuration file
Specifying Compensation Table Sources • Set CompTable[m].Source[n] to number of motor whose position will be used as source data for table in this dimension • Source[0] must be specified for 1D, 2D, and 3D tables • Source[1] must be specified for 2D and 3D tables • Source[2] must be specified for 3D tables • Set CompTable[m].Nx[n] to number of data zones from matching source • For a 1D table, Nx[0] must be > 0, Nx[1] and Nx[2] must be = 0 • For a 2D table, Nx[0] and Nx[1] must be > 0, Nx[2] must be = 0 • For a 3D table, Nx[0], Nx[1], and Nx[2] must be > 0 • For no rollover from dimension n, specify points 0 thru Nx[n] • For rollover from dimension n, specify points 0 thru Nx[n]-1 • Set CompTable[m].X0[n] to minimum position of Source[n] motor used in its units • Data[0] in this dimension is correction at this position • Set CompTable[m].Dx[n] to (max – min) distance of Source[n] motor in its units • Spacing of table points in this dimension is Dx[n] / Nx[n] • Set CompTable[m].SourceCtrl bit n to 0 to use desired pos, 1 to use actual pos, from Source[n] (new in V1.6)
2D Compensation Table Example Dz=f(x,y) Dz Dz
Specifying Compensation Table Targets • Set CompTable[m].Target[q] (q = 0 to 7) to address of register where correction is to be written • Only selected classes of registers are permitted • Type of register used as target determines what type of table is • Position (“leadscrew”) compensation table (for measurement errors) = Motor[x].CompPos.a// Outer-loop actual position (for accuracy) = Motor[x].CompPos2.a // Inner-loop actual position (for smoothness) • If target motor # “x” != source motor #, have “cross-axis” compensation • Torque compensation table = Motor[x].CompDac.a // Servo output correction (16-bit output units) • Backlash compensation table = Motor[x].BlCompSize.a // Backlash table correction • Electronic cam table (for commanded motion, usually cross-axis) = Motor[x].CompDesPos.a // Part of net desired position • Setting Target[q] = 0 disables target
D D D D D D y y y y y y M E Cross-Axis Comp Table Example Δy=f(x) Target motor # ≠ Source motor #
Comp Table Control Byte (.Ctrl) • CompTable[m].Ctrl determines how corrections are calculated • 8-bit value organized into 4 2-bit fields • Bits 0 & 1 determine order of interpolation from each source = 0: 1st-order interpolation from all sources = 1: 3rd-order interpolation from 1st source = 2: 3rd-order interpolation from 1st and 2nd sources = 3: 3rd-order interpolation from all 3 sources • Bits 2 & 3 determine boundary mode for 1st source • Bits 4 & 5 determine boundary mode for 2nd source • Bits 6 & 7 determine boundary mode for 3rd source = 0: Rollover at table boundary of this source = 1: Maintain last correction past boundary of this source = 2: Mirror table at boundary of this source • If source not used, settings for it are “don’t care” • Example: .Ctrl=$57 means no rollover, cubic interpolation, all sources
Using Multiple Tables on Same Target • Useful to be able to add corrections from multiple tables into single target register • Most common use is coarse and fine position compensation tables • Fine table is for repetitive errors over small interval of travel, e.g. • Sensor eccentricity over one mechanical revolution of motor • Harmonic distortion of sine/cosine sensor over one sensor period • Fine table must be set up to “roll over” • Coarse table is for non-repetitive errors over full range of travel • e.g. screw errors over full length of screw • Coarse table entries must each be at same point in fine table • Each table has same target address • First (lowest-numbered) table must be set up to overwrite target (bit q of CompTable[m].OutCtrl = 0 for Target[q]) • Subsequent (higher-numbered) table(s) must be set to to add to target value (bit q of CompTable[m].OutCtrl = 1 for Target[q])
Effective Disabling of Enabled Table • Sys.CompEnable = n enables tables 0 to n-1 • Some users want more flexibility in enabling/disabling tables • Disable all compensation to a motor (e.g. during homing) • Switch between compensation tables for a motor • Disabling method 1: Set CompTable[m].Sf[q] to 0.0 • Forces correction to zero • Can ramp down gradually to remove correction smoothly • Can ramp up gradually to re-introduce correction smoothly • Disabling method 2: Set CompTable[m].Target[q] to 0 • Leaves last correction in place • Can manually overwrite last target value if desired
Comp Table Data Elements • Data[ ] elements (table entries) are corrections at given (raw) positions of source motor(s) • Values are single-precision floating-point, scaled to units of the target register • Table entries are evenly spaced in each dimension (spacing can differ between dimensions) • Location index in square brackets for dimension n can range from 0 to Nx[n] • Index value can be constant or local variable (no expressions) • If table rolls over, only points with indices from 0 to Nx[n]-1 are used • For multi-dimensional tables, first source uses last location index • For CompTable[m].Data[k][j][i], location index i is for Source[0] position, j is for Source[1] position, k is for Source[2] position • Can enter multiple points with consecutive final location indices in single command • e.g. CompTable.Data[4][3][0]=0, 4.2, -1.9, 2.6, -0.7
Comp Table Data Element Indices • Data element indices can be specified with integer constants or local variables • For 1D tables, elements CompTable[m].Data[i], index i can be: • Integer constant from 0 to 16,777,215 • Any local variable L0 – L8191 • For 2D tables, elements CompTable[m].Data[j][i], indices can be: • i: Integer constant from 0 – 65,534, local variable L0 • j: Integer constant from 0 – 65,533, local variables L0 and L1 • For 3D tables, elements CompTable[m].Data[k][j][i], indices can be: • i: Integer constant from 0 – 65,534, local variable L0 • j: Integer constant from 0 – 253, local variables L0 and L1 • k: Integer constant from 0 – 252, local variables L0, L1, and L2 • Value of index (either constant or variable) must be within declared range for that dimension
Calculating Comp Table Corrections • New correction computed for each table every servo cycle • Corrections calculated after new desired positions computed for all motors • Using new cycle’s desired positions avoids a cycle of delay • Corrections calculated before servo loop closure of motor specified by Sys.CompMotor • At default value of 0, all tables calculated before any motor’s servo loop • Can be set greater than 0; useful for “0D” table for cascading servo loops • 1st-order interpolation calculates weighted average using one table entry on each side of source position for each active dimension • 2, 4, or 8 entries for 1D, 2D, or 3D, respectively • 3rd-order interpolation calculates weighted average using two table entries on each side of source position for each active dimension • 4, 16, or 64 entries for 1D, 2D, or 3D, respectively • Resulting correction multiplied by Sf[q] before writing to Target[q]
Simple 1D Comp Table Example • Setup for standard “leadscrew comp” 1D table on Motor 1 CompTable[0].Source[0]=1 // Use Motor 1 as (1st) source CompTable[0].Nx[0]=11 // 11 data zones from 1st source CompTable[0].Nx[1]=0 // No second dimension CompTable[0].Nx[2]=0 // No third dimension CompTable[0].X0[0]=-10000 // Start table at -10,000 counts of 1st source CompTable[0].Dx[0]=110000 // Span of 110,000 counts (to +100,000) CompTable[0].Target[0]=Motor[1].CompPos.a // Motor 1 position loop CompTable[0].Target[1]=Motor[1].CompPos2.a // Motor 1 velocity loop CompTable[0].Sf[0]=1.0 // Unity scale factor for #1 position loop CompTable[0].Sf[1]=1.0 // Unity scale factor for #1 velocity loop CompTable[0].Ctrl=7 // Disable rollover, cubic interpolation CompTable[0].OutCtrl=0 // Overwrite target registers each cycle CompTable[0].Data[0]=0,25.2,12.1,-7.3,8.1,-1.9 // Points 0 to 5 (Motor 1 units) CompTable[0].Data[6]=6.5,13.4,-3.6,2.9,-11.8,4.7 // Points 6 to 11 (Motor 1 units) Sys.CompEnable=1 // Enable this table [0] only
Small 2D Comp Table Example CompTable[1].Source[0]=1 // Use Motor 1 as 1st source CompTable[1].Source[1]=2 // Use Motor 2 as 2nd source CompTable[1].Nx[0]=4 // 4 data zones from 1st source CompTable[1].Nx[1]=3 // 3 data zones from 2nd source CompTable[1].Nx[2]=0 // No third dimension CompTable[1].X0[0]=0 // Start table at 0 counts of 1st source CompTable[1].X0[1]=0 // Start table at 0 counts of 2nd source CompTable[1].Dx[0]=40000 // Span of 40,000 counts across 1st source CompTable[1].Dx[1]=30000 // Span of 30,000 counts across 2nd source CompTable[1].Target[0]=Motor[3].CompPos.a // Motor 3 position loop CompTable[1].Target[1]=Motor[3].CompPos2.a // Motor 3 velocity loop CompTable[1].Sf[0]=1.0 // Unity scale factor for #3 position loop CompTable[1].Sf[1]=1.0 // Unity scale factor for #3 velocity loop CompTable[1].Ctrl=$17 // Disable rollover both dims, cubic interp CompTable[1].OutCtrl=0 // Overwrite target registers each cycle CompTable[1].Data[0] [0]=0,10,20,30,40 // 1st-row data points (#3 units) CompTable[1].Data[1] [0]=11,21,31,41,51 // 2nd-row data points (#3 units) CompTable[1].Data[2] [0]=22,32,42,52,62 // 3rd-row data points (#3 units) CompTable[1].Data[3] [0]=33,43,53,63,73 // 4th-row data points (#3 units) Sys.CompEnable=2 // Enable tables 0 & 1
Special Use of “0D” Comp Table • If CompTable[i].Nx[0], Nx[1], Nx[2] all = 0, the table still has a single entry (Data[0]) • This value of this entry is scaled and written to target register(s) • Can be useful way of injecting calculated offsets/corrections • Into position, torque, or backlash compensation registers • Program statement simply writes value to CompTable[m].Data[0] • Can affect multiple motors simultaneously with multiple targets • Useful for cascaded servo loops • If Ctrl bits 0 & 1 > 0 for 0D table, uses Source[0] motor’s servo command • Can integrate outer-loop output by setting OutCtrl to 1 • Target[q] is CompDesPos.a for inner-loop motor • Sys.CompMotor specifies when to compute table corrections • Before specified motor’s servo loop is closed (default is 0) • Setting between outer and inner-loop motors eliminates servo-cycle delay