News:

  • April 16, 2026, 07:05:18 PM

Login with username, password and session length

Author Topic: Scanning vs. Executing  (Read 8909 times)

PureGasControls

  • Newbie
  • *
  • Posts: 5
Scanning vs. Executing
« on: December 30, 2008, 07:29:28 PM »
The DirectSoft manuals are not terribly clear on the difference between scanning and executing instructions. Most of the time they seem to mean the same thing, but clearly they are not. For instance, logic placed in subroutines are not scanned except when called by GTS because they follow the END. Therefore, they don't affect the PLC's scan time except when called. The manual is not clear whether logic in stages follow the same pattern, though.

The manual says this:
"The ladder rung(s) below each stage box belong to each respective stage. This means the PLC only has to scan those rungs when the corresponding stage is active!"

but it also says this:
"If Stage bit S0 = 0, its ladder rungs are not scanned (executed).
 If Stage bit S0 = 1, its ladder rungs are scanned (executed)."

but then it also says this:
"Note that unlike stages in RLLPLUS, the logic within the master control relays is still scanned and  updated even though it will not function if the MLS is off."

Clearly, instructions in an inactive stage are not executed, but are they still scanned, thus affecting the scan time?
« Last Edit: December 30, 2008, 07:59:37 PM by PureGasControls »

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3607
  • Darth Ladder
Re: Scanning vs. Executing
« Reply #1 on: December 30, 2008, 08:33:35 PM »
Doesn't sound like there's a discrepancy to me.

The first statement says logic in a stage is scanned only when that stage is active.

The second statement says that when a stage bit is 0, the corresponding ladder "is not scanned (executed)"

The third statement says that rungs inside an MLS are disabled but still scanned "unlike stages in RLL Plus", implying that inactive stage logic is neither scanned nor executed.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3803
    • Host Engineering
Re: Scanning vs. Executing
« Reply #2 on: December 31, 2008, 10:49:08 AM »
Yes, think GOTO.  When a stage is DISABLED, it does a GOTO the next stage, skipping all ladder logic in that stage (one of the reasons why Stage/RLL plus programs can be faster than their "functionally equivalent" ladder versions).  It does not bother "scanning" any of the instructions in the stage.

Normal instructions, especially OUTPUT COLUMN instructions, take time to "execute", even if they are not enabled.

For example:

STR X0
LD V2000
ADD V2001
DIV K2
OUT V1400

When X0 is ON, the LD, ADD, DIV, and OUT instructions all "execute".  But when X0 is OFF, since these instructions are enabled based off the current power flow, they do NOT "execute", but they still take time to "scan" through the instructions. 

Each PLC User manual has an appendix (C?) that shows "Instruction Execution Times", showing "Execute" times and "Not Execute" times.  In the above example, if X0 was ON, then it would take the "Execute" time.  If X0 was OFF, then it would take the "Not Execute" amount of time.

An instruction can only be "executed"
1. if it is SCANNED AND
2. it is enabled

Like your subroutine example, you could call an SBR 10 times in one PLC scan, or never.  In the former, those instructions are scanned 10 times, and each instruction in the subroutine can be executed UP TO 10 times (depending upon power flow/enable status).  In the latter, they are never scanned (and hence never executed and never "not executed").

Although it is hard to describe in words, I hope the examples above help you in understanding the differences.

PureGasControls

  • Newbie
  • *
  • Posts: 5
Re: Scanning vs. Executing
« Reply #3 on: December 31, 2008, 12:05:54 PM »
Thanks very much for your replies. I'm sure I just wasn't understanding the manual correctly.

On a related note, do stage blocks function the same way? (i.e. any stages or other instructions between a BLK and a BEND will not be scanned when the BLK is inactive)

franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3803
    • Host Engineering
Re: Scanning vs. Executing
« Reply #4 on: December 31, 2008, 02:18:58 PM »
Not sure about that, but at worst case, it will just skip over each stage, one at a time.  So say a block has 10 stages in it, each with 10 instructions, then worst case, it will GOTO past every 10 instructions (versus skipping all 100 instructions at once).