PLC 2
PLC 2
Introduction A PLC is a computer type device used to control industrial process such as conveyor systems, food processing machinery, auto assembly e.t.c. The advent of the PLC began in the 1970s, and has become the most common choice. PLCs have been gaining popularity on the factory floor and will probably remain predominant for some time to come.
PLC HARDWARE
Many PLC configurations are available, even from a single vendor. But, in each of these there are common components and concepts. The most essential components are:
Power Supply
It provides the required voltage and current to the PLC This can be built into the PLC or it can be an external unit. Common voltage levels required by the PLC (with and without the power supply) are 24Vdc, 120Vac, 220Vac.
Indicator lights Indicate the status of the PLC including power on, Running mode, Pause mode
and Fault. These are essential when diagnosing problems
Input Modules
In smaller PLCs the input modules are normally built in and are specified when purchasing the PLC. In larger PLCs the inputs are provided as a separate module, or cards, with 8 or 16 inputs of the same type on each card. Input modules can be analogue or digital. The typical ranges for input voltages, and is roughly in order of popularity: 12-24 Vdc, 100-120 Vac, 10-60 Vdc, 12-24 Vac/dc, 5 Vdc (TTL), 200-240 Vac, 48 Vdc, 24 Vac For PLC input cards, an external power supply is needed to supply power for the inputs and sensors. The example in figure below shows how to connect an AC input card to field devices.
Push button
Temperature switch
PLC input modules must convert a variety of logic levels to the 5Vdc logic levels used on the data bus. This can be done with circuits similar to those shown below. Basically the circuits condition the input to drive an optocoupler. This electrically isolates the external electrical circuitry from the internal circuitry. Other circuit components are used to guard against excess or reversed voltage polarity.
Output Modules
As with input modules, external power supplies are connected to the output card and the card will switch the power on or off for each output. Outputs must convert the 5Vdc logic levels on the PLC data bus to external voltage levels. It use an optocoupler to switch external circuitry. This electrically isolates the external electrical circuitry from the internal circuitry. Other circuit components are used to guard against excess or reversed voltage polarity.
Fig.4: Electronic out put module Fig.5: relay type output module
PLC Memory
The memory system in the PLC stores both the control program and the data from the equipments connected to it.
Old PLCs use RAM for the program and ROM to store the basic operating system for the PLC.
Originally PLC vendors used RAM with a battery so that the memory contents would not be lost if the power was lost. This method is still in use, but is losing favor. EPROMs have also been a popular choice for programming PLCs. The EPROM is programmed out of the PLC, and then placed in the PLC. When the PLC is turned on the ladder logic program on the EPROM is loaded into the PLC and run. This method is very reliable, but the erasing and programming technique can be time consuming. EEPROM memories are a permanent part of the PLC, and programs can be stored in them like EPROM. Memory costs continue to drop, and newer types (such as flash memory) are becoming available, and these changes will continue to impact PLCs.
Program File-0 is used for program and password information. SFC programs must be in program File-1. The main program will be stored in program File -2. All other program files from 3 to 999 can be used for subroutines. This is where the variable data is stored that the PLC program operates on. Fig.6: Memory organization
PLC OPERATION
All PLCs have four basic stages of operations that are repeated many times per second.
SELF TEST - Checks to see if all cards(modules) are error free, reset watch-dog timer,
etc. (A watchdog timer will cause an error, and shut down the PLC if not reset within a short period of time - this would indicate that the ladder logic is not being scanned normally).
INPUT SCAN - Reads input values from the input cards, and copies their values to
memory. (the physical input values are copied into memory). This makes the PLC operation faster. There are special PLC functions that read the inputs directly, and avoid the input tables.
LOGIC SCAN/solve - Based on the input table in memory, the program is executed
one step at a time, and outputs are updated. (When the ladder logic is scanned it uses the values in memory, not the actual input or output values). (When the outputs to a PLC are scanned they are copied from memory to the physical outputs). These chips then drive the output devices.
OUTPUT SCAN - The output table is copied from memory to the output chips.
Initially when turned on the first time it will check its own hardware and software for faults. If there are no problems it will copy all the input and copy their values into memory, this is called the input scan. Using only the memory copy of the inputs the ladder logic program will be solved once, this is called the logic scan. While solving the ladder logic the output values are only changed in temporary memory. When the ladder scan is done the outputs will updated using the temporary values in memory, this is called the output scan. The PLC now restarts the process by starting a self check for faults. This process typically repeats 10 to 100 times per second as is shown in figure below
PLC STATUS
On the front of the PLC there are normally limited status lights. Common light indicators are:
Power - this will be on whenever the PLC has power Run - this will often indicate if a program is running, Stop it indicates that the plc is doing nothing (stop mode). Fault - this will indicate when the PLC is experienced a major hardware or software problem. These lights are normally used for debugging.
Limited buttons will also be provided for PLC hardware. The most common will be: A start/stop switch: used to switch off when maintenance is being conducted, and back to run when in operation. This switch normally requires a key to keep unauthorized personnel from altering the PLC program or stopping execution. Almost all PLCs never have an on-off switch or reset button on the front.
Programming PLC
The control program is the software program in the PLCs memory that consists of one or more instructions which accomplished certain task.
The user or system designer is usually the one who develops the control program.
Basic PLC programming styles: Ladder logic (LD), Function Block diagram (FBD), Statement List (SL), Structured Text(ST), Sequential Function Charts (SFC)
1- Ladder Logic
Ladder logic is the main and easiest programming method. Ladder logic programs are modeled from relay logic. In relay logic each element in the ladder will switch as quickly as possible. But in a program elements can only be examined ones at a time in a fixed sequence.
Example-2
To compare with assembly language format The program begins at the START: label. At this point the first value is loaded, and the rest of the expression is broken up into small segments.
Exercise-2: Write the ladder diagram programs that correspond to the following Boolean programs. (a)
LDN AN A LD A OLD = I0.2 I0.3 I0.4 I0.5 I0.6 Q0.1
(b)
LD A LD A OLD =
(c)
LDN A LD O A OLD = AN =
In the program
The inputs N7:0 and N7:1 are used to calculate a value sin(N7:0) * ln(N7:1). The result of this calculation is compared to N7:2. If the calculated value is less than N7:2 then the output Q:000/01 is turned on, otherwise it is turned off.
Example-2. Some functions allow a variable number of arguments. In Figure 21.4 there is a third input to the ADD block. This is known as overloading.
When developing a complex system it is desirable to create additional function blocks. This can be done with other FBDs. Figure below shows a divide function block created using ST. In this example the first statement declares it as a FUNCTION_BLOCK called divide. The input variables a and b, and the output variable c are declared. In the function the denominator is checked to make sure it is not 0. If not, the division will be performed, otherwise the output will be zero.
FUNCTION BLOCK divide VAR_INPUT a:INT; b:INT; END_VAR VAR_OUTPUT c:INT; END_VAR IF b<>0 THEN c: = a/b; ELSE c:=0; END_IF END_FUNCTION_BLOCK
Fig. Timing diagram The output with an L inside will turn the output Qo on when the input Io becomes true (at t= T1). Qo will stay on even if Io turns off (at t= T2). Output Qo will turn off when input I1 becomes true (at t= T3)and the output with a U inside becomes true. If an output has been latched on, it will keep its value, even if the power has been turned off.
Flip-Flops
Latches are not used universally by all PLC vendors, others such as Siemens use flip-flops. These have a similar behavior to latches, but the different is that flipflop is an output block that is connected to two different logic inputs. The first rung shown has an input Io connected to the S setting terminal. The second rung has an input I1 connected to the R resetting terminal.
Operation When Io goes true the output value Q will go true. When I1 goes true the output value Q will be turned off. The output Q will always be the inverse of Q. Notice that the S and R values are equivalent to the L and U values of Latch.
TIMERS
There are four fundamental types of timers 1. On delay timer (TON) :- An on-delay timer will delay for a set of times (before turning on) after a line of ladder logic has been true, but it will turn off immediately. 2. Off-delay timer (TOF):- An off-delay timer will turn on immediately when a line of ladder logic is true, but it will delay before turning off. 3. Retentive on-delay timer (RTO):- A retentive on-delay timer will sum all of the on times for a timer, even if the preset time is not elapsed. 4. Retentive Off-delay timer (RTF):- A retentive off-delay timer will sum all of the off times for a timer, even if the preset time is not elapsed.
Note: A non-retentive timer will start timing the delay from zero each time.
TON - timer
The timing diagram below illustrates the operation of the TON timer with a 4 second on-delay. Whenever the timer input (Io) is true the EN enabled bit for the timer will also be true. But the DN bit value will remain off until the accumulator value is equal to the preset.
The first time Io is true, it is only true for 3 seconds (before turning off), after this the value resets to zero. (Note: in a retentive time the value would remain at 3 seconds.) The second time Io is true, it is on for more than 4 seconds. After 4 seconds the DN bit turns on. But, when Io is released the accumulator resets to zero, and the DN bit is turned off.
RTO- timer The timer in the figure below is identical to that in the previous figure, except that it is retentive. The most significant difference is that when the input Io is turned off the accumulator value does not reset to zero, it rather store the current time value. When Io is on for the second time, the accumulator continues counting from this value. As a result the DN bit will be set when the preset time is elapsed, and the timer does not turn off after it turns on. A reset instruction is required that will allow the accumulator to be reset to zero.
Exercise: Draw the ladder logic and timing diagram of 1. Off-delay non retentive timer 2. Off-delay retentive timer
COUNTERS There are two basic counter types: 1. count-up (CTU) 2. count-down (CTD) 1- CTU
When the input Io goes true the accumulator value will increase by 1 (no matter how long the input is true). If the accumulator value reaches the preset value (n)the counter DN bit will be set. (The count can continue above the preset value). The instruction requires memory in the PLC to store values and status, in this case is C5:0 (C5: indicates that it is counter memory). If input I1 goes true the value in the counter accumulator will become zero.
2- CTD
Count-down counters are very similar to count-up counters. Exercise: Draw some ladder logic for CTD with time diagram and explain its operation based on the time diagram. (Use n=4 pulses )
Important :- Both CTU and CTD can be used on the same counter memory
location. Example: Consider the figure below.
Input I/1 drives the count-up instruction for counter C5:1. Input I/2 drives the count-down instruction for the same counter location. The preset value for a counter is stored in memory location C5:1 so both the count-up and count-down instruction must have the same preset. Input I/3 will reset the counter.
Problem
1. Develop the ladder logic that will turn on an output light, 15 seconds after switch Io has been turned on. 2. Develop the ladder logic that will turn on a light, after switch I1 has been closed 10 times. Push button B will reset the counters. 3. A motor will be controlled by two switches. The Go switch will start the motor and the Stop switch will stop it. If the Stop switch was used to stop the motor, the Go switch must be thrown twice to start the motor. When the motor is active a light should be turned on. The Stop switch will be wired as normally closed. 4. A conveyor is run by switching on or off a motor. We are positioning parts on the conveyor with an optical detector. When the optical sensor goes on, we want to wait 1.5 seconds, and then stop the conveyor. After a delay of 2 seconds the conveyor will start again. We need to use a start and stop button - a light should be on when the system is active
Problem
Design a PLC program and prepare a typical I/O connection diagram and ladder logic program that will correctly execute the hardwired control circuit given below
Solution-1
Solution-2