Introduction to the SLC-500 Selectable Timed Interrupt
The SLC-500 Selectable Timed Interrupt allows you to guarantee the execution of a routine in a given amount of time. For example, we might have a PID instruction that we need to execute every 50ms. We cannot guarantee the execution time of standard logic. Therefore, we create a routine, and schedule this routine to execute every 50ms.
Likewise, you might have logic that you write for safety, such as E-Stops. The E-Stops drop control power. However, you might want to take other actions when the operator activates an E-Stop.
Check your Overall Scan Time
While you are online, open the S2 Status file. In this case, I’m setting the Time Base flag to 1. This allows us to see the overall scan time in milliseconds instead of hundredths of seconds.
Obviously, this is a small project. Presently, the average scan time is around 3ms. Notice, however, the maximum scan time is 10ms. All logic is likely to execute within 1 to 10ms, but we cannot guarantee the execution time. For example, we’ll create an STI that executes every 5ms. That is to say, the main scan is interrupted, and the STI routine will execute every 5ms.
Go Offline, and Create the SLC-500 Selectable Timed Interrupt Subroutine
At this point, I’ll drop offline, and create a new subroutine. This will be program file 6, and I’ll name it “STI”.
Secondly, I’ll add some logic to the subroutine to verify it’s execution. Obviously, your logic will be different than my example.
I’m just adding a simple ADD statement to verify the routine is working.
Configure the STI in the S2 Status File
Open the S2 Status file, and click on the “STI” Tab. Notice that I turned on the “Resolution Select Bit” to enter the setpoint in miliseconds instead of hundredths. The program file number for the STI will be 6. Be sure you have the enable bit set to 1.
Download and test your work.
Finally, I’ll download our work, and the STI should execute approximately every 5 ms. the value of N7:1 should increment each time the processor executes the STI Routine.
Warning!! As your logic becomes larger, be careful of the watchdog timeout. Because the STI is executing so often, the overall scan time may dramatically as you add more logic. You will fault the processor if your overall scan time exceeds the watchdog setpoint.
As you can see, N7:0 is incrementing rapidly! Approximately every 5ms.
For more information, visit the SLC-500 Category Page!
— Ricky Bryce