PLC Programming is a Journey, not a Destination.
Alex:
Just prior to your joining this forum, I wrote a little treatise (with comments from Terry Woods) on
How to Start. I'll reproduce some of it here:
[Rainbow]PLC Programming is a Journey, not a Destination.[/Rainbow]
#1. YOU HAVE TO KNOW WHERE YOU ARE STARTING FROM.
Before you start writing code, you must come up with as complete an I/O list as possible.
The list will grow and change as you do the second task. But that's OK. You've got to start somewhere.
You have a good I/O list, from what looks like a previous job. In looking over it, though, I note some irregularities, particularlly in your outputs.
What is the difference between:
O:0/00 – Jockey pump start
and
O:0/04 – Jockey pump start
Does the PLC really have outputs
O:0/05 – Duty pump # 1 fault
O:0/06 – Duty pump # 2 fault
which CAUSE the pumps to fault? Or are these indicator lights (as might be O:0/4 above)? If so, your I/O list should make that clear.
One technique I try to teach newbies when annotating code - USE VERBS! Verbs let you know exactly what is going on. For example, you have:
I:0/03 – Duty pump lead signal
Perhaps a better description might be (if I'm guessing it's purpose correctly):
I:0/03 – Pump #1 is selected for lead duty.
With the verb "is selected", there's no confusion as to what's going on. Furthermore, when you get to coding, then -| |- means "is selected", and -|/|- means "is not selected" (which may be the same, as "Pump #2 is selected", or it may not. Study Logic (philosophy course) and learn the difference between "imply" and "infer".
#2. YOU HAVE TO KNOW WHERE YOU ARE GOING TO.
You need a careful, detailed sequence of operations. As you develop this sequence, you'll be realizing that you may have gaps in the I/O, Fill them in, and then review your sequence again.
Be sure your sequences are detailed enough.
The hardest thing for a lot of guys to overcome is the tendency to take things for granted. They don't consider the details - all of the details!
I usually suggest that a person needs to "Be the Computer". However, that might be a little presumptive in this case.
Another thing I suggest is that a person think of how they would control the system if they had to do it at a completely manual control station. However, that too might be a little presumptive... it presumes all input and output signals exist. It's too easy to overlook a detail.
Your sequence / flow chart is a good start, but there are many holes in it.
For example, you refer to a "MIXER" in the sequence, but your I/O list doesn't have anything called a "MIXER". You have a "Jockey Pump" and a "Fire Pump", but no "MIXER". Is your I/O list missing something?
That's the second thing that I try to drill home to newbies: BE CONSISTANT IN WHAT YOU CALL THINGS. Lots of stuff goes by many different names, for the same dohickey in the same plant. In the long run, it doesn't matter if you refer to it as TK-123 or Neutralization Tank or Waste Treatment Tank or The Old Rust Bucket, as long as you're consistent. If you're not, someone who doesn't know as much as you do won't be able to follow your code. ("Why is the Waste Treatment Infeed pump on when the Neutraliation Tank valve is open?). For that matter, YOU won't be able to follow your code 6 month from now.
Once you have your I/O list and a good sequence, you're ready to START your journey.
#3. YOU HAVE TO KNOW HOW TO GET THERE.
There are no shortcuts. You start by understanding how logic is scanned (especially how, what you do on one scan, will affect what happens on the next), and knowing your instruction set. For beginners, -| |-, -|/|-, -( )-, Timers and Counters are enough instructions. (Since you have analog inputs, you'll need to understand some of the math functions too).
Then you start with the outputs. Just draw them out in space like this:
MIXER
. . . . . . . . . . . .---( )
`
Then look at your sequence.
When does the mixer come on? -
When the Level is greater than 0.6 M
So you add this out in space:
MIXER
----| LEVEL > 0.6 |-----+ . . . . . . .---( )
`
Your sequence implies, but does not speficially state (which means you need to go back a step and revise it), that "Once started, the mixer keeps on running, until the level drops to 0.3 M."
The line in the sequence: "Once started, the mixer keeps running" means that we need to "latch" or "seal" (epending on your age and where you went to school) the pump, like so:
MIXER
----| LEVEL > 0.6 |-----+ . . . . . . .---( )
|
MIXER |
--------| |-------------+
`
The Mixer stops when the level gets below 0.5 M. Another way of saying this is that the mixer keeps running as long as the level is
ABOVE 0.5
Adding that yeilds the complete rung:
MIXER
----| LEVEL > 0.6 |-----+-------| LEVEL > 0.5 |--------( )
|
MIXER |
--------| |-------------+
`
#4. YOU HAVE TO EXPECT DETOURS.
With the completed code, you start asking yourself "What-If" question?
"I know what's supposed to happen when the one pump fails. What if they BOTH fail?"
"What if the a pump fails. Shouldn't the PLC tell somebody?"
If so, how. Lights? Noise? How will those be turned off once the problem is fixed?
"What if one pump is not in AUTO, but the "PUMP IS RUNNING input indicates that the pump is running (and it's the lead pump? Should I start the lag anyway, because the lead is not under my control, or wait until LEVEL > 1.2 to start the Lag pump?"
This "map" is just a start. If you are serious about learning PLCs, get
PHIL'S BOOK (or video, if you learn better watching things move).
Step-by-step. Plain English. It will not just teach you about PLCs, but might even show you how to
think in the methodical manner required, not just for PLCs, but programming in general.
I repeat:
IN THIS JOURNEY, THERE ARE NO SHORTCUTS.
But there is a lot of running back home (Step 1 - Make an I/O list) to get the thing that you forgot to take with you.
Good luck