
Reference Manual
Chapter
3
IVC-2D
©
SICK AG • Advanced Industrial Sensors • www.sick.com • All rights reserved
45
Efficient Programming
3.9
Efficient Programming
It is important for both efficiency and readability reasons that programs are well structured
and well documented. When writing programs in IVC Studio you should consider the tips in
this chapter for more efficient programming.
3.9.1
Organizing Programs for Readability and Maintenance
By following these rules your programs become more readable and easier to maintain:
Divide the program structure into two main parts. One initialization part and one cycle
part.
The initialization part contains everything that is only set once after power-up, for exam-
ple grabbing parameters, static ROIs, load table from memory, and so on.
The cycle part is what is executed over and over again until the program is stopped.
Group sequences of steps to represent a higher-level function than the individual steps.
To perform this grouping, there are three standard ways:
1) tabulation in the program tree
2) subroutines
3)
macros
Name step tools more specifically than the tool’s original name.
Example: Rename “Scan rows” to “Scan rows, find upper left edge” or “If go” to “If width
too small, go to fail”.
Name the first step in the sequence in accordance with the purpose of the entire high-
level function when a sequence of steps is grouped.
Example: If 12 steps are used to localize a blob and find its uppermost edge pixel, then
rename the first step to “Find top edge of blob” and indent the remaining 11 steps.
Add dummy steps with the only purpose to give a sequence of indented steps a good
name, and to retain the possibility to give a more specific name to the first image pro-
cessing step of the sequence. For example, a ‘Goto‘ tool that only goes to the next step
can be used.
3.9.2
Making Debugging Easier
Display key values of your program/table, using the ‘Display‘ tool, to enable performan-
ce tests and fast debugging.
Display key parameters in different colors and sizes in the displayed bank by using the
‘Add Text‘
tool. For example in simple pass/fail applications you display Pass in green
letters or Fail in red letters.
For graphical feedback, add a ‘Draw ROI‘ step directly after the ROI creation to speed
up debugging when you use dynamic ROIs. Dynamic ROIs are ROIs that move around
depending on other results in the program.