Simplelogix said...
"And yes, I am looking to be an ace in motion control. In this regard I must also ask another question. I hear people saying, "PLCs? Anybody can program one. You dont need to be an engineer to do PLCs". Does that mean that spaghetti code is the norm in the industry rather than structured code?"
Sad to say... the answer is yes.
This is because most PLC Programmers have not developed their expertise from an Engineering point of view. There are by far many more Electricians and other non-Engineer types (some of which do an excellent job) than there are adequately trained Process Engineers (some of which do a terrible job, despite having had the training).
Simplelogix said...
"And contrary to the general opinion I mentioned, I find that it is not so easy to program a PLC."
When you say "...program a PLC." that illustrates my comment about "hammer-swinging-programmers looking for a nail".
There is a world of difference between programming a PLC and developing a process.
If your comment means that it is hard to enter code into a PLC, that is one thing. There are a lot of so-called "user-friendly" programming interfaces. Many of them are neither "user-friendly" nor are they intuitive.
However, I hope you mean that it is hard to develop the code that you then enter. That is the proverbial horse of a different color.
Developing the code is by far the most complicated part of developing a process. Even very small and apparently simple processes might require a great deal of careful planning for the code. Using the "classic" PLCnet response... "It depends". The nature of the code depends on everything in as much as everything depends on the code. It's a co-dependence sorta thing.
The biggest problem that programmers make for themselves is when they sit down and begin developing the "process code". They are trying to write their code in terms of the entire process.
That can't help but be overwhelming, confusing and ultimately, the source of most spaghetti-code.
The secret is "Modularity". Don't even consider thinking of code until you have clearly and completely identified the entire process in terms of modules and sub-modules within the modules.
Also... don't even bother trying to create an I/O List at this point. You can't possibly build that list until you "know" what you need!
Caveat: After you finish identifying your modules you will most likely have to go back and redefine your list of modules. This usually happens when you begin to think on the details of how a particular module is to function. Sometimes you find that a module needs something that has not been specified in that module or any others. Sometimes you might find that you haven't really broken a particular module down to its' constituent sub-modules. At any rate, you are bound to revisit this part of the development process many times before you are through.
Once you have your process broken down into a list of modules and sub-modules, begin considering the output devices in that module. Consider the specific process-reasons that you would want to turn on the device. The fewer the number of process reasons, the easier to develop the control scheme. Some devices might turn on for one of several process-reasons... it depends.
Each reason becomes a separate "causal factor". Each of those "causal factors" needs to be developed separately.
Cause-A
---| |---+---( Output )
|
Cause-B |
---| |---+
|
*
*
*
|
Cause-X |
---| |---+
Cause-A gets developed as a single sub-module. Likewise for causes B through X. The Output only needs to see that it has a valid process-reason to run. The Output does not need to interrogate other aspects of the system for a reason to run. It simply sits there waiting for the reason to come. Now, you have to properly develop the "reason".
Aw jeez... I just gotta write that book one day.
The deal is, develop the process one module at a time. While developing the modules, be mindful of information that might be needed from or by other modules. This information is passed in the form of "flags". No module should expend any effort examining the conditions or states within another module. (This does not mean that modules can not share inputs. Sometimes they do... it depends.)
If Module-A needs to know that Module-B is waiting for the next part to be delivered, then Module-A should sit on its' hands until it "sees" the flag from Module-B indicating... "Hey, send the damned part, already!"
As you develop the module, your Input List will essentially write itself.
Gotta go... the plaster has dried and I have work to do.
More info available if you want it... ask some questions.