
General Program Flow and Timing information
This section will discuss general programming flow and timing information for Galil programming.
REM vs. NO or ' comments
There are 2 ways to add comments to a .dmc program. REM statements or NO/ ' comments. The main difference
between the 2 is that REM statements are stripped from the program upon download to the controller and NO or '
comments are left in the program. In most instances the reason for using REM statements instead of NO or ' is to
save program memory. The other benefit to using REM commands comes when command execution of a loop,
thread or any section of code is critical. Although they do not take much time, NO and ' comments still take time to
process. So when command execution time is critical, REM statements should be used. The 2 examples below
demonstrate the difference in command execution of a loop containing comments.
The GalilTools software will treat an apostrophe (') comment different from an NO when the compression
algorithm is activated upon a program download (line > 80 characters or program memory > 4000 lines). In this
case the software will remove all (') comments as part of the compression and it will download all NO comments to
the controller.
Note: Actual processing time will vary depending upon number of axes, communication activity, number
of threads currently executing etc.
#a
i=0;'initialize a counter
t= TIME;' set an initial time reference
#loop
NO this comment takes time to process
'this comment takes time to process
i=i+1;'this comment takes time to process
JP#loop,i<1000
MG TIME-t;'display number of samples from initial time reference
EN
When executed on a DMC-4020, the output from the above program returned a 116, which indicates that it took
116 samples (TM 1000) to process the commands from 't=TIME' to 'MG TIME-t'. This is about 114ms ±2ms.
Now when the comments inside of the #loop routine are changed into REM statements (a REM statement must
always start on a new line), the processing is greatly reduced.
When executed on the same DMC-4020, the output from the program shown below returned a 62, which indicates
that it took 62 samples to process the commands from 't=TIME' to 'MG TIME-t'. This is about 60ms ±2ms, and
about 50% faster than when the comments where downloaded to the controller.
#a
i=0;'initialize a counter
t= TIME;' set an initial time reference
#loop
REM this comment is removed upon download and takes no time to process
REM this comment is removed upon download and takes no time to process
i=i+1
REM this comment is removed upon download and takes no time to process
JP#loop,i<1000
MG TIME-t;'display number of samples from initial time reference
EN
WT vs AT and coding deterministic loops
The main difference between WT and AT is that WT will hold up execution of the next command for the specified
time from the execution of the WT command, AT will hold up execution of the next command for the specified time
from the last time reference set with the AT command.
Chapter 7 Application Programming ▫ 135
DMC-40x0 User Manual