Title: Programming of a PLC to perform

basic input / output operations

I. Objectives

(a) Familiarization with the PLC simulator PSIM-2000

(b) Learning of simple input output instructions

(c) Development of ladder logic diagrams for basic programming of a PLC

II Theory

What is a PLC?

A PLC (i.e. Programmable Logic Controller) is a device that was invented to replace the necessary sequential relay circuits for machine control. The PLC works by looking at its inputs and depending upon their state, turning on/off its outputs. The user enters a program, usually via software, that gives the desired results.

PLCs are used in many "real world" applications. Fields of industry such as machining, packaging, material handling, automated assembly or countless other cases are greatly benefited because of the PLCs’ presence. Almost any application that needs some type of electrical control has a need for a plc. For example, let's assume that when a switch turns on, we want to turn a solenoid on for 5 seconds and then turn it off regardless of how long the switch is on for. We can do this with a simple external timer. But what if the process included 10 switches and solenoids? We would need 10 external timers. What if the process also needed to count how many times the switches individually turned on? We need a lot of external counters. As you can see the bigger the process the more of a need we have for a PLC. We can simply program the PLC to count its inputs and turn the solenoids on for the specified time.

In the frame of our laboratory sessions you will take enough information to be able to write programs far more complicated than the simple one above. Initially, we will take a look at what is considered to be the "top" plc instructions. It can be safely estimated that with a firm understanding of these instructions one can solve more than 80% of the applications in existence. Of course we'll learn more than just these instructions so as to be able to solve almost all our potential plc applications.

PLC Operation

A PLC works by continually scanning a program. We can think of this scan cycle as consisting of 3 important steps (Fig. 1). There are typically more than 3 but we can focus on the important parts and not worry about the others. Typically the others are checking the system and updating the current internal counter and timer values.


Figure 1: The three steps of a scan cycle

Step 1-CHECK INPUT STATUS-First the PLC takes a look at each input to determine if it is on or off. In other words, is the sensor connected to the first input on? How about the second input? How about the third... It records this data into its memory to be used during the next step.

Step 2-EXECUTE PROGRAM-Next the PLC executes your program one instruction at a time. Maybe your program said that if the first input was on then it should turn on the first output. Since it already knows which inputs are on/off from the previous step it will be able to decide whether the first output should be turned on based on the state of the first input. It will store the execution results for use later during the next step.

Step 3-UPDATE OUTPUT STATUS-Finally the PLC updates the status of the outputs. It updates the outputs based on which inputs were on during the first step and the results of executing your program during the second step. Based on the example in step 2 it would now turn on the first output because the first input was on and your program said to turn on the first output when this condition is true.

After the third step the PLC goes back to step one and repeats the steps continuously. One scan time is defined as the time it takes to execute the 3 steps listed above.

Basic Instructions

Now let's examine some of the basic instructions in greater detail to see more about what each one does.

1. XIC

The XIC (eXamine the input to see If its physically Closed) instruction is a normally open contact. Sometimes it is also called load (LD) instruction. The symbol for an XIC instruction is shown below


Figure 2: An XIC (contact) symbol

This is used when an input signal is needed to be present for the symbol to turn on. When the physical input is on we can say that the instruction is True. We examine the input for an on signal. If the input is physically on then the symbol is on. An on condition is also referred to as a logic 1 state.

2. XIO

The XIO (eXamine the input to see If its physically Opened) instruction is a normally closed contact. Sometimes it is also called LoaDNot (LDN) instruction. The symbol for an XIO instruction is shown below


Figure 3: An XIO (normally closed contact) symbol

This is used when an input signal does not need to be present for the symbol to turn on. When the physical input is off we can say that the instruction is True. We examine the input for an off signal. If the input is physically off then the symbol is on. An off condition is also referred to as a logic 0 state.

3. OTE

The OTE (OuTputEnergize) instruction is sometimes also called Out instruction. The output instruction is like a relay coil. Its symbol looks as shown below.


Figure 4: An OTE (coil) symbol

When there is a path of True instructions preceding this on the ladder rung, it will also be True. When the instruction is True it is physically On. We can think of this instruction as a normally open output.

Ladder Logic Diagrams

The first PLCs were programmed with a technique known as Ladder Logic Diagrams. This was based on relay logic wiring schematics which eliminated the need to teach the electricians, technicians and engineers how to program a computer - but, this method has stuck and it is the most common technique for programming PLCs today. The method is explained via the following example:


Let's consider a real world physically connected relay circuit (Fig. 5).

Figure 5: A Simple circuit

A relay is a simple device that uses a magnetic field to control a switch, as pictured in Fig. 5. When a voltage is applied to the input coil, the resulting current creates a magnetic field. The magnetic field pulls a metal switch towards it and the contacts touch, closing the switch. The contact that closes when the coil is energized is called normally open. The normally closed contacts touch when the input coil is not energized. Relays are normally drawn in schematic form using a circle to represent the input coil.

In the above circuit, the coil will be energized when there is a closed loop between the + and - terminals of the battery. We can simulate this same circuit with a ladder diagram. A ladder diagram consists of individual rungs just like on a real ladder. Each rung must contain one or more inputs and one or more outputs. The first instruction on a rung must always be an input instruction and the last instruction on a rung should always be an output (or its equivalent).


