SCAN Recursive

dandrade

Member
Join Date
Jan 2004
Posts
374
MAIN: What is SCAN RECURSIVE (recursive processing) ? Exists how many ways of processing the SCAN?

SECONDARY: Which PLC run in this way?

A simple drawing, easy understanding.
 
basic recursive loops ...

the basic idea of a “recursive” scan is to force the processor to go through a “loop” over and over again for a certain number of times ... in simplest terms, the word “recursive” means “repeating” ... here is a very simple example of a program with a recursive loop ...

[attachment]

Rung 0000 is outside the loop. Each time the processor scans ladder #2, the value of F8:0 will increase by one.

Rung 0001 is the first rung of the recursive loop. The label acts as a target for the jump. N7:0 is used as an "index" to count how many times the loop has been executed. The value of N7:0 will increase by one each time this rung is scanned. Programmers often refer to this operation as “incrementing the index”.

Rung 0002 is inside the recursive loop. Because of the recursive action, each time the processor scans ladder #2, the value of F8:1 will increase by four. In this simple example, we only have one rung inside the loop. In actual practice the loop might include many rungs. We could also clean this up by putting a single JSR rung here – and then programming as many rungs as necessary in a separate subroutine file. This would NOT make the program any more efficient – but it might make it easier for our maintenance technicians to recognize and understand the “recursive looping” action. Constructions like this can be very confusing – especially when we cannot see the JMP and the LBL on the screen at the same time.

Rung 0003 is the last rung of the recursive loop. Some programmers call this the “test” rung. If the value of N7:0 is 0, 1, 2, or 3, then the processor scan will jump backwards to the label in Rung 0001 - and then go through the loop again. When the value of N7:0 reaches 4, then the scan will "fall through" this JMP rung and then continue on to the next rung below.

Rung 0004 resets the value of N7:0 back to 0 to get ready for the next scan.

When we run this sample program:

The value in F8:0 will constantly increase. Basically it is just counting the total number of scans which the processor has made.

The value of F8:1 will also constantly increase – but it will increase four times as fast as the value in F8:0. That is because of the “recursive” action. It forces the processor to go back and execute Rung 0002 four times during each processor scan. (Note that in the picture 8778 * 4 = 35112).

If you’re still confused, try reading the description above again ... but this time substitute the word “repeating” instead of the word “recursive” ...

To answer your specific question, any processor which has the ability to “jump” backwards in its scan to a “label” should be able to perform a “recursive” loop. Just make sure that you don’t stay inside the loop too long! Most processors have a “watchdog” timer which monitors the length of time it takes to complete each scan. If the timer runs out, then the processor will fault.

Finally, this same type of “recursive looping” construction may be used to build a “FOR/NEXT” loop for smaller processors that do not have a FOR/NEXT included in their instruction set.

loop.jpg
 

Similar Topics

Hi everyone, I'm trying to simulate any program in control expert and see a register in Modscan32 or any software to do that (Like ModbusPoll). I...
Replies
0
Views
93
I am not sure if this is possible but if there is a way, you guys would be the ones to know. I am currently working on a project where we are...
Replies
7
Views
216
I have a Type C to RS485 adapter connect to my Siemens RWF55. I use modscan to scan it to get a value from the Siemens controller. In the...
Replies
4
Views
100
Hi, I'm new to PLCs and learning about PLC Scan times for Schneider PLCs I've derived the PLC scan time using the free running blocks. The PLC...
Replies
7
Views
665
Hello. Does anyone know the equivalent of the first scan bit in a L32ER compactlogix? Do o need to obtain it via GSV? I’m looking to regain...
Replies
3
Views
448
Back
Top Bottom