Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FUNCTION "XOR4" : BOOL
- TITLE = 4 way XOR - OON
- { S7_Optimized_Access := 'TRUE' }
- AUTHOR : MSKRAM
- VERSION : 0.1
- //One and Only One
- VAR_INPUT
- IN1 : BOOL;
- IN2 : BOOL;
- IN3 : BOOL;
- IN4 : BOOL;
- END_VAR
- VAR_OUTPUT
- MoreThanOne : BOOL; // More than one active inputs
- ActiveInputs : USInt; // Number of active inputs
- END_VAR
- VAR_TEMP
- usiCount : USInt;
- END_VAR
- BEGIN
- #usiCount := 0;
- IF #IN1 THEN #usiCount += 1; END_IF;
- IF #IN2 THEN #usiCount += 1; END_IF;
- IF #IN3 THEN #usiCount += 1; END_IF;
- IF #IN4 THEN #usiCount += 1; END_IF;
- #ActiveInputs := #usiCount;
- #MoreThanOne := #usiCount > 1;
- #XOR4 := (#usiCount = 1);
- END_FUNCTION
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement