Writing Code

schui

Member
Join Date
Sep 2011
Location
Toronto
Posts
51
Hi All,
How do you learn the correct way to program or write code
I have completed a lot of courses on how each piece of software works
But in these courses you do not learn how to write code
I have seen how different engineers think and how they write things basically doing the same thing only doing it differently,
Is there a standard/ format you can follow
Mostly the only portion of programming I see that is common is safety
I would really like to find out what you experts see in the field and what your experiences are with dealing with engineers/ programmers making the same PLC/ machine/ Process work but doing it completely different than each other
Thank you and I appreciate any opinions
 
there are many posts on this site - Please do a search
- Safety is always the number one concern using the "What Happens If"
But - 99% of the PLC programmers posting on this site, intend that the Major Safety is done via hard wiring externally from the PLC.
With only a few Bits telling the program of the status of the relevant Safety devices. These are also used to stop or reset parts of the program.

There are many ways to write code - some of which are dependant on the PLC's software ability to be easily read.
Sectionalising programs is a good start
Generally a good program is something easily read by others, while fault tracing.
Try to answer these Questions - Others will comment on this
1. Where are the Inputs / Outputs
2. How does the Manual Work
3. How does the Automatic Work
4. How Does the HMI get INfo
5. How Does the HMI send Info
6. Temperature, analogue, Servo, Motor, the list continues
 
You should look at the work of others, especially working examples.

You will find that certain styles lend themselves better to certain types of machinery and you can mix and match those styles and techniques when necessary.

When writing a program for a machine, you need to fully understand the machine, and the product(s) it processes first, then determine the control hardware you need, then go about designing the control algorithm which might be a simple list of steps, or a twenty page flowchart.

After the plan is laid out, lay out the memory and file structure of the PLC, and start entering your code, one chunk at a time according to the plan...

Search the forum for other good discussions on the subject.
 
Is there a standard/ format you can follow
For each function (generally a PLC Output), ask yourself: "If I was a fairly new troubleshooter trying to figure out why this output no longer works correctly, what would I need to know about it?"

Then write a description that includes all those things a trouble-shooter might need to know. Put that description on a rung comment for that particular PLC Output. Now you are ready to write the logic for this output. Do that, then go on to the next Output and do the same thing all over again. This procedure will lead you to a good programming method. Programming Methods are similar to the methods that authors use to write books - each has a method that works best for him, and it may not be the same as the next guy's method.

At first you will think "How silly! What a waste of time! I know everything I need to know without putting it in a comment." Five years from now you may have to go back and makes some changes or additions to a program that you wrote. Believe me, you will then be saying things like "What was I thinking here? What factors did I use to come up with that formula? Where in the heck did that number come from? How was the input module configured? What was the control voltage level? Why did I not make a note of it so that I don't now have to do it all over again?"

If you have a perfect photographic memory and total recall, then you don't have to use comments to jog your memory. But those that follow after you will curse the ground you walked on. That guy trying to remember how the he@@ that old program ever could have worked could be you. It reminds me of a sign I saw back in my wild young days in a pool hall. There was a 5-gallon bucket in the corner that served as the restroom. A sign above the bucket said "Stand close, pee straight. The next guy could be you with a hole in your shoe."
 
Last edited:
as you learn to write code i would suggeat the following:
study your machine operation.
write down the sequence in simple terms and keep expanding on it until you add the i/o.

ask "what if questions". if you can ask a question your code needs to be able to handle it.

when you use latch/unlatch commands, use them only once per bit. multiple latch/unlatch commands is very confusing.

THINK of those who will be troubleshooting your code. i have and will continuie to say that the machine can cost billions of dollars, but if maintenance cannot troubleshoot the code and get it running, its a piece of junk! when management gets involved, they might hire someone to rewrite the code, and it will be the best piece of equioment in the world, simply because the code was well documented and easy to follow.

when writing code, also write a manual with a sequence of operations, calibration, setup, and general operations.

this are my suggestions and opinion.
there are as many different ways to write code as there are members of this website.
get with maintenance and work together for a common goal, life will be much easier than forcing someone to accept a machine that they know nothing about.

working together you will learn a lot from each other.

regards,

james
 
It may be the proper time to introduce the concept of "Plane Code". Simply put, there are two types of Plane Code applied to any machine's PLC.

Type A Plane Code is that which you write on the airplane on your way to commission a new machine.

Type 2 Plane Code is that which you write so that you can catch your scheduled flight home from the commissioning.

Some people claim there is a Type II plane code defined as that which you write to prevent your boss from getting on an airplane to get to the job site where he will fire your sorry a$$ as soon as he sees what a mess you've made of things.
 

Similar Topics

Hello, i am currently trying to create a plc programme from my Tia portal v16 for a package filling machine. But i am kinda new to the plc stuff...
Replies
48
Views
17,459
i am new to these things. I have no intention of using this in a commercial way whatsoever. I wanted to write a small plc programme for myself. We...
Replies
18
Views
7,934
Hi, I use Excel to write some routines and was wondering if it is possible to add rung comments when doing so? Excel function: ="MOV "&[@[Range...
Replies
2
Views
2,561
The communication is between micrologix 1100 and GE power relay MM300, I have the following informations : And the command adress is as...
Replies
0
Views
1,261
Hi all. Sorry for the mayby extreme newbee questions writing Mitsubishi ladder code but there are something I can't figure out :-) I have a demo...
Replies
6
Views
4,347
Back
Top Bottom