Command Descriptions
255
in which the scan takes place should be considered when creating PLCP programs to minimize the effects
of such a lag. One way to avoid the lag is to create a binary variable as a temporary holding place for the
desired output states. The last commands before the
END
statement of the PLCP program can set the outputs
according to the final status of the variable, such that all output states are written at the same time, just as
the scan completes. This method is demonstrated in the example program below.
For more information on defining a PLC program, refer to the
PLCP
command description.
Example:
DEF PLCP3
; Binary states of outputs 1-6 are represented by VARB1 bit 1-6.
; Outputs 1-6 are set at the end of the program.
VARB1=b000000
; Initialize binary variable 1
IF(IN.1=b1)
; If Input 1 is ON, turn Output 1 ON
VARB1=VARB1 | b100000
; Set binary bit for output 1 only to ON
NIF
IF(IN.2=b1)
; If Input 2 is ON, turn Output 2 ON
VARB1=VARB1 | b010000
; Set binary bit for output 2 only to ON
NIF
IF(IN.3=b1)
; If Input 3 is ON, turn Output 3 ON
VARB1=VARB1 | b001000
; Set binary bit for output 3 only to ON
NIF
IF(IN.4=b1)
; If Input 4 is ON, turn Output 4 ON
VARB1=VARB1 | b000100
; Set binary bit for output 4 only to ON
NIF
IF(IN.5=b1)
; If Input 5 is ON, turn Output 5 ON
VARB1=VARB1 | b000010
; Set binary bit for output 5 only to ON
NIF
IF(IN.6=b1)
; If Input 6 is ON, turn Output 6 ON
VARB1=VARB1 | b000001
; Set binary bit for output 6 only to ON
NIF
OUT(VARB1)
; Turn on appropriate outputs
END
PCOMP PLCP3
; Compile program PLCP3
SCANP PLCP3
; Run compiled program PLCP3 in Scan mode
; The diagram below illustrates the scan.
DEF PLCP3
VARB1=b000000
IF(IN.1=b1)
VARB1=VARB1 | b100000
NIF
IF(IN.2=b1)
VARB1=VARB1 | b010000
NIF
IF(IN.3=b1)
VARB1=VARB1 | b001000
NIF
IF(IN.4=b1)
VARB1=VARB1 | b000100
NIF
IF(IN.5=b1)
VARB1=VARB1 | b000010
NIF
IF(IN.6=b1)
VARB1=VARB1 | b000001
NIF
OUT(VARB1)
END
Pause Scan
Scanning
Scanning
Scanning
Scanning
Begin New
Scan
0
2 msec
Time (msec)
4 msec
6 msec
2 System Update Periods are needed to complete the scan
for compiled program PLCP3, for a total of 4 msec.
The response to a
TSCAN
command would be:
*TSCAN4
.
Scan
Complete
www.comoso.com
Содержание Gemini GT6K
Страница 24: ...www comoso com ...
Страница 40: ...www comoso com ...
Страница 344: ...www comoso com ...
Страница 350: ...www comoso com ...