5 PLC Programming Approaches that Always Work

PLC programs can be constructed in many different ways and still achieve the same external results.  I thought I would share five of our approaches, that always work.

Approaches to Programming

The best approach is the one that provides the desired functionality and is easy to understand and maintain.  Since we are in the business of providing solutions for our customers which includes the development of PLC programs that they are able to understand and maintain we need to pay close attention to our overall and detailed approach to providing solutions.

1. Program Flow

Programs should be developed to mimic and flow along the same lines as the functionality required of the machine or system.  This will lead to the development of programs that are easy to grasp and maintain by someone who understands the functionality requirements of the machine.

2. Conditions Required for Program Advance

When machine functions have to occur in a particular order it is best to stage these functions based on feedback events from the machine or process.  The use of timers alone to gate the progression of a machine sequence should be avoided since this scenario is easily broken if reactions speeds, air pressure, or motor speeds are changed.

3. Arrangement of Like Function Bits at Consistent Relative Offsets

When multiple devices are to be controlled within the same program the bits that represent Like Functions (Opened, Closed, Start, Fault, etc) for these devices (Valves, Motors, Scaled analog values, etc) should always be arranged at consistent offsets so that it is easy to remember that for instance that the 5th bit in a DWord always represents Start or Open.

4. Use of Set and Reset Functions

In almost all cases the use of a Set coil instead of a contact sealed latch is a bad idea.  There are places where Set and Reset bits can be used effectively but they almost always lead to more involved programming and leave the process open to failure at power up, return from E-Stop, or error conditions.

When Set or Reset functions are used in an application it is very easy to create situations where the state of a bit is Set or Reset then it is abandoned if for instance the machine cycle is aborted.  This leads to having to create massive recovery blocks to return the bits to their startup or standby state before restarting the machine.

If a contact sealed latch simply includes the Running or in Cycle bit of a process the latch seal will be broken any time the process is stopped and the bit will automatically be returned to the startup or standby state.

5. Stepped Approach to Sequential Machine Programming

Many applications require that functions occur in a predefined or minimally modifiable sequence.  In these cases it is relatively easy to establish a series of steps that must occur and the conditions required to be met to advance to the next step.

One method that is very easy to understand and straightforward to implement is the concept of a step pointer and predefined step constants.

In this approach a common step pointer is defined and a symbolized constant value is also defined for each step in the sequence.  If more steps are required at a later time just define more constants.  Then use a comparison to check the Step number against the Step constants to determine which functions should be performed when.  When a particular function has been successfully performed simply move the next step constant into the Step pointer.

In the example below the sequence will advance as follows:

  • Step 1

  • Step 2

  • Step 3

  • Back to Step 1

Step_Progression.png

I hope you can get some benefit from these proven approaches.  If you get stuck you can always contact us at (603) 431-5877 or scarter@ltsoftware.com

Stephen Carter