For/Next in branch not allowed?

TheWaterboy

Lifetime Supporting Member + Moderator
Join Date
May 2006
Location
-27.9679796,153.419016
Posts
1,925
PLC-5

I read this warning from the Help file

ForNext Warning.jpg

And my code looks like this, so I appear to be violating both rules yet they work fine. Should these be laid out on separate rungs and if so, are they skipped by the PLC when the FOR Loop is not in play?

ForNext Example.jpg
 
my guess, you can't predict from a visual. In (old?) siemens world you can switch programming languages to textual so you can follow better what is going on. Your mileage may vary. it's the code that's getting generated by the interpreter/compiler that is important. when your vendor says you better not, my guess is that there are circumstances that the visual circuit sometimes gets interpreted wrong.
 
What plc is this?
I am unfamiliar with the for / nxt commands since this looks like a slc500 program.

your rung will execute 1 time due to the oneshot b3:14/1 and is triggered by the equal or B3:0/1 bit.
the line will execute in this order
for
mov
res
nxt
mov
equal - unlatch b3:0/1

both conditions must be off when the run rescans so the oneshot will work, but the for next logic would reset back to the start.

this is what I see, but I am unfamiliar with the for / nxt command.

james
 
What plc is this?
I am unfamiliar with the for / nxt commands since this looks like a slc500 program.

your rung will execute 1 time due to the oneshot b3:14/1 and is triggered by the equal or B3:0/1 bit.
the line will execute in this order
for
mov
res
nxt
mov
equal - unlatch b3:0/1

both conditions must be off when the run rescans so the oneshot will work, but the for next logic would reset back to the start.

this is what I see, but I am unfamiliar with the for / nxt command.

james


Not the OP, but it's a PLC-5
 
What plc is this?
I am unfamiliar with the for / nxt commands since this looks like a slc500 program.

your rung will execute 1 time due to the oneshot b3:14/1 and is triggered by the equal or B3:0/1 bit.
the line will execute in this order
for
mov
res
nxt
mov
equal - unlatch b3:0/1

both conditions must be off when the run rescans so the oneshot will work, but the for next logic would reset back to the start.

this is what I see, but I am unfamiliar with the for / nxt command.

james

It's a PLC-5 . I am assuming that it works like a subroutine since it works as shown. But as you say, it maybe shouldn't ? the ONS was necessary to make it work only one time per call.
 
PLC-5

I read this warning from the Help file

View attachment 51697

And my code looks like this, so I appear to be violating both rules yet they work fine. Should these be laid out on separate rungs and if so, are they skipped by the PLC when the FOR Loop is not in play?

View attachment 51698

I think that moving the contents of the branch into a JSR, and having the ONS and branch call the JSR, will get rid of the warning.

That will allow you to put the code into separate rungs too

In my opinion, that would make the logic a bit easier to read. But as you say .. it does work ;)
 
Slightly off topic, what is the "for" instruction, how does it worked, I've never seen this instruction before.

When you want to do something repetitive. This one moves a few dozen values from a set of C5 accumulator registers to N Registers for later consumption and then clears the counters for the next days capture.
 
I think that moving the contents of the branch into a JSR, and having the ONS and branch call the JSR, will get rid of the warning.

That will allow you to put the code into separate rungs too

In my opinion, that would make the logic a bit easier to read. But as you say .. it does work ;)

The warning is in the help file, it doesn't occur in any way. Just wondering what the issue might be.

I'm not a fan of separate rungs for a single operation unless its required due to scan limitations or it gets too long. Just my preference.
 

Similar Topics

I've got this start screen where the user has to enter their username and password. The username and password feature works fine. However, I want...
Replies
7
Views
1,438
Anyone know what the little green triangle on SCREEN 3 means ? See picture Thanks
Replies
2
Views
457
What do you guys think of this representation for on/off contacts? C003 is on, then others are off. I have never seen the logic represented in...
Replies
5
Views
1,801
Is it possible to get a report about used digital inputs on GE Proficy? I want to set what inputs are available.
Replies
3
Views
1,083
Hello PLCS.net! Link here: https://www.rockwellautomation.com/en-us/products/software/factorytalk/whats-new.html Seems like Rockwell is actually...
Replies
33
Views
22,425
Back
Top Bottom