Sunday, 31 August 2014

Features of PLC including the ladder example

Features:


The main difference from other computers is that PLCs are armored for severe conditions (such as dust, moisture, heat, cold) and have the facility for extensive input/output (I/O) arrangements. These connect the PLC to sensors and actuators. PLCs read limit switches, analog process variables (such as temperature and pressure), and the positions of complex positioning systems. Some use machine vision. On the actuator side, PLCs operate electric motors, pneumatic or hydraulic cylinders, magnetic relays, solenoids, or analog outputs. The input/output arrangements may be built into a simple PLC, or the PLC may have external I/O modules attached to a computer network that plugs into the PLC.





How Does A PLC Operate?
There are four basic steps in the operation of all PLCs; Input Scan, Program Scan, Output Scan, and Housekeeping. These steps continually take place in a repeating loop.

Four Steps In The PLC Operations
1.) Input Scan
  • Detects the state of all input devices that are connected to the PLC

2.) Program Scan
  • Executes the user created program logic

3.) Output Scan
  • Energizes or de-energize all output devices that are connected to the PLC.

4.) Housekeeping
  • This step includes communications with programming terminals,
    internal diagnostics, etc...
programmable logic controller operation
These steps are continually
processed in a loop.



Scan time:

A PLC program is generally executed repeatedly as long as the controlled system is running. The status of physical input points is copied to an area of memory accessible to the processor, sometimes called the "I/O Image Table". The program is then run from its first instruction rung down to the last rung. It takes some time for the processor of the PLC to evaluate all the rungs and update the I/O image table with the status of outputs. This scan time may be a few milliseconds for a small program or on a fast processor, but older PLCs running very large programs could take much longer (say, up to 100 ms) to execute the program. If the scan time was too long, the response of the PLC to process conditions would be too slow to be useful.

As PLCs became more advanced, methods were developed to change the sequence of ladder execution, and subroutines were implemented. This simplified programming and could also be used to save scan time for high-speed processes; for example, parts of the program used only for setting up the machine could be segregated from those parts required to operate at higher speed.

Special-purpose I/O modules, such as timer modules or counter modules, could be used where the scan time of the processor was too long to reliably pick up, for example, counting pulses from a shaft encoder. The relatively slow PLC could still interpret the counted values to control a machine, but the accumulation of pulses was done by a dedicated module that was unaffected by the speed of the program execution.

System scale:

A small PLC will have a fixed number of connections built in for inputs and outputs. Typically, expansions are available if the base model has insufficient I/O.

Modular PLCs have a chassis (also called a rack) into which are placed modules with different functions. The processor and selection of I/O modules are customized for the particular application. Several racks can be administered by a single processor, and may have thousands of inputs and outputs. A special high speed serial I/O link is used so that racks can be distributed away from the processor, reducing the wiring costs for large plants.

User interface:

PLCs may need to interact with people for the purpose of configuration, alarm reporting or everyday control. A human-machine interface (HMI) is employed for this purpose. HMIs are also referred to as man-machine interfaces (MMIs) and graphical user interface (GUIs). A simple system may use buttons and lights to interact with the user. Text displays are available as well as graphical touch screens. More complex systems use programming and monitoring software installed on a computer, with the PLC connected via a communication interface.

Communications:

PLCs have built in communications ports, usually 9-pin RS-232, but optionally EIA-485 or Ethernet. Modbus, BACnet or DF1 is usually included as one of the communications protocols. Other options include various fieldbuses such as DeviceNet or Profibus. Other communications protocols that may be used are listed in the List of automation protocols.
Most modern PLCs can communicate over a network to some other system, such as a computer running a SCADA (Supervisory Control And Data Acquisition) system or web browser.
PLCs used in larger I/O systems may have peer-to-peer (P2P) communication between processors. This allows separate parts of a complex process to have individual control while allowing the subsystems to co-ordinate over the communication link. These communication links are also often used for HMI devices such as keypads or PC-type workstations.

Programming:

PLC programs are typically written in a special application on a personal computer, then downloaded by a direct-connection cable or over a network to the PLC. The program is stored in the PLC either in battery-backed-up RAM or some other non-volatile flash memory. Often, a single PLC can be programmed to replace thousands of relays.

Under the IEC 61131-3 standard, PLCs can be programmed using standards-based programming languages. A graphical programming notation called Sequential Function Charts is available on certain programmable controllers. Initially most PLCs utilized Ladder Logic Diagram Programming, a model which emulated electromechanical control panel devices (such as the contact and coils of relays) which PLCs replaced. This model remains common today.

IEC 61131-3 currently defines five programming languages for programmable control systems: function block diagram (FBD), ladder diagram (LD), structured text (ST; similar to the Pascal programming language), instruction list (IL; similar to assembly language) and sequential function chart (SFC). These techniques emphasize logical organization of operations.

While the fundamental concepts of PLC programming are common to all manufacturers, differences in I/O addressing, memory organization and instruction sets mean that PLC programs are never perfectly interchangeable between different makers. Even within the same product line of a single manufacturer, different models may not be directly compatible.