Figure 6: Circuit converted to ladder diagram

Notice in this simple one rung ladder diagram we have recreated the external circuit above with a ladder diagram. Here we used the XIC and OTE instructions. Some manufacturers require that every ladder diagram include an END instruction on the last rung.

Generally, to interpret these diagrams imagine that the power is on the vertical line on the left hand side which we call the hot rail. On the right hand side is the neutral rail. On each rung, we may have combinations of inputs (two vertical lines) and outputs (circles). If the inputs are opened or closed in the right combination the power can flow from the hot rail, through the inputs, to power the outputs, and finally to the neutral rail. An input can come from a sensor, switch, or any other type of sensor. An output will be some device outside the PLC that is switched on or off, such as lights or motors.

III Experimental Work

The PLC simulator PSIM-2000

PSIM is actually three distinct programs combined into a single package. First, PSIM contains a PLC Ladder Logic editor that allows users to create and edit PLC programs using a series of PLC instructions. Secondly, PSIM emulates the scanning sequence of a PLC. When placed into the "RUN" mode, the users program is scanned and the appropriate I/O is updated just as would occur in an actual PLC. Thirdly, PSIM contains a number of animated simulations which respond accurately to the inputs, and outputs of the emulated PLC. A conveyor based filling line, Traffic intersection and Batch mixing simulations present life-like challenges for the student programmer.

Getting Started:

From the Main Menu screen of the PSIM program, select the I/O simulation display. The
I/O (Input/Output) simulation screen shown below (Fig.7) should now be displayed on the display.

Using The I/O simulator

The I/O simulator allows you to change the state of the switches connected to the Input Card of our simple PLC. The windows in the centre of the display allow us to monitor the state of the PLC's Data Table. Although all PLCs store this data as ones and zeros, our simulator substitutes a period in place of any zero in order to make the display easier to read. In


Figure 7: The Input / Output Simulation screen

addition, we can have the simulator alternatively display this information in both decimal and hexadecimal format by pressing the [F3] "Toggle Radix" function key.

·  [F1] Toggle Switch State

You can control the state of the switches connected to Input Card of our simple PLC by pressing the F1 function key. To select which switch is to be toggled, first use the Up and Down arrow keys on the keyboard to move the cursor focus to the desired switch.

·  [F2] Toggle Tables

When you first enter the I/O simulation, the upper data window displays the Output image words of our simple PLC. The lower window displays the Input Image words. The [F2] key allows you to display other areas of PLC's data table such as those areas used by timers and counters etc. For this exercise however, we only wish to view the Input and Output section of the Data Table. Each time you press this key another view of the PLC's data table will be shown. If you keep pressing this key you will eventually return to the original Input/Output display.

·  [F3] Toggle Radix

Pressing the Toggle Radix function key toggles between Binary and Decimal/ Hexadecimal display of Data Table information.

·  [F5] Rung Edit

Pressing this key takes you to the Ladder Rung Program Editor. We will use this shortly to enter our first practice program.

·  [F6] Exit (Esc)

Pressing F6 or the Esc key will return you to the PSIM Main Menu display.

Entering The Rung Editor

From the I/O simulator screen select the Rung Edit function [F5] The Rung Editor Screen shown below should now be displayed on your Computer.


·  The Editor is displaying a single rung which marks the end of the program. This rung is present in every program and is included in the count of the program rungs. Thus an empty program will still have a rung count of one.

·  Note the Function Key Menu along the Bottom of the screen. For most operations you will be required to press the corresponding Function Key on your Keyboard in order to invoke the specified operation which is described by this and other Function Key Menus.

Entering a Rung


Ensure that you are in the Rung Editor

Enter the above program by following these steps:

Note

·  All keystrokes that you are required to enter are shown in square brackets [ ].

·  Ensure that the NumLock light is on if using the numeric keypad for numbers.

1.  Insert a Rung into your empty program by pressing the F2 function key

2.  Select the XIC (Examine-On) instruction by pressing F1.

3.  Now enter the address of the first toggle switch by entering [ I 1 0 0 ] followed by pressing the Return or Enter Key.

Note: The backspace key (the left arrow key above the Enter key) may be used to delete incorrect entries prior to pressing Enter.

4.  Next, press the F8 (Output Instructions) which will display a new menu at the bottom of the screen.

5.  Select the OTE (Output Energize) instruction by pressing the F1 function key.

6.  Now enter the address of the first simulator Light. [ O 1 0 0 ] followed by the Enter key.

7.  The rung should now be complete and a second rung will have been started. Exit from the insert mode by pressing the F10 (Exit) key or the Esc key.

8.  You can now test your program by exiting the editor (F10 or Esc). When you exit back to the I/O simulation display the PLC is automatically placed in the RUN mode.

9.  Toggle the switch several times and observe the operation of your program. Light 00 should light whenever switch 00 is true (closed).

Adding a Rung

From the I/O simulator screen select the Rung Edit function.


Modify your program by adding a second rung as shown above.

10.  Append a second Rung to your program by pressing the F1 function key

11.  Note: "Insert Rung" adds a rung above the rung the cursor is on.