Delta Tau GEO BRICK LV User Manual

Page of 440
Turbo PMAC User Manual 
Motor Compensation Tables and Constants 
177 
For large amounts of extra data memory, it is recommended to use the User Buffer set up with the on-line 
DEFINE UBUFFER command.  The User Buffer occupies a number of registers at the high end of X/Y 
data memory.  With an Option 5x0 standard memory configuration, the end of data memory is at 
X/Y:$0107FF; if DEFINE UBUFFER 2048 is declared, all data memory from $010000 through 
$0107FF is reserved for the user’s own purposes.  With an Option 5x3 extended memory configuration, 
the end of data memory is at X/Y:$03FFFF; there is by default a User Buffer of 65,536 words, reserving 
all memory registers from X/Y:$030000 to X/Y:$03FFFF for user use.  It is the user’s responsibility to 
make sure that registers in the UBUFFER utilized for Open Servo data storage are not used for other 
purposes as well. 
Writing the Open Servo Program 
The Open Servo program should be written in a plain-text editor such as the editor in the new 
PEWIN32PRO PMAC Executive program.  While the program can be written in any plain-text editor, it 
must be compiled by the PEWIN32PRO editor’s download function.  In this program, released in October 
2001, the download routine will recognize Open Servo routines automatically, compile them, and 
download the resulting machine code.  (Older versions of the PMAC Executive program are not capable 
of doing this.) 
In the file containing the Open Servo preceding the actual program must be all L-variable and F-variable 
pointer definitions, and all #define macro substitutions, or #include references to accessible files 
that contain these definitions and substitutions.  Remember that the built-in compiler does not download 
these definitions and substitutions to the Turbo PMAC; it uses them to do the compilation properly. 
The OPEN SERVO command is a signal to the compiler that the statements following up to the (required) 
CLOSE command are to be compiled into DSP machine code before downloading.  The CLEAR 
command that is used following the OPEN command on interpreted buffers is not required for Open Servo 
algorithms, because downloading the newly compiled code automatically clears older code, but it may 
still be used here. 
Example 1: Proportional Control 
The following algorithm shows one of the simplest possible Open Servo algorithms, implementing a 
simple proportional control law using the motor’s Ixx30 parameter as the proportional gain. 
OPEN SERVO   
 
; Following lines to be compiled 
CLEAR 
   ; Not necessary, but acceptable 
COPYREG P30  
 
; Copy following error into P32 
P35=P32*I(ITOF(MTRNUM*100+30))/65536 
; Multiply by gain, scale 
RETURN(FTOI(P35))  
; Make an integer and output 
CLOSE 
Example 2: Bi-Quad Filter 
The next example shows an implementation of a bi-quad filter capable of running on multiple motors, 
storing values from cycle to cycle for each motor.  It uses #define substitution macros to keep the code 
readable, and the MTRNUM function for variable and register arrays to separate stored values for each 
motor.  Variable arrays (which are easier for the user to access) are used for user-set “gains”, and register 
arrays (which are quicker for the algorithm to access) are used for algorithm-calculated stored values.   
This Open Servo program implements the following transfer function: 
)
z
(
E
)
d
z
)(
b
z
(
)
c
z
)(
a
z
(
K
)
z
(
U
p
+
+
+
+
=
 
It implements this as the following difference equation: 
(
)
[
]
(
)
2
k
1
k
2
k
1
k
k
p
k
bdu
u
d
b
ace
e
c
a
e
K
u
+
+
+
+
=