High-speed Counter Function10-2610.4.4 Sample Program (Upper Limit Control, Subtraction)The following shows the program for performing three cam outputs (R100-R102) according tothe elapsed value of the high-speed counter CH0. In the case of subtraction, when theelapsed value falls below the target value (OFF set value), the cam output turns off, and whenit falls below the target value (ON set value, the cam output turns on. When it falls below thetarget value (OFF set value), the interrupt program is started. When the elapsed value fallsbelow 0, it returns to the upper limit.Code Value Descriptionⓐ Upper limit When the elapsed value falls below 0, it returns to the upper limit.ⓑ Elapsed value The control is started from the elapsed value when executed. In this example,the elapsed value 13000 is preset.ⓒ Target value 3: OFFset valueThe cam output is performed according to the target values.In this example, the ON set value is smaller than the OFF set value for anytarget values. Therefore,When subtracted: When the elapsed value falls below the OFF set value, thecam output turns on, and when it falls below the ON set value, it turns off.When added: When the elapsed value reaches the ON set value, the camoutput turns on, and when it reaches the OFF set value, it turns off.ⓓ Target value 2: OFFset valueⓔ Target value 1: OFFset valueⓕ Target value 3: ONset valueⓖ Target value 2: ONset valueⓗ Target value 1: ONset value① Execution condition When the execution condition turns on from off, the instruction is executedand the cam control starts.② High-speed counterinstruction active flagThe high-speed counter instruction active flag turns on during the execution ofthe instruction.③ Cam output The output turns ON/OFF according the set values.④ Interrupt programactivationIn the case of subtraction, when the elapsed value falls below the OFF setvalue, the interrupt program is started.