Digital and Control Signals:

Digital or discrete signals behave as binary switches, yielding simply an On or Off signal (1 or 0, True or False, respectively). Push buttons, limit switches, and photoelectric sensors are examples of devices providing a discrete signal. Discrete signals are sent using either voltage or current, where a specific range is designated as On and another as Off. For example, a PLC might use 24 V DC I/O, with values above 22 V DC representing On, values below 2VDC representing Off, and intermediate values undefined. Initially, PLCs had only discrete I/O.

Analog signals are like volume controls, with a range of values between zero and full-scale. These are typically interpreted as integer values (counts) by the PLC, with various ranges of accuracy depending on the device and the number of bits available to store the data. As PLCs typically use 16-bit signed binary processors, the integer values are limited between -32,768 and +32,767. Pressure, temperature, flow, and weight are often represented by analog signals. Analog signals can use voltage or current with a magnitude proportional to the value of the process signal. For example, an analog 0 - 10 V input or 4-20 mA would be converted into an integer value of 0 - 32767.

Current inputs are less sensitive to electrical noise (i.e. from welders or electric motor starts) than voltage inputs.

Example:

As an example, say a facility needs to store water in a tank. The water is drawn from the tank by another system, as needed, and our example system must manage the water level in the tank.

Using only digital signals, the PLC has two digital inputs from float switches (Low Level and High Level). When the water level is above the switch it closes a contact and passes a signal to an input. The PLC uses a digital output to open and close the inlet valve into the tank.

When the water level drops enough so that the Low Level float switch is off (down), the PLC will open the valve to let more water in. Once the water level rises enough so that the High Level switch is on (up), the PLC will shut the inlet to stop the water from overflowing. This rung is an example of seal-in (latching) logic. The output is sealed in until some condition breaks the circuit.

|                                                                                  |
|   Low Level      High Level                 Fill Valve    |
|------[/]------|------[/]----------------------(OUT)--------|
|               |                                                                  |
|               |                                                                  |
|               |                                                                  |
|   Fill Valve  |                                                            |
|------[ ]------|                                                              |
|                                                                                   |
|                                                                                   |

An analog system might use a water pressure sensor or a load cell, and an adjustable (throttled) control (e.g. by a valve) of the fill of the tank.

In this system, to avoid 'flutter' adjustments that can wear out the valve, many PLCs incorporate "hysteresis" which essentially creates a "deadband" of activity. A technician adjusts this dead band so the valve moves only for a significant change in rate. This will in turn minimize the motion of the valve, and reduce its wear.


A real system might combine both approaches, using float switches and simple valves to prevent spills, and a rate sensor and rate valve to optimize refill rates and prevent water hammer. Backup and maintenance methods can make a real system very complicated.

Thursday, 28 August 2014

Fundamental concept of PLC - Boolean Algebra

AND, OR and NOT

Life is full of decisions. What is true for us is also true of PLCs. We gather information (input) and based on that we make choices that determine our output. All though I've always found computers to be quite a bit more logical then human beings.

For an example of how we use logic in everyday life consider these statements:

If Tommy OR Bob want to play basketball then I'll play too.
It's 6 o'clock AND I'm NOT hungry therefore I'm going to keep playing.
If Mom comes out AND orders me inside OR it get's dark then I'll stop playing.

Now these are pretty simple decisions especially if you're a ten year old boy.  You'll notice that they all involve three types of comparisions: AND, OR and NOT.  Now we could get more complex but all that we'd be doing is using these simple building blocks.

In the world of automation these types of TRUE or FALSE conditions come down to a device being ON or OFF, CLOSED or OPEN, PRESENT or ABSENT, 24 VOLTS or 0 VOLTS.  In the PLC it all boils down to our now familiar binary system of a 1 or a 0.  Typically having a bit ON represents a TRUE condition while OFF is FALSE.  This is abitrary though as it may make more sense to use what is called failsafe logic and have an ON bit as a FALSE condition.

Let's turn again to some simple statements but this time using automation examples.

When the button is pressed AND the door is closed then turn on the motor.

If the process is done OR the emergency stop button signal is NOT on then turn off the motor.  (This is an example of a failsafe operation as the emergency stop button could be      pressed or the wire has been disconnected.  In either case we want to check this for safety reasons.  Relying on a signal to turn on when a wire has fallen off long ago may cause an awkward moment when we truly have to stop the machine in an emergency.)

If the tank is full OR the button is pressed AND there are no alarms then start the process.
It would be nice to program like this but computers like to be a little bit more structured.  A series of graphical objects have been used for years to represent these logic elements and they can be easily converted to a common ladder logic equivalent.  These functions are also called gates as they act like gate keepers for different logic. 

The simple switching circuits presented further down should be sufficient to understand practical implementation in hardware of Boolean Algebra. For clarity, we have attached the correspondent firmware/software logic equivalent formulas.
   
  


  
 

