Logic flow

I'm new to this and I'm trying to learn Allen Bradley and Siemens side by side.
I'm familiar with basic commands instructions comparators etc. For some reason my mind cannot wrap around big picture logic flow. Wondering if anybody has some good podcasts or YouTube videos to help me get the big picture
 
For any given homework assignment or task at work, you must consider these instructions as the customers specifications.

First and foremost of importance is to get the companies / corporate specs for the following:
plc brand, power supply, photo cells prox switched, valves, enclosures, everything you can !
for example, putting in an Allen Bradley plc when the corporate standard is GE will get you in big trouble !
your customer now has to buy software, interface cables, spare parts, pay for training....
there are already spares of GE plc's and components in the store room.

1. read the specifications several times.

2. write down your understanding of what you read in a step by step fashion.

3. review what you wrote down and see if it makes since, modify if necessary.

4. Get with the mechanical designer and discuss the project openly and honestly. When your opinions differ in regards
to an operation, discuss it, don't ignore it.
there must be a reason for a difference of opinion. modify your instructions and i/o to accommodate the mechanical
design if possible. Mechanical design may have to be changed due to plc programming limitations.
YOU BOTH MUST be in agreement on all points of operation before going to step 5. you may have to modify/rewrite
step 2 and 3 based on the discussion.

5. step through your notes again this time, you are the one following the instructions. In other words, you are the
plc. Write down on paper the events you are doing.
For example, turn on hydraulic motor 1, write down hydraulic motor 1 on. If a sensor is needed, write that down.

6. Continue through the instructions. When you turn off the motor, mark a line thru it.

7. Go through your instructions with all the sensors, motor aux. contacts, outputs documented. Modify if necessary.

8. Repeat step 6 until no changes are made.

9. Try to group your data words into some organized fashion. The more programs you write, the more organized you become

10. Write the plc program using your notes in a step by step manner.

10A Over half way through writing the program you WILL realize a different/better way of doing something you are
almost done writing (or a new spec will require it) and you will completely rewrite it

10B It WILL happen more than once.

Note: 10A and 10B added to list. thanks Aabeck, member plctalk.net forum

11. DOCUMENT EVERYTHING!!! You may remember things today, but in 5 years and hundreds of programs later, you won't
remember, especially at 2 am, so DOCUMENT EVERYTHING. use easy to understand tags and rung comments.

12. MAINTENANCE is your best friend and your worst enemy.
if you work with them and find out what they can do, write the program where they can trouble shoot the program.
they will be able to fix the problem and everyone will be happy.
BUT
if you write the program to where you are the only one who understands what is going on, maintenance can't fix the
issue, the machine is down, production is down, management hears about it, your boss hears about it, then you hear
about it - rewrite the program or else. you get calls all hours of the day and night.
this still holds true, a machine can cost a billion dollars, but it's not worth 10 cents if maintenance cannot
trouble shoot the issue and fix the issue. everyone has their own style of programming and you must develop your
own way as well.

13. When the customer is in your shop and brings maintenance, discuss things with them, let them see your code, be open.
if they make suggestions, write them down, don't ignore them. their ideas may save you days of programming.

14. Install the program and leave in program mode if possible so you can to debug your i/o

15. When writing your instruction manual(s), use your notes from step 9. Use easy to understand English language.
specify the i/o, timers, counters, outputs when possible. this will help maintenance even more to see what is going on.

16. Question for you, when is a machine and plc the most dangerous and why?
When it s first powered on when power is first applied to a machine, you don t know how things are wired.
When you energize the plc outputs, you don t know how they are wired.
When the plc is put into run mode the first time, it will do what you told it to do, NOT what you wanted it to do.

17. Debug the program.
Remember, the program will always do what you told it to do, NOT what you wanted it to do.

18. IF you can ask a what if this happens type of question, YOU MUST have an answer, EVEN IF its a 1 in a million
chance. that what if situation will happen in the first 30 minutes of production runoff in front of the customer.
 
#1 pay careful attention to everything @James Mcquade wrote.

In addition to that, I am going to try to address your "big picture" query, but instead of big picture, you might want to think of big digital video. Bear with me for a bit while I cover some background first:

Background

A PLC program implements a model of the process it controls. The reason I use the term "model" is that the PLC program's implementation only knows, or cares, about a limited number of aspects of the process. The PLC might need to know about, i.e. measure, the level in the tank; the PLC is unlikely to need to know about the color of the operator's socks.

The PLC user program measures the model by reading inputs (sensors) that are measuring the process. It reads values from prox sensors; from level switches; even from analog signals like temperatures, flows; etc. Note that the input (bit) values as used by the PLC user program are in memory i.e. the PLC operating system, in the guise of the "I/O scan," and input modules measure electrical signals coming in and convert them to zeros and ones in memory with tags (labels or names or addresses) such as X123 or I:4.5/6 or Local:7:I.Data[8].9. Those tags are memory references; they follow the electrical signals from the field sensors; they are specifically not the electrical signals, rather that are no more a discretized model of the process kept in specific places (addresses) in PLC memory.

