advertisement
from the Forum department...
RSLogix 5000 While and For Loops
PLCs and related questions. topic
Posted by rpmccly on 4 April, 2011 - 10:17 am
I am new to programming and need a pump to turn on when the high level sensor energizes and to turn off when the low level sensor de-energizes. I am using the RSLogix 5000 Demo to experiment with it so I don't mess up the actual code on the actual machine. I want to run a while loop that would be as follows:

----
While Low Sensor & High Sensor Energized
...While Low Sensor Energized
......Pump ON
...End
End
----

I only see for loops in 5000 so is that all I can do or are while loops hidden somewhere?

How would this be setup?


Posted by Anon on 4 April, 2011 - 3:31 pm
Seriously ?

Oh dear.....


Posted by curt wuollet on 4 April, 2011 - 3:44 pm
Why the loop for that? It looks to me to resolve to:

pump on = low sensor on and high sensor on. Am I missing something? That's just a rung.

Regards
cww


Posted by curt wuollet on 4 April, 2011 - 3:45 pm
I think I see the problem. Let the PLC do the looping and you do the logic. Think through how a PLC works.

You don't need a loop.

Regards
cww


Posted by Steve Myres on 4 April, 2011 - 9:50 pm
Ladder was originally designed to replace systems where the logic was implemented using relays. Think how you would solve this using physical relays (think latching circuit, like a three wire motor control circuit) and you'll have your answer.

Even if you're working in a language other than ladder, the same principle applies.


Posted by Patrick J Beckett on 5 April, 2011 - 4:04 am
Okay, I think I see the problem here. You are approaching this from a typical high level language approach. The PLC is not programmed like that. This is why:-

Simplistically, everything is within a 'while TRUE do ...' loop.
While TRUE Do
...SCAN INPUTS
...USER CODE
...UPDATE OUTPUTS
Loop

The PLC monitors the length of time it takes to do one full cycle of the loop and if it takes too long, the PLC faults. It must complete it refresh of the IO within a set time or its pointless. PLC programmers are VERY careful about using any kind of loop structure in their code, to ensure it does not slow the processor down too much.

Loops in a high level language (C, java, basic, etc) may pause the overall execution for .25 of a second with no ill effects. To a PLC a pause of 250ms is a disaster. Imagine not reacting to a fault circuit for that length of time. (Don't flame me, I know that is a lot of number crunching to slow it down that much, but its the principle I'm getting across.)

In your case, as the others have said, we are talking about an if statement with some memory.
If (high_level OR pump_was_started) AND NOT Low_Level then

...pump_was_started = ON

else

...pump_was_started = OFF

end if

That could then be converted into one rung of ladder.

Hope that helps.

pjb


Posted by Paul Edwards on 5 April, 2011 - 5:26 pm
The rung would look something like

High,,,,,,,Low,,,,,,Run Pump
--| |---------|/|--------( )--
,,,,,,,,,,|
--| |----|
Run Pump

Ignore the commas I had to add them to show the verticle rung.

The high trigger the latch and the low resets it.

Paul


Posted by rpmccly on 6 April, 2011 - 1:44 pm
This is my first project....I know zero about PLC logic.

Anon - Thanks for the help...

cww - Yes, the part your missing is the high sensor goes off before we want the pump to shut off so your rung won't work. Also, I'm not really sure the details of the PLC.

Steve M - good way of thinking, thanks.

pjb - Your right, I'm thinking at the higher level, and I will stay away from the loops.

Paul - Thanks for post, you basically solved it. What we will is use,

,,,,,,,High,,,,,,,,Low,,,,,,Run Pump
-------| |---------| |--------( )--
--|,,,,,,,,,,|
------| |----|
,,,,Run Pump

I think that would work, I will let you know when it gets put into the machine.


Posted by curt wuollet on 6 April, 2011 - 6:11 pm
That wasn't stated, but logical I suppose.

Regards
cww

Your use of this site is subject to the terms and conditions set forth under Legal Notices and the Privacy Policy. Please read those terms and conditions carefully. Subject to the rights expressly reserved to others under Legal Notices, the content of this site and the compilation thereof is © 1999-2014 Nerds in Control, LLC. All rights reserved.

Users of this site are benefiting from open source technologies, including PHP, MySQL and Apache. Be happy.


Fortune
Wit, n.:
The salt with which the American Humorist spoils his cookery
... by leaving it out.
-- Ambrose Bierce, "The Devil's Dictionary"
Advertise here
Advertisement
our advertisers
Help keep our servers running...
Patronize our advertisers!
Visit our Post Archive