Optimizing Programs - Control Techniques UD70 User Manual

Large option module and software
Hide thumbs Also See for UD70:
Table of Contents

Advertisement

4.8

Optimizing programs

In order for programs to run effectively, the following are recommended.
Integer variables
Use integer variables where possible, rather than floating-point variables.
The processing of a floating-point variable is 20 times slower than for an
integer variable. (See
Fixed-point arithmetic
To represent decimal places, use fixed-point arithmetic. For example, if a
resolution of .001
accuracy to be maintained throughout mathematical operations.
The output from an expression must then be corrected by a relevant
dividing factor.
Example
a% = 1500
b% = 2500
c% = a% * b%
// Divide by 1000 to adjust c%
c% = c% / 1000
// To convert to the real value, we must divide by 1000 again
#1.21 = c% / 1000 //
Temporary integer variables
Minimize the number of times parameters are accessed. Instead of
accessing a parameter repeatedly, use temporary integer variables if a
parameter value is needed more than once. The access time for a
parameter is 50 times greater than that for a variable.
Example
IF #1.21 > 100 THEN
range% = 1
ELSEIF #1.21 > 200 THEN
range% = 2
ENDIF
This becomes:
temp% = #1.21
IF temp% > 100 THEN
range% = 1
ELSEIF temp% > 200 THEN
range% = 2
ENDIF
4-16
DPL programming
instruction in Chapter 7 Reference.)
INT
.001 is required, let 1 1 be represented by 1000
//
"a% = 1.5"
//
"b% = 2.5"
//
c% = 3750000
//
"c% = 3750"
"c% = 3.75"
1000. This allows
UD70
Issue code: 70nu2

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the UD70 and is the answer not in the manual?

Table of Contents

Save PDF