The PLC user program effects changes in the process by writing output values to the process. Again, PLC operating system and I/O scan is between (i) the (bit) values written to memory by the user program, and (ii) the electrical signals sent via the physical output modules to the process. The output image map memory has tags like Y123, O:4.5/6, Local:7:O.Data[8].9. The output electrical signals, driven by the bit values from memory, will turn motors on and off, extend and retract cylinders, control valve positions, etc.

The third piece, after inputs and outputs, of a PLC user program is the PLC-internal memory, with tags like D123, N7:8, Flow_rate (for a tag-based system). PLC-internal memory is used to maintain things that are neither measured (inputs) nor written (outputs), like "what was the RUN state of the process from the previous scan cycle?" It is kept in memory. "Memory" is a time word: each bit of memory remembers what its value is, at least until that value is overwritten as some point in the future.

The summary point to here is that the PLC user program measures, changes, and maintains the model in memory.

Finally, the PLC is a bit-driven, i.e. discrete, device. It is discrete in its ability to read analog inputs, detect states of on/off/open/closed/.../not... binary sensor inputs, write analog outputs, and set states of binary on/off/lit/dark/... binary outputs. It is also discrete in time in its behavior i.e. it can only do one thing at a time*. And at the center of that discrete time ecosystem are the program scan cycle and the I/O scan cycle**. As I have said once or twice in the past, PLC programming is primarily about time, and the scan cycle is the clock.

Why Big Digital Video instead of Big Picture

It's that final point, that the PLC user program is executed once in time, and then again, and again, in a never-ending series of discrete events. So every scan cycle is like a Big Picture, with (i) the input signals being read into memory, (ii) the user programming examining the those values as well as the value of memory written from a previous scan cycle and using that to implement behavior by writing values back to memory, and (iii) the output memory value being written to the physical output signals. But since that event is repeated over time, with the behavior being adjusted as the memory values change over time, it not just a single Big Picture but a series of Big Pictures i.e. a Big Digital video.

The PLC program you write will discretely observe the input image map memory values and use that to choose the values to write to the output image map memory. It will do it one scan cycle at a time, but will repeat so quickly that it will seem continuous over time. And so time is really what the PLC is about. To implement that behaviour, you need a model of the overall system, i.e. of the combination of the process plus the feedback control provided by the PLC.

You will need that model to be first of all in your head, which is why @James Mcquade's steps are so important, but that is what they are focused on delivering.

Once you have the model in your head, you need to figure out how to implement using the capabilities of the chosen PLC. That is actually the easiest part, once you have some experience.

That is the big picture.



* there can of course be multiple CPUs and thread-like time- and interrupt-driven routines, but even an interrupt routine will stop the continuous task.

** there are of course many more things like communication tasks, houskeeping, watchdog timers, etc.
 
17. Debug the program.
Remember, the program will always do what you told it to do, NOT what you wanted it to do.

Once you have the model and have started programming and testing, this is the most important item to remember. Because when the PLC does not do what we want it to do, our first instinct will be to wonder what is wrong with the PLC that it is not doing what we told it to do, i.e. we confuse "told it" with "want it." This forum is littered with threads of those who made that mistake ("Instruction XYZ does not work"). That way lies madness: by starting with that question and its underlying assumption (i.e. that the PLC is not doing what we told it to do), it is only the rarest stroke of luck that will enable us to find the actual problem. Those who wander down this infernal path can spend weeks there.

Once we overcome that instinct (i.e. get burned enough;)), we ask a different question: how, and where in the program, did we tell it to do that? We ask that question because we assume the PLC is indeed doing, mercilessly and inexorably, exactly what we told it to do. Once we ask that question, we will very quickly drill down to find the answer.

TL;DR

I am into my fifth decade of programming*. Dozens of times I thought I had found a bug in a compiler, because the code was not doing what I "told" it to do, i.e. I made the wrong assumption. Do you know how many times I actually did trigger a compiler bug? Exactly once, that was fairly recently, and we are talking about a couple dozen different programming languages. Of course by that time it took me a day or so to actually convince myself it actually was a compiler bug, but that was short compared to the time wasted each of many times earlier in my career going the other way.

* not with PLCs until recently; the syntax and grammar are different, but the same principles apply.
 

Similar Topics

There have been many threads started about integrating the signal from an analog flow sensor to get a total volume along with comments (some by...
8
Replies
2,130
Views
Hey all, I'm looking for a little advice. I developed a system with 16 different lines, and a color injection. This mixes all the raw...
1
Replies
3,167
Views
Hello. I'm mounting a Sarco Spirax Flow Meter going to a Red Lion Data Station Plus. From the DSP we are going to a Compaq logic controller. This...
1
Replies
3,918
Views
Greetings In my project, there are three control valve One of the hot water line with a diameter of 200 Another on the cold water line with a...
11
Replies
4,704
Views
I'm wondering if anyone has encountered some decent software out there for documenting logic flow, particularly for control systems. Preferably...
12
Replies
7,993
Views
Top