programming a PLC

franchois13

Member
Join Date
Nov 2008
Location
london
Posts
76
Hi there, I've been involved in some plc program modification but haven't done writing program from scratch. Is there a particular procedure or methods on how a program should be constructed or as long as you get what you want that would be fine. thanks...
 
I always start with an I/O point list. Then I create a list of alarms, and then a list of adjustments accessible to the operator. Finally I create a functional description that describes in text the sequence of operations and control functions for the system.

Then start writing the program. Use descriptive names for each coil, contact, etc. and lots of comments on each rung. The comments should relate back to the function description.

Group program functions. Put alarms in one section, and control in one section, etc. Keep logically related steps together. I avoid one shots and set/reset as much as possible because they can be hard to debug.
 
I totally agree with Tom's methodology. I too start by listing all the I/O and then start writing my FD.

I don't write any code until I am sure my FD is solid. When I do start coding I refer to my FD religiously. If there are any changes then the FD gets updated first before the code is modified.

There is quite a difference between modifying code and writing code from scratch. You got a blank piece of paper (screen) in front of you and there are seemingly no boundaries.

If you are a newbie and just want to write a small PLC program then I would suggest you start from the first output and then work your way to the last output. Later on you can play with step engines, subroutines, state machines etc if you want to.
 
Last edited:
Tom



I read many of your replies in the forum and have learned a great deal from them. What methods do you use to avoid using one shot and set / reset in ladder logic? I also agree that they can be hard to troubleshoot in a large program
 
I usually use a NO holding contact instead. In series with it is another NC contact that I turn on when the event in question is completed.
 
Tom Jenkins said:
I usually use a NO holding contact instead.

Just to add to Tom's comments, be mindful of the consequence of a processor restart, say in the event of a power failure, or a processor mode switch (Program to Run).

For example, A-B PLCs, when starting up, do a pre-scan on the code, turning off all non-retentive "outputs", which includes internal memory bits.

Tom's "seal-in" circuit won't stay "sealed-in" under those circumstances.

Addresses of Set/Reset or Latch/Unlatch instructions don't get changed by a processor restart, so the instructions have their rightful place in a processor's instruction armoury.
 
Another useful starting point is to breakdown the desired operation into a flow chart this allows you to simplify complexity in thinking and programming. there are advantages to having retentive bits although they can be a nuisance if not properly handled one way to handle retentives is through the usage of first cycle scan rungs. This is extremely important with regards to safety related circuits or circuits that require a specific starting point such as some ram related operations. My access to this site is limited for the time being, others here will willingly expand on my comments. (in the midst of travelling) Good luck
 
My method is similar to tom's, starting with IO, modules to information exchange to HMI, and then making the normal running logic. At the end, I made the faults and alarms checks and the PLC start logic.

I normally use S88, so I need the S/R controls. There is no other way to work with it.
 
plc noob said:
What logic could be used to replace a one shot?

Think about how a one shot works. Then think about how you might write that in code.

We used to have to write our own one-shots because they didn't exist yet... (Modicon 484, 584, 885; AB PLC2, SLC100/150)
 
Why the negativity toward using one shots? It is a useful instruction that I use regularly when it fits.

Set/Reset or Latch/Unlatch instructions also have their places in programming. Sometimes they can be easier to troubleshoot than the seal-in circuit and as daba stated, they maintain state through a power cycle. I have some modes that need to be maintained through a power cycle and others that need to reset automatically, therefore, I utilize both methods.
 
1. Who said something against one shot?

2. Yes, S/R instructions have their usefulness. Like i said for example if you intend to use S88 you don't have other option. You depend on those. But by no chance I believe they are easier to troubleshot.
 
How do you "code" a one-shot

--] [--------------------------------]/[-----------------( )-------
| |
| |
|----------------------( )-------

The first N.O. contact is the conditional that triggers the action that you want to one-shot. The first output is the action. The output on the branch is the tag for the one-shot, and the N.C. contact is of that one-shot tag.

I hope this formats alright once the post is submitted.

Feel free to ask questions. Our lead controls engineer was against using one-shots on our last major project, and this is the "developed" one-shot that we have in our logic.

HTH
 
Format of ladder logic

It didn't format like I wanted. Just know that the second line of ladder is branched around the N.C. contact and the output on the first line.
 

Similar Topics

Hello colleagues, Some time ago I started my adventure with programming. With your help and the courses, things are starting to come together...
Replies
13
Views
660
Dear All, I need a sample PLC program to count the output pulse of a mass flow meter so that a specific amount of mass (for example 100gm)can be...
Replies
2
Views
141
Hi Please I have zeilo smart relay #SR2A201BD but I don't have it's programming cable. Can I use any general usb/rs232 converter? Or need...
Replies
3
Views
124
Hi, Does anyone have thoughts or know of, can point in the right direction any published materials with a plumbing centric point of you explaining...
Replies
1
Views
161
@ All: what is your best guess on a potential range in increase in efficiency in % (i.e. saved programming hours, greater output, etc.) when...
Replies
5
Views
340
Back
Top Bottom