Wanting help reviewing projects

Hello I am a controls tech and I’m trying to find someone that would be willing to review a few ACD files I wrote. Getting into beginner roles to write more code from scratch and I am not an engineer but wanting to just get better and get a job with our integrator. Any help would be much appreciated and feedback on program layout, routines etc.
I could email you or whatever is best.

Thank you
 
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.
 
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.
Your best resource for this is an experienced operator. If anyone can F*ck up a machine, its a good operator.

Can safety protocols be bypassed, can sequences be jumped, can quality be compromised, can the machine be placed in a dangerous state. A good solid operator can find these issues and often times help you find ways to correct them.

If the program is weak, a good operator will find a way to turn you machine into a prezel.

James is correct, your best friend is the maintenance ( If you do not want that 2am call). Maintenance best friend are the operators.

Never............never underestimate the power of donuts or the occasional pizza
 
When auto mode, permissives ok, tankPV below 10 and PB start then move to step 10.
10- Fill tank
20 - Mix tank
30 - Drain valve/pump tank
40 - Rinse Fill
41 - Rinse Drain
50 - Complete then ONS batch counter.

Wording and numbers are just fillers as it is not a real project working on, just practicing. Is there a better way to program step seq than to use EQ/GRE and MOV? I guess here it is not bad cause it is not a lot going on.
 

Attachments

  • FillTank_1.PNG
    FillTank_1.PNG
    72.9 KB · Views: 35
  • TankFill_2.PNG
    TankFill_2.PNG
    76 KB · Views: 35
  • TankFill_3.PNG
    TankFill_3.PNG
    71.6 KB · Views: 30
  • TankFill_4.PNG
    TankFill_4.PNG
    69.3 KB · Views: 35
I have been programming PLC's for over 45 years & I prefer to use a sequence number rather than memory bits, I always do it by using say a base of 10 or 100 so first one is 0 = IDLE, 10 = Startup & so on this then allows room for adding extra steps I also group them in perhaps 500 or 1000 for example 0-100 is say batch sequence, 101-200 is CIP & so on.
On more complex batching I even use banks of sequence numbers i.e. 201-300 is Water, 301 -400 veg & so on when the recipe has been downloaded I check the current stage & set the seq. to the corresponding sequence group.
I'm not against memory bits but find seq. steps much better for being able to change things & they are in order not bits all over the place, also iy is easy to jump back or forward & using SET/RESET in many places can be difficult to control & de-bug.
 
Not to shabby, but u to have a fundamental misunderstanding about how PLCs work, especially output coils, which always wetsuit a valu, either a value of 1 or a value of 0, when their rung is evaluated.

1# Watch this video series: - YouTube

2) Look up "duplicate destructive bit."

3) don't feel bad. Almost everyone makes this mistake. The good ones learn and only make it over (intentionally ).

Hint: Rungs 2 and 9, as written, are wrong. They should be a single ORed (parallel branched) rung with a single (i.e. non-duplicate) coil writing to the output bit

Rungs pair 6 and 11, and rung pair 7 and 12, have the same mistake.
 
A really good thing you did is to isolate the Sequence Logic (the rungs that MOV new values into integer tag Seq_Step) from the Business Logic (the rungs that write the output bits based on the current sequence step). It is a my personal preference, but I would also not interleave Sequence Logic rungs with Business Logic rungs; rather I would separate those into separate sections; I might even have separate Permissives_Sequence and Permissives_Business (_Outputs?) routines. And even though it is my personal preference, the fact that you need to fix the duplicate destruct bit errors because a few of the outputs will have values of 1 written to them at multiple steps of the sequence means you cannot completely interleave Business Logic rungs with Sequence Logic rungs.

The rationale is that code is written once, but read many times, so Rule #1 is that it must be as clear as possible what the code is doing. Mixing/interleaving Sequence Logic rungs with Business Logic rungs may make sense to you now, but if those sections separated, then the person trying to troubleshoot this sysem and its sequence (e.g. because of a loose wire) will thank you if the Sequence Logic is in all one place with no distractions, and the same for the Business Logic.

Also
  • Step 0 (Idle?) was excluded in the description of Post #6.
  • the sequence has no way to reset itself to 0 without completing step 50
    • perhaps unless the value of bit/Boolean tag Seq_Active can be written externally e.g. from an HMI
  • the tag Seq_Active is not needed; it is redundant with the value of the Seq_Steptag.
    • all of the XIC Seq_Active, OTL Seq_Active, and OTU Seq_Active, instructions can be removed.
    • Rung 1 can be removed, although I would still have a way to reset the sequence
      • e.g. hold down the Start_PB for 5s
    • Rung 14 can be removed.
  • the ONS instruction on Rung 15 can be removed.
  • There should be a brief comment, describing the process, and not the bits (the code does that already)
