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
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?
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.
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.
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.
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
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
...pump_was_started = OFF
Hope that helps.
The rung would look something like
--| |---------|/|--------( )--
Ignore the commas I had to add them to show the verticle rung.
The high trigger the latch and the low resets it.
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,
-------| |---------| |--------( )--
I think that would work, I will let you know when it gets put into the machine.