RSlogix 500

klm

Member
Join Date
Jul 2007
Location
San Diego, California
Posts
33
Hello,

How would I write a reocurring loop in
a ladder logic program? Something like
a "DO LOOP" in PBASIC or
a "While (1==1) in C.

Thanks for your help.

K-
 
You can use the Jump and label instructions to construct a "DO" loop. However, beware, if your loop can increase your scan time tremendously, if you have a very long loop, you can cause you scan time to exceed the watchdog timer, and fault the processor.
 
I'm not sure that you would really want to. If you could give an example why you would, it might help.

In BASIC the program will execute, and the only way you can get it to re-execute a certain group of instructions, or maybe kill some time, is to put the instructions within some sort of a loop. Otherwise the program would just continue on and finish.

Visual BASIC is a little different. It will execute the instructions associated with an event, and then not do anything until there is another event such as a button press or a timer fires.

The PLC program will continuously loop over the entire program with every scan anyway, so outputs or whatever will not change anyway until something else changes.

It will DO

the same outputs and "internal relays" leaving them in the same state

UNTIL an input, or a count, or timer changes.



Or DO

the same outputs and "internal relays" leaving them in the same state

WHILE the inputs, or counts, or whatever do NOT change.
 
Ken is correct, on all counts.
But even more to the point, why do you believe you NEED to loop like that?

There are the FILE type instructions on the 500 platform that can operate on tables worth of data at a time, the main scan is cyclical, and there are interrupt routines available.

A JMP/LBL Loop construct is the wrong idea about 99.975% of the time.
 
Ken is correct, on all counts.
But even more to the point, why do you believe you NEED to loop like that?

There are the FILE type instructions on the 500 platform that can operate on tables worth of data at a time, the main scan is cyclical, and there are interrupt routines available.

A JMP/LBL Loop construct is the wrong idea about 99.975% of the time.

Going to have to disagree with you here. 1st of all, watchdog
time-out is an issue but that is always going to be an issue. The SLC-500 doesn't have the file instructions that the PLC-5 has. Even with that said the file instructions are too specific and often times lead to worse programs than individual logic rungs. This is not a blanket statement of-course but I speak from experience. I've seen too many PLC coders trying to shoe-horn their code to fit instructions rather than program a solution and use the best instruction/algorithm for the task.

The statement about the JMP/LBL construct being wrong so often riles me. I have to ask you where you get your statistics. The point is this, the JMP/LBL is one of the ways you do loops in the SLC world. It is a valuable construct and should be used when you need it. I have used it many many times with excellent results. And yes, if you're careful you can program recursive subroutines and they will work fine too.

Finally, to answer the original question, you don't have to write a while(1) type loop in the PLC because that's the way the PLC works anyway. The main program(s) is essentially executed as an uncoditional while loop.

Good Luck,

(8{)} :) .)
(Yosi)
 
Sometimes writing a DO While or for-next loop is bad programming practice. Sometimes its good programming practice. It depends on what you are trying to do.

Since you haven't told us that I can't say one way or another. However, in answer to the question, I suggest that you do a search on the forum for posts using the phrase "for-next loop" and "for/next loop." Put the search phrase in quotes so that you search for the phrase instead of posts containing the words "for" or "next" or "loop."
 
This forum is helpful, I'm glad it's here.
I appreciated everyone's comments and help.
Thank you to all who have responded to
my question. It's always a help.

K-
 
K,

Here is a program that has two "For-Next" loops. It is a number sort routine, converted from a BASIC program to a RSLogix ladder logic program. I am sure it can be converted without the loops, but I did not want to take the time to figure out how, so i just used the original I and J loops instead.
 

Similar Topics

Hi Everyone, I am not proficient in RSLogix 500 so I have a question regarding the evaluation of N7:0 data as an input. So as I understand in...
Replies
1
Views
85
I have a little bit of experience with Allen-Bradley. I have a Micrologix 1500 (RSLogix 500) and a PanelView Plus 7 (FactoryTalk View Studio ME)...
Replies
3
Views
165
buen dia. tengo una falla al pasar los tags de mi plc SLC 5 0/4 a mi panel me aparece un error Problem writing value " " to item <tag name>...
Replies
1
Views
81
Will someone please convert this logic to pdf?
Replies
2
Views
127
Hello, Haven't been on in a while. I need to generate a bit level pdf of the I/O for RSLogix 500. I can generate a report but it just shows the...
Replies
1
Views
158
Back
Top Bottom