Delta Tau GEO BRICK LV User Manual

Page of 440
 
Turbo PMAC User Manual 
380
 
Writing and Executing PLC Programs
 
Functions 
As with any Turbo PMAC user program, compiled PLCs can utilize the following mathematical 
functions.  Note that these functions can be used only in floating-point statements within a compiled PLC: 
SIN (trigonometric sine), COS (trigonometric cosine), TAN (trigonometric tangent), ASIN (trigonometric 
arc sine), ACOS (trigonometric arc cosine), ATAN (trigonometric arc tangent), ATAN2 (special 2-
argument, 4-quadrant arc tangent), ABS (absolute value), INT (greatest integer within), EXP 
(exponentiation), LN (natural logarithm), and SQRT (square root). 
The trigonometric functions use degrees if Turbo PMAC variable I15 is set to the default value of 0; they 
use radians if I15 is set to 1.  The present value of I15 is evaluated each time a trigonometric function is 
executed. 
Note:  
The ATAN2 function uses Q0 as its second argument – the cosine argument.  The 
first argument – the sine argument – is inside the parentheses immediately 
following ATAN2.  The Q0 used is that of the coordinate system selected in the 
PLCC by the ADDRESS statement, or Coordinate System 1’s Q0 if no ADDRESS 
statement has been executed in that PLCC. 
Optimization for Speed  
As mentioned above, fixed-point operations with L-variables are over 10 times faster than the same 
operations done with floating-point mathematics in a compiled PLC (and over 30 times faster than the 
same operations done in an interpreted PLC).  Even with fixed-point operations, there are differences in 
speed and efficiency. 
L-Variables that are 24-bit signed values are the fastest to read and write.  Unsigned 1- to 20-bit variables 
without offset are next fastest and signed 1- to 20-bit variables and those having an offset from bit 0 are 
the slowest.  The slower the operation, the more PLC program memory is used.  However, 24-bit L-
variables will use more data memory than the smaller-width ones.  Because speed is more of a concern 
than data memory in most compiled PLC applications, usually all L-variables that do not have to be short 
to point to a particular portion of a word (such as all the general-purpose L-variables in the user buffer) 
are 24 bits wide, even if they do not require the full range. 
A read or write operation on a signed 24-bit L-variable takes 3 DSP instruction cycles to execute and 2 
program memory locations to store. 
A read operation from a less-than-24-bit (1- to 20-bit) signed L-variable takes from 6 to 8 DSP instruction 
cycles and from 5 to 7 program memory locations.  A read operation from a less-than-24-bit (1- to 20-bit) 
unsigned L-variable takes from 7 to 9 DSP instruction cycles and from 6 to 8 program memory locations.   
A write operation to a less-than-24-bit (1- to 20-bit) signed or unsigned L-variable takes 12 to 14 
instruction cycles and 10 to 12 program memory locations. 
The &, ^, |, +, -, * operators take 1 or 2 DSP instruction cycles in fixed-point operations. 
The divide ( / ) operator takes nominally 82 DSP instruction cycles in fixed-point operations. 
The modulo ( % ) operator takes nominally 76 DSP instruction cycles in fixed-point operations. 
Memory Utilization 
The DSP563xx CPU for the Turbo PMAC employs Harvard architecture with separate areas of program, 
or instruction, memory, and data memory.  The actual instructions of the compiled PLCs are loaded into P 
program memory; all of the data registers it uses are in X and Y data memory.