Understanding scan cycle and rung execution order

P.S. I am not saying this is good programming practice, because it is not. The purpose is validating my mental model of how PLC works.

My proposal is that, if we understand why this works, and why it can experience neither an infinite loop nor an indirect address violation, then we are well on our way to understanding how PLCs work.
 
Last edited:
My eye always twitches when an operator describing a problem starts a sentence with "it's as if the PLC thinks that..."

No. The PLC doesn't think anything. The PLC does exactly what I tell it to do and doesn't ask questions. The only things around here that think are you and me, and sometimes I'm not even sure about that.
 
Modicon stumbles

I get a halt when I place a zero at position 13 on Control Expert. Any ideas where I went wrong?


Attached a pair of screenshots and the program ZEF in a ZIP.

Screenshot 2022-08-22 130445.jpg Screenshot 2022-08-22 130610.jpg
 

Attachments

  • jumptest.zip
    60.7 KB · Views: 3
I get a halt when I place a zero at position 13 on Control Expert. Any ideas where I went wrong?


Attached a pair of screenshots and the program ZEF in a ZIP.


Halting when it reaches a zero is exactly what it is supposed to do.


I'm not familiar with the platform but in the second screenshot it looks like to output No_Zeros_In_N26 is ON when on that last jump through it should have turned OFF.


The ERR on the input in your first screenshot is why when I make an array I always make it larger than needed by one or 2,
EDIT: Just noticed your array is 19 long and stops at 18, it needs to be at least 20 long and include 19. That's why it ERR's.
 
Last edited:
I get a halt when I place a zero at position 13 on Control Expert. Any ideas where I went wrong?.


No, but you are asking the right question, and not "Why does the PLC not act like I expect it to?"

The most I could say is that the model I used for how the PLC executes ladder logic instructions in RSLogix 500 is not consistent with the one that is in Control Expert and that PLC's firmware.

Do you have any information on the cause of the halt? Are there PLC status bits that can be examined?
 
Halting when it reaches a zero is exactly what it is supposed to do.


I'm not familiar with the platform but in the second screenshot it looks like to output No_Zeros_In_N26 is ON when on that last jump through it should have turned OFF.


The ERR on the input in your first screenshot is why when I make an array I always make it larger than needed by one or 2,
EDIT: Just noticed your array is 19 long and stops at 18, it needs to be at least 20 long and include 19. That's why it ERR's.


Thanks for responding.


On the Schneider side we have an instruction called HALT that can either be called manually or by the watchdog. Since I don't have HALT in my code I think this must be the watchdog timing out. Note that my last coil END is unnecessary, it just turns on a bit that says I made it to the end of the diagram at least once.


I believe the halt must have occurred before the No_Zeros_In_N26 could be evaluated, otherwise I agree it would have turned off.



The ERR on my input would be equivalent to the ? in drbitboy's 2nd screenshot, since his array is also 0..18. It's evaluated for display to the operator in between program scans. The block never receives the error value as its input, as the index is always reset after the less-than comparison fails to trigger a jump.
 
... That's why it ERR's.


The HALT occurs in the screenshot where [0] is shown as the value of IN1 of the [NEQ] instruction .2.


The screenshot with #Err!# (gotta love that exclamation point) showing is running and not halted, as can be seen from the green [RUN] at the bottom right. The #Err!# is probably coming from the Control Expert monitor, which cannot reconcile an index of 19 into the N26 array.
 
Last edited:
No, but you are asking the right question, and not "Why does the PLC not act like I expect it to?"

The most I could say is that the model I used for how the PLC executes ladder logic instructions in RSLogix 500 is not consistent with the one that is in Control Expert and that PLC's firmware.

Do you have any information on the cause of the halt? Are there PLC status bits that can be examined?


The only item in the Diagnostic Viewer is Watchdog overflow/System Alarm/%S11.


The PLC screen shows the last execution time was 1010 ms, whereas the watchdog is set to trip at just 250 ms. This program is sufficiently simple that its normal execution (no zeroes) is 8 ms or less.
 
I was taking HALT as the JUMP stopped jumping back when he saw a 0, not the PLC stopped running. [Still not familiar with that line]


Taking the green lines after the NE instruction I would say that is where it is faulting because after it should not be green, unless green doesn't mean "Energized because TRUE" like in A-B.
 
The only item in the Diagnostic Viewer is Watchdog overflow/System Alarm/%S11.


The PLC screen shows the last execution time was 1010 ms, whereas the watchdog is set to trip at just 250 ms. This program is sufficiently simple that its normal execution (no zeroes) is 8 ms or less.


Then my next guess is that the backwards jump to [Q2:] is still, inexplicably, being executed from the [LT] instruction, even though the EN input rung of the LT instruction is FALSE.

As a diagnostic, set up another integer that is cleared at the same time as the index, and increment that other integer in each pass of the loop i.e. before the [NEQ]; I suspect its value at the time of the HALT will be greater than 13. Because even if the jump back to [Q2:] is occurring even though the LT's input rung EN is False, the [ADD] should not be executing, so the index would stay at 13 until the watchdog timeout.
 
Last edited:
Taking the green lines after the NE instruction I would say that is where it is faulting because after it should not be green, unless green doesn't mean "Energized because TRUE" like in A-B.


Yah. But if, when N26[13] becomes 0, the LT is jumping back to the [Q2:] in an infinite (actually unterminated) loop, until the watchdog calls the halt, when the index reaches 13, then it never gets to the next rung that energizes or de-energizes boolean NO_ZEROS_IN_N26, so that boolean would keep its previous value of 1.
 

Similar Topics

I'm trying to understand how the PLC will scan this "For" loop. will the "PhoneNb" variable not increment until all instructions within the "For"...
Replies
0
Views
1,661
I am using Allen Bradley PLC for Ethernet/IP communication. I send any explicit msg request (Get attribute or Set attribute), I observed packet...
Replies
0
Views
69
Took a new job and the controls schemes are fairly old and I'm used to Allen Bradley and Siemens. I'm looking to replace a pair of Superior...
Replies
1
Views
105
Hello Team, I am desperate for some help with an assessment I have as part of a Level 3 general engineering course. I am in a role that is much...
Replies
9
Views
345
Good day is there somewhere i can see the situation and compatibility regarding different firmware revisions. I have a 2711-K5A5, series H and...
Replies
4
Views
212
Back
Top Bottom