
The algorithm can be reduced to as follows:
1) Check the screen number for a valid number (zero is not a valid screen number).
2) Subtract the offset from the lower byte of the screen number word.
3) Perform a range check.
4) Left shift a '1' by the calculated amount.
Note that in a Siemens S5 PLC, the 'DO' instruction can be used to modify the operation of
the instruction following.
Convert the screen integer number to a binary pattern (0 - 15).
SCNO - Integer number representing the screen number.
OFST - Offset to subtract from actual screen number.
BPOS - One bit is set in this word which represents SCNO with
bit 0 indicating screen 1, and bit 15, screen 16.
(e.g. SCNO=4, BPOS=0000 0000 0000 1000).
DECL: SCNO I, W ;Screen number input.
DECL: OFST D, KF ;Screen number offset.
DECL: BPOS Q, W ;Output screen indicator.
: T FW254 ;Reset a scratch word.
: T =BPOS ;Reset the result.
: L =SCNO ;Load the screen number.
: !=F ;Is it equal to zero?
: L KH 00FF ;Mask off the upper byte,
: AW ;lower byte contains screen number.
: LW =OFST ;Subtract the screen offset.
: D 1 ;Change range from 1-16 to 0-15.
: L KF +15 ;Is it greater than 15?
: L KF +0 ;Is it less than 0?
: T FY255 ;else, transfer it to a scratch word.
: L KH 0001 ;Convert this to a bit position.
: T =BPOS ;Transfer the result to the output.
Kommentare zu diesen Handbüchern