//Continious Scan
TIMESTEP = 50
TimeStep ON
 
 
//Set all variables for the first time
VAR1 = 0
VAR2 = 0
CALL CALC_CHECKSUM_LSB
CALL CALC_CHECKSUM_MSB
 
 
 
// endless loop for checkings
LABEL WINPLC
     CALL CALC_CHECKSUM_LSB
     IF VAR3 != $VAR1 Then
          CALL WRITELOG
          VAR1 = VAR3
     END IF
      
     CALL CALC_CHECKSUM_MSB
     IF VAR3 != $VAR2 Then
          CALL WRITELOG
          VAR2 = VAR3
     END IF
GOTO WINPLC
 
 
 
//calculate the condition of channel 1-8 to a number
SUB CALC_CHECKSUM_LSB
     TEXTVAR = "$IO01+2*$IO02+4*$IO03+8*$IO04+16*$IO05+32*$IO06+64*$IO07+128*$IO08"
     VAR3 = $CALC(TEXTVAR)
END SUB
 
 
//calculate the condition of channel 9-16 to a number
SUB CALC_CHECKSUM_MSB
     TEXTVAR = "$IO09+2*$IO10+4*$IO11+8*$IO12+16*$IO13+32*$IO14+64*$IO15+128*$IO16"
     VAR3 = $CALC(TEXTVAR)
END SUB
 
 
// an I/O channel changed, write log!
SUB WRITELOG
     LOGFILE = "C:\io kanalen.log"
     WRITELOG "<$DAY/$MONTH/$YEAR $XTIME> $IO01$IO02$IO03$IO04$IO05$IO06$IO07$IO08$IO09$IO10$IO11$IO12$IO13$IO14$IO15$IO16"
END SUB

BACK TO SAMPLE OVERVIEW