Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on October 26, 2019, 09:33:17 AM
-
Can someone point me to the help topic on $tTopOfScan and $tBottomOfScan or provide a brief explanation of how they work and any limitations? I've got a pretty good idea but I searched through the help file and couldn't seem to find any information on these tasks. Also, could someone describe a common use for these tasks.
-
Not sure about help, but they are just predefined system tasks that execute at the top and bottom of the scan. If you were mapping I/O in or out, or if you had other system housekeeping that needs to occur ever scan, these tasks are a handy place to do that.
-
What about $tLastScan? Does it perform the same way if it is a Run to Stop transition or Run to Loss of Power?
-
Yes, but only on transition from run to program.
-
$tLastScan is not a task. PLC is going to STOP, so no looping, no time slice, nothing asynchronous. It is straight line logic (think subroutine).
$tTopOfScan and $tBottomOfScan is just like any other task, and can have timers, edge triggered instructions, async instructions, etc. It's just that those code blocks are guaranteed to run BEFORE and AFTER (respectively) all the other code-blocks.
-
Read all your sensors, switches etc. in Top of Scan. Write all your outputs in Bottom of Scan and be sure that nothing strange happens because of precedence of order.
-
TopOfScan is also a good place to post data from remote devices and results from interrupt routines that you want to make sure all the routines see the data in the correct order of sequence in the scan. Otherwise the data will arrive at some indeterminate place in the scan which might yield unexpected results.