









Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This is lecture handout for Control Systems course in degree of Electrical Engineering. Dr. Anbu Manghirmalani provided this handout at Birla Institute of Technology and Science. It includes: Ladder, Logic, Fundamentals, Contacts, Coils, Timers, Counters, Electrical, Switches, Master, Physical
Typology: Exercises
1 / 16
This page cannot be seen from the preview
Don't miss anything!










8-
Ladder logic programs mimic the electrical circuit diagrams used for wiring control systems in the electrical industry. The basic purpose of an electrical control system is to determine whether a load should be turned ON or turned OFF, under what circumstances and when it should happen. To understand a ladder program, just remember the concept of current flow - a load is turned ON when the current can flow to it and is turned OFF when the current could not flow to it.
The fundamental element of a ladder diagram is a "Contact". A contact has only two states: open or closed. An open contact breaks the current flow whereas a closed contact allows current to flow through it to the next element. The simplest contact is an On/OFF switch, which requires external force (e.g. the human hand) to activate it. Limit switches are those small switches that are placed at certain location so that when a mechanical device moves towards it, the contact will be closed and when the device moves away from it, the contact will be open.
If a contact is connected to a load and the contact is closed, the load will be turned ON. This simple concept can be illustrated by the most basic ladder diagram as follow:
The vertical line on the left is the "Power" line; current must flow through the "Switch" contact in order to turn ON the load "Lamp". (In fact, there should be a second vertical line on the right end of the ladder diagram to provide a return path for the current flow, but this is omitted to simplify the circuit diagram). Now, if instead of wiring the switch to the lamp directly as suggested in the above diagram, you could connect the switch to the PLC's input and connect the lamp to the PLC's output, and then write the above ladder program to perform the same job. Of course it makes little sense to use a PLC if that is all you want to do. We will see how a PLC can simplify wiring shortly.
Note: The contact "Switch" shown in the above diagram is termed a Normally-open (N.O.) contact.
8-
Now, let's say if there are 3 switches that must work together to control the lamp. A Master switch must be ON, and one of the two control switches "controlsw1" and "controlsw2" must be ON while the other must be OFF in order to turn ON the lamp (think of three-way switches in your house and you will get the idea). We can wire all 3 switches to 3 inputs of the PLC and the lamp to the output of the PLC. We can write the following ladder program to perform this task:
A contact with a "/" across its body is a Normally-Closed (N.C.) contact. What it means is that the ladder program is using the "inverse" of the logic state of the input to interpret the diagram.
Hence in the above ladder diagram, if "Master" and "controlSW1" are turned ON but "controlSW2" is turned OFF, the lamp will be turned ON since the inverse logic state of an OFF state "controlSW2" is true. Think of an imaginary current flowing through the "Master" contact, then through the "controlSW1" and finally through the normally-closed "controlSW2" contact to turn ON the lamp.
On the other hand, if "controlSW1" is OFF but "controlSW2" is ON, the Lamp is also turned ON because the current could flow via "Master" and then through the lower parallel branch via N.C. "controlSW1" and the N.O. "controlSW2".
Note: As you can see, although the switch "controlSW1" is connected to only 1 physical input to the PLC, but it appears twice in the ladder diagram. If you actually try to connect physical wires to implement the above circuits, both "controlSW1" and "controlSW2" will have to be of multiple poles type. But if you use a PLC, then these two switches only need to be of single-pole type since there is only one physical connection, which is to the input terminal of the PLC. But in the ladder diagram the same contact may appear as many times as you wish as if it has unlimited number of poles.
The above example may be simple but it illustrates the basic concept of logical “AND” and “OR” very clearly. "controlSW1" and "controlSW2" are connected in series and both must be TRUE for the outcome to be TRUE. Hence, this is a logical AND connection. On the other hand, either one of the two parallel branches may be used to conduct current, hence this is a logical OR connection.
8-
A PLC output is really just an internal relay with a physical connection that can supply electrical power to control an external load. Thus, like a relay, an output can also have unlimited number of contacts that can be used in the ladder program.
A timer is a special kind of relay that, when its coil is energized, must wait for a fixed length of time before closing its contact. The waiting time is dependent on the "Set Value" (SV) of the timer. Once the delay time is up, the timer's N.O. contacts will be closed for as long as its coil remains energized. When the coil is de-energized (i.e. turned OFF), all the timer's N.O. contacts will be opened immediately.
However, if the coil is de-energized before the delay time is up, the timer will be reset and its contact will never be closed. When a last aborted timer is re-energized, the delay timing will restart afresh using the SV of the timer and not continue from the last aborted timing operation.
A counter is also a special kind of relay that has a programmable Set Value (SV). When a counter coil is energized for the first time after a reset, it will load the value of SV-1 into its count register. From there on, every time the counter coil is energized from OFF to ON, the counter decrements its count register value by 1. Note that the coil must go through OFF to ON cycle in order to decrement the counter. If the coil remains energized all the time, the counter will not decrement. Hence counter is suitable for counting the number of cycles an operation has gone through.
When the count register hits zero, all the counter's N.O. contacts will be turned ON. These counter contacts will remain ON regardless of whether the counter's coil is energized or not. To turn OFF these contacts, you have to reset the counter using a special counter reset function [RSctr].
8-
TRiLOGI contains a number of special purpose bits that are useful for certain applications. These include 8 clock pulses ranging from periods of 0.01 second to 1 minute, a "Normally-ON" flag and a "First Scan Pulse", etc.
To use any of these bits, enter the ladder editor and create a "contact"; when the I/O table pops up, scroll the windows until a "Special Bits" menu pops up. This menu is located after the "Counter Table" and before the "Input" table. as shown below:
The 8 clock pulses supported by TRiLOGI are: Clock Pulse Period Ladder Symbol 0.01 second Clk:.01s 0.02 second Clk:.02s 0.05 second Clk:.05s 0.1 second Clk:0.1s 0.2 second Clk:0.2s 0.5 second Clk:0.5s 1.0 second Clk:1.0s 1 minute Clk:1min
A clock pulse bit is ON for the first half of the rated period, then OFF for the second half. Duty cycles for these clock pulse bits are therefore 50%, as follow:
The clock pulse bits are often used with counter instructions to create timers. Additionally, they can be used as timing source for "Flasher" circuit. A reversible counter can also work with a clock pulse bit to
8-
During ladder circuit editing, when you click on the or icon to create a special function coil, a special function menu will pop up as shown below:
The [DNctr], [UPctr] and [RSctr] functions work together to implement reversible counter functions on any of the 128 counters supported by TRiLOGI.
The ordinary down counter (created by clicking on the icon) essentially decrements the counter value by 1 from the "Set Value" (SV) and will stop when its count becomes zero. Unlike the ordinary down counter, a reversible counter is a circular counter that changes the counter present value (PV) between 0 and the SV. When you try to increment the counter past the "Set Value", it will overflow to become '0'. Likewise if you try to decrement the counter beyond '0', it will underflow to become the "Set Value".
All three counter functions [DNctr], [UPctr] and [RSctr] can operate on the same counter (i.e. assigned to the same counter label) on different circuits. Although these circuits may be located anywhere within the ladder program, it is recommended that the two or three functions which operate on the same counter be grouped together in the following order: DNctr], [Upctr] and [RSctr]. Note that NOT all three functions need to be used to implement the reversible counter.
8-
Decrement Counter [DNctr]
Each time when the execution condition of a [DNctr] function changes from OFF to ON, the present value of the designated counter is changed as follow:
a. If the counter's present value (PV) is inactive, load the counter register with the "Set Value" (SV, defined in the Counter table) minus 1. b. If the counter’s present value (PV) is already ‘0’, then load the counter’s PV with the SV defined in the counter table and turn on the counter's contact (also known as the completion flag). c. Otherwise, decrement the counter PV register by 1.
Increment Counter [Upctr]
Each time when the execution condition of an [Upctr] function changes from OFF to ON, the present value of the designated counter is affected as follow:
a. If the counter is inactive, load the counter register with the number '0001'.
8-
relay will be reset. In the ladder diagram, the program element label name will be shown above the [Clear] symbol.
If the execution condition for [Latch] and [Clear] functions are both ON at the same time, then the effect of the designated bit depends on the relative locations of these two functions. Remember that an output or relay bit energized by [Latch] will remain ON until it is turned OFF by [Clear]. It is recommended that [Clear] circuit be placed just after the [Latch] circuit for the same output or relay controlled by these two functions. This ensures that [Clear] function has higher priority over [Latch] function, which is normally so in hardware latch-relay or other industrial PLCs.
The "Interlock" [ILock] and "Interlock Off" [ILoff] functions work together to control an entire section of ladder circuits. If the execution condition of a [ILock] function is ON, the program will be executed as normal. If the execution condition of [ILock] is OFF, the program elements between the [ILock] and [ILoff] will behave as follow:
a. All output coils are turned OFF. b. All timers are reset to inactive. c. All counters retain their present values. d. Latched relays by [Latch] function are not affected. e. [dDIFU] and [dDIFD] functions are not executed. f. All other functions are not executed.
An Interlock section is equivalent to a master control relay controlling a number of sub-branches as follow:
Note that [ILoff] is the only function that does not need to be energized by other program elements. When you use one or more [ILock] functions, there must be at least one [ILoff] function before the
8-
end of the program. Otherwise the compiler will warn you for the missing [ILoff]. The logic simulator always clears the Interlock at the end of the scan if you omit the [ILoff] function.
You can program a second or third level Interlock within an Interlock section using a few [ILock] functions. However, you only need to program one [ILoff] function for the outermost Interlock section, i.e. [ILoff] need not be a matching pair for an [ILock] function.
When the execution condition for [dDIFU] goes from OFF to ON, the designated output or relay will be turned ON for one scan time only. After that it will be turned OFF. This means that the function generates a single pulse for one scan time in response to the rising-edge of its execution condition. When its execution condition goes from ON to OFF nothing happens to the output or relay that it controls.
On the other hand, when the execution condition for [dDIFD] goes from ON to OFF, the designated output or relay will be turned ON for one scan time only. After that it will be turned OFF. This means that the function generates a single pulse for one scan time in response to the trailing edge of its execution condition. When its execution condition goes from ON to OFF, nothing happens to the output or relay that it controls.
These two functions allow you to connect a user-defined custom function (CusFn) to the ladder logic as if it is a relay coil. Custom functions are created using the integrated text editor provided by TRiLOGI Version 6.x.
8-
used, Counter #5 must be defined as "Seq5". Next, enter the last step number for the program sequence in the "Value" column of the table.
Construct a circuit that uses the special function "Advance Sequencer" [AVSeq]. The first time the execution condition for the [AVseq] function goes from OFF to ON, the designated sequencer will go from inactive to step 1. Subsequent change of the sequencer's execution condition from OFF to ON will advance (increment) the sequencer by one step. This operation is actually identical to the [UPctr] instruction.
The upper limit of the step counter is determined by the "Set Value" (SV) defined in the Counter table. When the SV is reached, the next advancement of sequencer will cause it to overflow to step 0. At this time, the sequencer's contact will turn ON until the next increment of the sequencer. This contact can be used to indicate that a program has completed one cycle and is ready for a new cycle.
Accessing individual steps of the sequencer is extremely simple when programming with TRiLOGI. Simply create a "contact" (NC or NO) in ladder edit mode. When the I/O window pops up for you to pick a label, scroll to the "Special Bits" table as follow:
The "Special Bits" table is located after the "Counters" table and before the "Inputs" table.
Then click on the "SeqN:x" item to insert a sequencer bit. You will be prompted to select a sequencer from a pop-up menu. Choose the desired sequencer (1 to 8) and another dialog box will open up for you to enter the specific step number for this sequencer.
Each step of the sequencer can be programmed as a contact on the ladder diagram as "SeqN:X" where N = Sequencers # 1 to 8. X = Steps # 0 - 31.
e.g. Seq2:4 = Step #4 of Sequencer 2. Seq5:25 = Step #25 of Sequencer 5.
Although a sequencer may go beyond Step 31 if you define a larger SV for it, only the first 32 steps can be used as contacts to the ladder logic. Hence it is necessary to limit the maximum step number to not more than
8-
Quite a few of the ladder logic special functions are related to the use of the sequencer. These are described below:
Advance Sequencer - [AVseq] Increment the sequencer's step counter by one until it overflows. This function is the identical to (and hence interchangeable with) the [UpCtr] function.
Resetting Sequencer - [RSseq] The sequencer can also be reset to become inactive by the [RSseq] function at any time. Note that a sequencer that is inactive is not the same as sequencer at Step 0, as the former does not activate the SeqN:0 contact. To set the sequencer to step 0, use the [StepN] function described next.
Setting Sequencer to Step N - [StepN] In certain applications it may be more convenient to be able to set the sequencer to a known step asynchronously. This function will set the selected sequencer to step #N, regardless of its current step number or logic state. The ability to jump steps is a very powerful feature of the sequencers.
Reversing a Sequencer Although not available as a unique special function, a Sequencer may be stepped backward (by decrementing its step-counter) using the [DNctr] command on the counter that has been defined as a sequencer. This is useful for creating a reversible sequencer or for replacing a reversible "drum" controller.
a. Driving Stepper Motor A sequencer may be used to drive a stepper motor directly. A two- phase stepper motor can be driven by four transistor outputs of the controller directly (for small motors with phase current < 0.5A) or via solid-state relays. The stepper motor can be driven using a sequencer that cycles through Step#0 to Step#3 (full-step mode) or Step#0 through Step#7 (half-step mode). Each step of the sequencer is used to energize different phases of the stepper motor. A clock source is needed to drive the stepper motor through
8-
Figure 6.
The 1.0s clock pulse bit will advance (increment) Sequencer #2 by one step every second. Sequencer 2 should be defined with Set Value = 8. Each step of the sequencer is used as a normally open contact to turn on the desired LED for the step. A "Stop" input resets the sequencer asynchronously. When the sequencer counts to eight, it will become Step