Good vs Bad programming?

tgeyer

Member
Join Date
Apr 2012
Location
Las Cruces NM
Posts
2
Good morning, First time using the forum and first time programming a plc. I am building a controller for a 100 hp irrigation well. I am using a Click analog plc and Cmore micro hmi. There are 8 inputs(phase condition, valve position, control voltage,ect...) that must be true before the well starts. If any one of the inputs goes false the well must shut down. If one of the inputs goes false I want the hmi to show the fault, and send a signal to a scada system.
My question is this..can I put all the inputs on one rung of code or is it better to put them each on a separate rung ? I want the program to be simple but easy to understand in my absence. Would this be "good" or "bad" programing?


Thanks for your thoughts Tom
 
This is really down to programmers preference. I would use one rung like you suggested and if its a small program have the alarms underneath.
 
I think you can go either way on that one. Combining is good when it makes sense due to a logical grouping, which you have. It gets bad when someone combines many different things to save a few lines of code in a way that isn't understandable.
 
Welcome to the forum!

Absolutely no reason why not to putting in one rung. Have you given though about how you will prioritize your messaging if more than one fault occurs concurrently?
 
Good morning, First time using the forum and first time programming a plc. I am building a controller for a 100 hp irrigation well. I am using a Click analog plc and Cmore micro hmi. There are 8 inputs(phase condition, valve position, control voltage,ect...) that must be true before the well starts. If any one of the inputs goes false the well must shut down. If one of the inputs goes false I want the hmi to show the fault, and send a signal to a scada system.
My question is this..can I put all the inputs on one rung of code or is it better to put them each on a separate rung ? I want the program to be simple but easy to understand in my absence. Would this be "good" or "bad" programing?


Thanks for your thoughts Tom

I agree with some of the other responses that putting it all on one rung would be OK and is probably just a preference thing.

That being said, you may need to buffer some of your inputs with a timer to avoid nuisance trips. So your program may be several rungs longer and a little more complex than you described here.

Have fun.
 
While there is certainly nothing wrong with putting all of the contacts on one rung, that isn't my preference. I find de-bugging logic and analyzing machine failures is easier if I group the contacts, set a group coil, and then use a contact from that coil in my "master permissive" rung.

For example, "control voltage OK" and "no phase imbalance" would be grouped as "Electrical System OK". If you have multiple valves you could group all of the open and closed permissives on one coil, called "Valve Positions OK".

The result is shorter rungs, which are easier to diagnose at a glance. Long rungs tend to run off on screens and printouts, and you can't really absorb eight status contacts in one look.

More importantly, good programming means lots and lots and lots of comments, and descriptions of I/O and internal coils and register names etc. that are intuitively obvious as to their function. Good code isn't necessarily the one with the most elegant functions, or the least memory usage. Good code is a progam that can be easily understood and diagnosed five years later when another programmer sits down to work with it. (Or even yourself - it is amazing how strong the powers of forgetting are after five months, much less five years. I have often heard myself say "What was I thinking?")
 
More importantly, good programming means lots and lots and lots of comments, and descriptions of I/O and internal coils and register names etc. that are intuitively obvious as to their function. Good code isn't necessarily the one with the most elegant functions, or the least memory usage. Good code is a progam that can be easily understood and diagnosed five years later when another programmer sits down to work with it. (Or even yourself - it is amazing how strong the powers of forgetting are after five months, much less five years. I have often heard myself say "What was I thinking?")


Could not agree with you more Tom!!
 

Similar Topics

This week I ran into a customer program that repeatedly used an XIC bit named Off. There was no destructive OTE or OTL setting this bit to...
Replies
55
Views
9,689
I am programming in Siemens Step 7. I created an FB which controlles a Lenze profibus inverter. In this FB I also use stat variables. The instance...
Replies
14
Views
5,258
Hi All, We've been down this road several times before but I want to get this off of my chest. Here goes. I am not a big fan of sequencer...
Replies
16
Views
6,283
Hello all, I am brand new here :cool:. I'm limited in my controls knowledge but always trying to learn more. I recently started working at a...
Replies
14
Views
333
Dear All, I have an Mitsubishi PLC (FX1N-40MR) and PLC backup was taken and i compiled the program and its showing 0 error. then I tried to...
Replies
8
Views
272
Back
Top Bottom