News:

  • August 16, 2026, 03:17:14 PM

Login with username, password and session length

Author Topic: $tTopOfScan and $tBottomOfScan  (Read 12193 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
$tTopOfScan and $tBottomOfScan
« 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.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6170
  • Yes Pinky, Do-more will control the world!
Re: $tTopOfScan and $tBottomOfScan
« Reply #1 on: October 26, 2019, 10:00:58 AM »
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.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: $tTopOfScan and $tBottomOfScan
« Reply #2 on: October 26, 2019, 10:29:46 AM »
What about $tLastScan? Does it perform the same way if it is a Run to Stop transition or Run to Loss of Power?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6170
  • Yes Pinky, Do-more will control the world!
Re: $tTopOfScan and $tBottomOfScan
« Reply #3 on: October 26, 2019, 10:36:22 AM »
Yes, but only on transition from run to program.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3843
    • Host Engineering
Re: $tTopOfScan and $tBottomOfScan
« Reply #4 on: October 26, 2019, 11:54:17 AM »
$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.

Garyhlucas

  • Hero Member
  • *****
  • Posts: 421
Re: $tTopOfScan and $tBottomOfScan
« Reply #5 on: October 26, 2019, 06:52:13 PM »
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.

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2126
  • YKPAIHA
    • ATU, Inc.
Re: $tTopOfScan and $tBottomOfScan
« Reply #6 on: October 26, 2019, 08:11:54 PM »
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.