Best programming practices

ganutenator

Lifetime Supporting Member
Join Date
May 2002
Location
kansas
Posts
1,440
I'll start.
Name coils with their true state.
For example, if the photo eye is light operate, make the coil PE Clear.
That way, when you see the normally closed ref, you just read the normally closed contact as NOT the comment.
 
poor comment: this oneshot runs the timer for 5 seconds.
good comment: i put this timer in here to try and keep those kids from playing zz top.
 
1 Code comments don't cost you so much
2 KISS - Keep it simple stupid

KISS - Keep it Stupidly Simple

Code should read like a book. Show it to the people that are going to be troubleshooting the system. Use their terms for the devices and parts of the machine in your code.
 
When making additions to a program, consider how your contribution will fit with the overall flow of the program.

Does the system already have 30 valves programmed a certain way and you are adding a new, similar valve? Mimic the existing programming unless there is a very good reason not to. Is all of the analog scaling done in function block and you usually write scaling in ladder? Put your new scaling in function block anyway.

This idea can also apply to tag naming, comments, subroutines, etc. It can be painful to troubleshoot a system with a program that has been worked on by many different people, all doing things their own way.
 
poor comment: this oneshot runs the timer for 5 seconds.
good comment: i put this timer in here to try and keep those kids from playing zz top.

Agree with this. Having comments isn't useful unless they have a point. Most code is relatively straightforward in WHAT it does, the bigger question is WHY are we doing that.
 
Seeing comments like "This is my work around" to an issue that could have been fixed quite easily sends chills up and down my spine. Why are you even doing this?
 
A comment that irritates me is something like "Move data to XXX".

I can readily see that from the instructions. What I want to know is why was the data moved.
 
KISS - Keep it Stupidly Simple

Code should read like a book. Show it to the people that are going to be troubleshooting the system. Use their terms for the devices and parts of the machine in your code.

By using multiple simple rungs instead of one complex rung.

Modern PLCs have lots of RAM, Internals and speed.
 
For the love of sanity -
Don't put multiple contacts before a one-shot
Expect any Set/Reset to get stuck in the wrong state and plan accordingly
If you send a signal to another piece of code have the recipient destroy it
Scan order matters
 
I have many small snippets of code from one of our integrator projects that contains multiple bits called "do_not_forget". I guess he forgot!
 
If during coding you figure out that the design documentation is incorrect or doesn't match your implementation, UPDATE THE DESIGN DOCUMENTATION.

Have complete design documentation.
 

Similar Topics

I've been doing PLC programming for about 15 years now but all of my experience has been with Allen-Bradley PLC's. A few months ago I started a...
Replies
5
Views
3,158
Hi All - I have a system that I am setting up with about 50 axes of motion. There are 10 stations total where 9 of them are exactly the same. I...
Replies
0
Views
1,381
If I have a program that requires 10 different PID loops should I 10 different period tasks (using RSLogix5000)?
Replies
4
Views
2,338
I am looking for Ladder programming Best Practices and Tips. My Background is mostly AB and AD some Omron. Just looking for things to use in...
Replies
28
Views
15,385
and go! I'll start. Always comment the Boolean instruction for their TRUE state. For example. It is much easier to read a normally closed contact...
Replies
65
Views
21,528
Back
Top Bottom