Best programming practices

damn if I don't miss working for the oil companies and their unlimited budgets.
Love how my portion of the the 150 wasn't quite right, but we cool.
 
All I got right now. I would fire you if you programmed that w/o a really good rung comment.

scratch that.

I'd still fire your ***.

WHY, WHY, WHY, WHY????

You have stated that it is bad, but you haven't given any reason why it is bad. You haven't even come up with 'better' code. I'm all for writing good code, that's why I and others have asked. It isn't obvious to me why it is bad, and apparently it isn't obvious to you either, as you can't explain why its bad or provide code that is better. Since you can't give better code, and the code provided is unacceptable, your solution is to not use any code? Sheesh.
 
WHY, WHY, WHY, WHY????

You have stated that it is bad, but you haven't given any reason why it is bad. You haven't even come up with 'better' code. I'm all for writing good code, that's why I and others have asked. It isn't obvious to me why it is bad, and apparently it isn't obvious to you either, as you can't explain why its bad or provide code that is better. Since you can't give better code, and the code provided is unacceptable, your solution is to not use any code? Sheesh.

I'm sorry, I should stay off of here when I'm drunk.

Only bad memories of that logic where bad programmers didn't intend the functionality.

It will just bring back some ptsd to some of us old timers.

Glad it works for you. Maybe this will help my healing process.
 
Variables that show up as un-used whether because of indirect addressing, located data for HMI, et al. Find a way to make it appear to the programming software that it is used so it doesn't get deleted during an delete unused variables operation.
 
Why is it bad form to have separate lines of instruction that fires off one coil?

Input 1 Coil 1
Line 1 ------------| |---------------------( )-----------



Input 51 Coil 1
Line 15 ------------| |--------------------( )-------------



AB processors throw an error.

I am still at the beginning stages of my programming career.
 
Whatever line 15 tells the coil to do is what it will always do. It will be like line 1 is not even there. If it would let you do it, it would make debugging hard, too.
 
Last edited:
Whatever line 15 tells the coil to do is what it will always do. It will be like line 1 is not even there. If it would let you do it, it would make debugging hard, too.

So if Line 15 is false and Line 1 is true the coil will be false?

If Line 15 is true and Line 1 is false the coil will be true?
 
So if Line 15 is false and Line 1 is true the coil will be false?

If Line 15 is true and Line 1 is false the coil will be true?

Yes. Logic is processed left to right, top to bottom. It helps not to think of them as contacts and coils, because they're not contacts and coils. They're instructions. What's actually happening is when Line 1 is true, the OTE instruction writes a 1 to the assigned address. Then it gets to line 15 and it's false, so that OTE instruction WRITES A ZERO to that same address. OTE instructions do "something" no matter what state the rung is in! It's not like a relay where if you don't send power to the relay, nothing happens. Something will happen every time an OTE instruction is processed. OTLs and OTUs are different. They will do nothing if the rung is false, only if the rung is true, but you need an OTU for every OTL, and that often makes the programming more complicated.

I've never run into a situation where I had to use a double OTE. Heck, very rarely do I ever need to do an OTL or OTU.
 
So if Line 15 is false and Line 1 is true the coil will be false?

If Line 15 is true and Line 1 is false the coil will be true?

You have to know how the PLC scan works. First it looks at the physical inputs, then it solves the logic, then it writes the outputs. When it solves the logic, it will do what line 1 calls for the OTE to be until it solves line 15. Then it will make the OTE what line 15 says. Then it will write the outputs; therefore the actual output will always do what line 15 says.
 
Thank you for the explanation. It make perfect sense.

What is the best way to get a timer to reset itself after it reaches its preset?

I got this to work, but it lack elegance and is a hack job.

Timers.jpg
 
Take out the branch and the 2 TT bits, and voila! A repeating timer

Thank you! Worked like a charm. But how?

When the timer is timing the .DN is not true so the ---|\|---- is of course true.

When the timer hits its preset the .DN is true so the -----|\|------- is false.

I assumed the that the --------|\|-------- would stay false. Is it only false for one scan?

Thanks again.
 

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,180
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,384
If I have a program that requires 10 different PID loops should I 10 different period tasks (using RSLogix5000)?
Replies
4
Views
2,347
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,397
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,569
Back
Top Bottom