Programming, 1introduction, Introduction – Lenze PMSS1000 Simple Servo User Manual
Page 26: 1 introduction

Indexer-Programmer-Manual.pdf REV 1.3
2. Programming
2.1 Introduction
One of the most important aspects of programming is developing a structure for the program. Before you
begin to write a program, you should develop a plan for that program. What tasks must be performed? In
what order do they need to be performed? What things can be done to make the program easy to
understand and to be maintained by others? Are there any procedures that are repetitive?
Most programs are not a simple linear list of instructions where every instruction is executed in exactly the
same order each time program run. Programs need to do different things in response to external events
and operator input. SML contains program control structures instructions and scanned event functions
that may be used to control the flow of execution in an application program.
Control structure instructions are the instructions that cause the program to change the path of execution.
Scanned events are instructions that execute at the same time as the main body of the application
program.
Program Structure
SML programs are divided into four distinct sections:
Header
DEFINE
name Vn
ASSIGN
Events description
EVENT
name
…statements
ENDEVENT
Main Program Body
…statements
;End of main body statements
END
Subroutines
SUB subname
…statements
RETURN
Fault handler
ON
FAULT
…statements
RESUME
ENDFAULT
26