62
S t e p 2 : D e f i n e P a r a m e t e r s
A program will typically perform functions such as monitor a switch, control a
solenoid or relay, drive a motor, read an encoder, etc. In order for the program to
react to external devices through the I/O, the I/O parameters should be set before
running the program.
Global variables or flags should also be defined at this point. Motion parameters
should be set also.
All these can be entered into the text editor. See program following next step for
example.
S t e p 3 : P r o g r a m E n t r y
The program is now entered into the text editor. The following program example
is broken down into its separate components for clarity. This example follows the
plan illustrated in the flowchart figure 11.1. This is a working program illustrating
how an output can be switched on-the-fly using the position trip functions. An
LED can be connected to I/O line 21 and this program can be entered as shown.
'******** Parameter Setup ********
MUNIT = 51200
VI = 0.500
ACCL = 20
DECL = 50
IOS 21 = 0,1,0
'set i/o 21 to:output - gen. purpose,
'active low
'******** Main Program ********
PGM 200
LBL ONTHEFLY
TP1 = 5, PSUB1
'configure 1st position trip at 5 revs
TP2 = 10, PSUB2
'configure 2nd position trip at 10 revs
TPE1 = 1
'enable both position trips
TPE2 = 1
VM = 10
'initial max speed 10 rps
MOVA 4.25, 1
'move out to 4.25 revs at 10 rps
HOLD 0
VM = 2
'reduce max speed to 2 rps
MOVA 10.5
'move to 10.5 revs
HOLD 2
DELAY 250
VM = 10
'reset max speed to 10 rps
MOVA 0
'return to origin
HOLD 2
END
'******** Subroutines ********
LBL PSUB1
'turn on output at 5 revs.
IO 21 = 1
RET
LBL PSUB2
'turn off output at 10 revs
IO 21 = 0
RET
PGM
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from
Downloaded from