Another personal preference: I would place the TON for T_MixerRunTime on Rung 4, so all sequence-related information is available within the Sequence Logic section, so it is easier to see what is happening in one place. Same with the TONs T_RinseDrain, and T_CompleteHold on (current) Rung 15, or maybe re-use current Rung 14 for that instead of unlatching Seq_Active.
 
I have been programming PLC's for over 45 years & I prefer to use a sequence number rather than memory bits, I always do it by using say a base of 10 or 100 so first one is 0 = IDLE, 10 = Start-up & so on this then allows room for adding extra steps I also group them in perhaps 500 or 1000 for example 0-100 is say batch sequence, 101-200 is CIP & so on.
On more complex batching I even use banks of sequence numbers i.e. 201-300 is Water, 301 -400 veg & so on when the recipe has been downloaded I check the current stage & set the seq. to the corresponding sequence group.
I'm not against memory bits but find seq. steps much better for being able to change things & they are in order not bits all over the place, also it is easy to jump back or forward & using SET/RESET in many places can be difficult to control & de-bug.
This also makes it very easy to add additional, recovery or bail-out states at any point.
 
Ah. I did not look too closely at the code i just saw the seq. Var and how how it was used so yes a common mistake using duplicate out coils for physical outputs as already posted due to the way the program is scanned it is only the last instance of a duplicate coil will be at the state of the logic driving it
 
In terms of the debate of using EQU statements or memory bits...

Using the EQU statements is more friendly to the programmer because it does allow you to add intermediate steps/states.

HOWEVER, when an technician needs to troubleshoot at 3am, how is he supposed to know what steps 10 or 13 or 27 are? Using memory bits that can carry descriptions makes trouble shooting much easier. AND the memory bits have an singular output in exactly one rung, so you can cross reference and go directly to the rung that sets that step/condition.

As an intermediate solution, I would encourage you to add rung comments that help explain the steps/states. Its a lot more work, but it makes it a lot easier for the next guy (and for you too)
 
It would be assumed that any decent programmer would add rung comments if they have used symbolic text for bits, also quite easy to search a a string like 10, 20 etc. in most IDE's. so really a no brainer.
 
Even though I agree with the more experienced people that the pattern for handling sequences by MOVing constant values into an integer STEP_NUM tag to keep track of state is best, you might want to look at the Step pattern, number 8 here, which has a single bit for each step to indicate when that step is active.

It would not be a pointless exercise to use the Step pattern to code your sequence, to compare the results, and to have both patterns in your toolbox.

In one sense, the two patterns handle the Sequence Logic in a similar way: they are changing bits.

The sometimes awkward part about the bit-based Step pattern is that the code needs to clear each old step's bit value when it transitions to a new step, That is simple when there is only one possible sequence of steps (step 0/Idle→step 1/Fill1→...→step 0/Idle), as it can be handled by the Start/Stop Circuit pattern (number 3 at that same website), by making the new step's bit be the Stop Condition for the old step. If there are multiple paths through the steps, though, then it can get a little more involved, but still doable (multiple new-step bits form a compound Stop Condition for the old step).

The integer step pattern makes "turning off" the old step simple: the STEP_NUM tag comprises the current step in a single integer entity, so the MOV of the new step number value into that tag cancels/stops the old step simply overwriting the value (bits) of that STEP_NUM tag.

On the issue of using step numbers that have no meaning, using named tags for the constant step numbers is one solution, but you could also use string tags, instead of integers, as step names. It is far less CPU- and memory-efficient to be sure, but CPUs are fast and memory is cheap. It would also have the benefit that an HMI could use the string step tag directly to display the current step.
 

Similar Topics

Any ideas where I could buy software without going through my company to get better at programming.
17
Replies
890
Views
Hello, I have a PID block in my program controlling pump speed in order to get a correct Differential pressure. The way I have it set up is the...
3
Replies
2,113
Views
I am running 2 Beckhoff Industrial PC's that are identical, just different computer names and IP addresses. I connect remotely using “Choose...
4
Replies
4,593
Views
Here is a little background before I ask my question. I am an aircraft machinist by trade and have been for close to ten years. The job pays in...
25
Replies
8,950
Views
I've got an AB PLC5/40E and I will be using 14 Keyence lasers for continuous level measurement (wood products), thickness, side-to-side thickness...
2
Replies
5,940
Views
Top