BOOLEAN EQUIVALENT OF SWITCHING CIRCUITS
 

CIRCUIT
 
DESCRIPTION
Switching logic

 Fig 1 : 
Function LED

 LED = A * B  (in Boolean hardware)
 is equivalent to:
 LED = A AND B (in firmware logic)
 
Switching logic
 Fig 2 : 
Function LED

 LED = A + B  (in Boolean hardware)
 
LED = A OR B (in firmware logic)
Switching logic
 Fig 3 : 
Function LED

 LED = A * B * (C + D)  (in Boolean hardware)
 
LED = A AND B AND (C OR D) (in firmware logic)
Switching logic

 Fig 4 : 
Function LED

 LED = A * D + B * C (in Boolean hardware)
 
LED = (A AND D) OR (B AND C) (in firmware logic)
Switching logic Fig 5 : Function LED

 LED = A * (B + C) (in Boolean hardware)
 
LED = A AND (B OR C) (in firmware logic)
Switching logic

 Fig 6 : 
Function LED
 
 LED = A * B + A * B 
(in Boolean hardware)

 
LED = (A AND B) OR [(NOT A) AND (NOT B)] (in firmware logic)
 


The NOT function

The simplest of all logic functions is the NOT gate. 


It's sole function in life is to invert of flip the logic state.  So an input of 1 will come out as a 0 and visa versa.  Shown below is a truth table (it doesn't lie) showing all possible inputs and the resulting logical output.
   
Input A
Output 
 0
 1
1
 0


The ladder logic equivalent for a NOT function looks like a normal contact but with a slash through it.




The AND function

The AND gate is associated with the following symbol that can have any number of inputs but only one output.  



The truth table below shows that the output is only turned on when all the inputs are true (1).  An easy way to remember this is AND works like multiplication.

Input A
Input B 
 Output
 0
 0
 0
1
 0
 0
 0
 1
 0
 1
 1
 1

The ladder logic equivalent for an AND function looks like two normal contacts side by side.


The OR function

Last but not least the OR gate is associated with the following symbol that also can have any number of inputs but only one output.  



The truth table below shows that the output is turned on (1) when any of the inputs are true (1).  An easy way to remember this is OR works like addition.

Input A
Input B 
 Output
 0
 0
 0
1
 0
 1
 0
 1
 1
 1
 1
 1

The ladder logic equivalent for an OR function looks like two normal contacts on top of each other.


Combining AND or OR with NOT 
The NOT gate might not look like much help if you haven't programmed much but you'll find yourself actually using it frequently.  It's very common to use it in combination with AND and OR.  So the engineering gods decided to make some symbols for these combinations. 

Putting the NOT and AND gates together forms the NAND gate.The truth table below shows that it is simply an inverted output of the AND gate.

Input A
Input B 
 Output
 0
 0
 1
1
 0
 1
 0
 1
 1
 1
 1
 0

A little circle (or if you like, a bubble) at the end of a AND gate is used to signify the NAND function.  Its symbol and corresponding ladder logic are shown below.  Now pay close attention to the ladder logic because the contacts are in parallel and not in series like the AND function.




Putting the NOT and OR gates together forms... you got it... the NOR gate.  The truth table below shows that it is simply an inverted output of the OR gate.

Input A
Input B 
 Output
 0
 0
 1
1
 0
 0
 0
 1
 0
 1
 1
 0


Again a little circle is placed at the end of an OR gate to signify the NOR function.  Its symbol and corresponding ladder logic are shown below.  The ladder logic is very different from the regular OR gate.


But wait!  Don't order yet... the XOR gate.

So far with our logic gates we've covered almost all possible combinations except for one shown by the truth table below.

Input A
Input B 
 Output
 0
 0
 0
1
 0
 1
 0
 1
 1
 1
 1
 0

The logic to produce this output is called an Exclusive OR gate otherwise known as the XOR gate.  It's a specialized form of the OR gate.  So if either one of the inputs are on then the output is true, otherwise you're out of luck.  The symbol for the XOR gate is shown by added a curved line to the OR gate symbol.




The ladder logic to implement an XOR gate is a little more complex than the others. 




How useful is the XOR logic?  You probably use the XOR gate everyday without thinking about it if you have a room with a light that works off two switches.  If both switches are in the same position then the light will be off.  Therefore just flipping one switch will turn the light on.  In the PLC program this can be extremely useful for programming alternating actions or gray codes.

Ok, there is one more logic gate but I promise it is the last one.  It makes sense that there is a XNOR gate which is the combination of the NOT and XOR logic.  It simply inverts the output of the XOR function.


Input A
Input B 
 Output
 0
 0
 1
1
 0
 0
 0
 1
 0
 1
 1
 1


The symbol for the XNOR gate is shown below along with it's ladder logic equivalent.






While these terms and symbols may seem a bit esoteric for the PLC beginner they are important in the long run.  A good grasp of these essentials will make PLC programming easier, simplier and save memory.