You are on page 1of 67

Electrical, Electronics and Computer Engineering Department

PLC Basics
Module Code NE130

Version No Date Author

1 08/2007 DK

Chisholm Institute Fletcher Road FRANKSTON 3199 Tel: +61 3 9238 8226 Fax: +61 3 9238 8116

PLC BASICS OMRON

This page intentionally left blank

-2-

Copyright Chisholm Institute

PLC BASICS OMRON Duration of Module: 20 hours Module purpose: The aim of this module is to provide students with an introduction to programmable logic controllers (PLCs) and PLC systems.

LO 1: Describe the major differences between three basic forms of electrical control. 1.1 State the major differences between relay, static and programmable control. 1.2 Draw a block diagram representation of a programmable logic controller. 1.3 List advantages and/or disadvantages of programmable control over relay control. 1.4 List applications for programmable controllers. LO2: State the basic operating principles of PLCs. 2.1 List the steps in a basic scan cycle. 2.2 Define terms such as I/O, CPU, RAM, ROM. 2.3 Describe a typical addressing system for a PLC and give examples. 2.4 For a given PLC, identify inputs and outputs. LO3: Write, test, edit and monitor programs which include series elements, parallel elements, combination series parallel elements, basic timers and counters by using a hand program loader. 3.1 3.2 3.3 3.4 Write programs to suit given conditions. Load programs into a PLC. Test the operation of programs written. Use the monitoring function to verify circuit conditions and check the current values of timers and counters. 3.5 Use editing features to make minor program changes. Connect I/O devices to a PLC and prove their operation. 4.1 With the aid of a diagram connect input and output devices to a PLC. 4.2 Explain the implications of programming normally closed, field devices. 4.3 State the hardware changes necessary when converting a relay controlled process of a programmable controlled process. Resources: Shoe-box style Programmable Controller for each student with a suitable input simulator and hand program loader. Normally open and normally closed pushbuttons (or similar) that can be physically connected to the input terminals of a PLC. Contactor/lamp that can be physically connected to the output terminals of a PLC. Useful references include: Stenerson, Jon 1993, Fundamentals of Programmable Logic Controllers, Sensors and Communications, Regents, Prentice Hall, New Jersey. Simpson, Colin D. 1994, Programmable Logic Controllers, Regents, Prentice Hall, Eaglewood Cliffs.
Copyright Chisholm Institute

LO4:

-3-

PLC BASICS OMRON

This page intentionally left blank

-4-

Copyright Chisholm Institute

PLC BASICS OMRON

Table of Contents
Introduction to Programmable Logic Controllers (PLCs)................................................................ 7 The PLC ...................................................................................................................................... 7 History...................................................................................................................................... 7 Individual PLC sections ............................................................................................................... 9 Power supply section. .............................................................................................................. 9 CPU module............................................................................................................................. 9 The memory section .............................................................................................................. 10 The Program Software Section.............................................................................................. 11 Input Output Section .............................................................................................................. 11 PLC block diagram................................................................................................................. 13 Peripheral devices ..................................................................................................................... 14 Inside the PLC............................................................................................................................... 15 Input Relays (Contacts) ......................................................................................................... 15 Internal Utility Relays (Contacts)............................................................................................ 15 Counters ................................................................................................................................ 15 Timers .................................................................................................................................... 15 Output Relays (Coils)............................................................................................................. 15 Data Storage.......................................................................................................................... 15 PLC Operation .............................................................................................................................. 16 Check Input Status................................................................................................................. 16 Execute Program ................................................................................................................... 16 Update Output Status ............................................................................................................ 16 Response Time...................................................................................................................... 17 Response Time Concerns ..................................................................................................... 17 Relays ........................................................................................................................................... 18 Replacing Relays ................................................................................................................... 19 Basic PLC instructions .................................................................................................................. 21 Load........................................................................................................................................... 21 Example ................................................................................................................................. 21 LoadBar/LoadNot ...................................................................................................................... 22 Example ................................................................................................................................. 22 Out............................................................................................................................................. 23 Example ................................................................................................................................. 23 OutBar ....................................................................................................................................... 24 Example ................................................................................................................................. 24 PLC programming example....................................................................................................... 25 Level Application.................................................................................................................... 26 The Program Scan ........................................................................................................................ 28 Getting Started .............................................................................................................................. 31 To start the program .............................................................................................................. 31 Program Creation.......................................................................................................................... 33 Documentation .......................................................................................................................... 36 Method 1 ................................................................................................................................ 36 Testing your Program.................................................................................................................... 39 Transfer.................................................................................................................................. 40 Monitoring .............................................................................................................................. 41 Latching Instructions ..................................................................................................................... 42 Latching Example ...................................................................................................................... 43 Ladder.................................................................................................................................... 43 Mnemonics............................................................................................................................. 43 Ladder.................................................................................................................................... 44
Copyright Chisholm Institute

-5-

PLC BASICS OMRON Mnemonics............................................................................................................................. 44 Timers ........................................................................................................................................... 45 CPM1A Timer instructions......................................................................................................... 48 On delay................................................................................................................................. 48 TIM......................................................................................................................................... 48 Example (TIM ) ..................................................................................................................... 49 Ladder.................................................................................................................................... 49 Mnemonics............................................................................................................................. 49 Counters........................................................................................................................................ 51 Types of counters ...................................................................................................................... 51 CPM1A Counter instructions ..................................................................................................... 54 Count down............................................................................................................................ 54 CNT........................................................................................................................................ 54 Example (CNT) ...................................................................................................................... 55 Ladder.................................................................................................................................... 55 Mnemonics............................................................................................................................. 55 Up/down counter (reversible)................................................................................................. 57 CNTR ..................................................................................................................................... 57 Exercises and Assessment items ................................................................................................. 58 Exercise 1.................................................................................................................................. 58 Exercise 2.................................................................................................................................. 59 Exercise 3.................................................................................................................................. 60 Exercise 4.................................................................................................................................. 61 Exercise 5.................................................................................................................................. 62 Assessment Item 1 Door Simulation ...................................................................................... 63 Assessment Item 2 Level Application (Using Latching instructions.) ..................................... 65 Assessment Item 3 Carton Filling Timer................................................................................. 66 Assessment Item 4 Pallet Loading Counter. .......................................................................... 67

-6-

Copyright Chisholm Institute

PLC BASICS OMRON

Introduction to Programmable Logic Controllers (PLCs)


The PLC
A PLC (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. If there is industry present, chances are good that there is a PLC present. If you are involved in machining, packaging, material handling, automated assembly or countless other industries you are probably already using them. If you are not, you are wasting money and time. 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.

History
In the late 1960's PLCs were first introduced. The primary reason for designing such a device was eliminating the large cost involved in replacing the complicated relay based machine control systems. Bedford Associates (Bedford, MA) proposed something called a Modular Digital Controller (MODICON) to a major US car manufacturer. Other companies at the time proposed computer based schemes, one of which was based upon the PDP-8. The MODICON 084 brought the world's first PLC into commercial production. When production requirements changed so did the control system. This becomes very expensive when the change is frequent. Since relays are mechanical devices they also have a limited lifetime which required strict adhesion to maintenance schedules. Troubleshooting was also quite tedious when so many relays are involved. Now picture a machine control panel that included many, possibly hundreds or thousands, of individual relays. The size could be mind boggling. How about the complicated initial wiring of so many individual devices! These relays would be individually wired together in a manner that would yield the desired outcome. These "new controllers" also had to be easily programmed by maintenance and plant engineers. The lifetime had to be long and programming changes easily performed. They also had to survive the harsh industrial environment. That's a lot to ask! The answers were to use a programming technique most people were already familiar with and replace mechanical parts with solid-state ones. In the mid1970's the dominant PLC technologies were sequencer state-machines and the bit-slice based CPU. The AMD 2901 and 2903 processors were quite popular in Modicon and AllenBradley PLCs. Conventional microprocessors lacked the power to quickly solve PLC logic in all but the smallest PLCs. As conventional microprocessors evolved, larger and larger PLCs were being based upon them. However, even today some are still based upon the 2903.(ref A-B's PLC3) Modicon has yet to build a faster PLC than their 984A/B/X which was based upon the 2901.
Copyright Chisholm Institute

-7-

PLC BASICS OMRON Communications abilities began to appear in approximately 1973. The first such system was Modicon's Modbus. The PLC could now talk to other PLCs and they could be far away from the actual machine they were controlling. They could also now be used to send and receive varying voltages to allow them to enter the analogue world. Unfortunately, the lack of standardization coupled with continually changing technology has made PLC communications a nightmare of incompatible protocols and physical networks. Still, it was a great decade for the PLC! The 80's saw an attempt to standardize communications with General Motor's manufacturing automation protocol (MAP). It was also a time for reducing the size of the PLC and making them software programmable through symbolic programming on personal computers instead of dedicated programming terminals or handheld programmers. Today the world's smallest PLC is about the size of a single control relay! The 90's have seen a gradual reduction in the introduction of new protocols, and the modernization of the physical layers of some of the more popular protocols that survived the 1980's. The latest standard (IEC 1131-3) has tried to merge PLC programming languages under one international standard. We now have PLCs that are programmable in function block diagrams, instruction lists, C and structured text all at the same time! PC's are also being used to replace PLCs in some applications. The original company who commissioned the MODICON 084 has actually switched to a PC based control system.

-8-

Copyright Chisholm Institute

PLC BASICS OMRON

Individual PLC sections


Common to all PLCs are five sections, each of which can be subdivided into smaller but equally important sections. These primary sections include: The power supply section which provides the operating DC power to the PLC and I/O base modules and includes battery backup. The CPU module, which contains the processor and holds the memory. The memory section The software program section The I/O section, which controls peripheral devices and contains the input and output modules.

Power supply section.


The power supply (PS) section gets its input power from an external 120VAC or 240VAC source (line voltage), which is usually fused and fed through a control relay and filter external to the PS. In addition, the PS has its own integral AC input fuse. This line voltage is then stepped-down, rectified, filtered, regulated, voltage- and currentprotected, and status-monitored, with status indication displayed on the front of the PS in the form of several LEDs (light-emitting diodes). The PS can have a key switch for protecting the memory or selecting a particular programming mode. The output of the PS provides low DC voltage(s) to the PLC's various modules as well as to its integral lithium battery, which is used for the memory backup. Should the PS fail or its input line voltage drop below a specific value, the memory contents will not change from what they were prior to the failure. The PS output provides power to every module in the PLC; however, it does not provide the DC voltages to the PLC's peripheral I/O devices.

CPU module
"CPU," "controller," or "processor" are all terms used by different manufacturers to denote the same module that performs basically the same functions. The CPU module can be divided into two sections: the processor section and the memory section. The processor section makes the decisions needed by the PLC so that it can operate and communicate with other modules. It communicates along either a serial or parallel data-bus. An I/O base interface module or individual on-board interface I/O circuitry provides the signal conditioning required to communicate with the processor. The processor section also executes the programmer's RLL software program.

Copyright Chisholm Institute

-9-

PLC BASICS OMRON

The memory section


This section stores (electronically) retrievable digital information in three dedicated locations of the memory. These memory locations are routinely scanned by the processor. The memory will receive ("write" mode) digital information or have digital information accessed ("read" mode) by the processor. This read/write (R/W) capability provides an easy way to make program changes. The memory contains data for several types of information. Usually, the data tables, or image registers, and the software program RLL are in the CPU module's memory. The program messages may or may not be resident with the other memory data. A battery backup is used by some manufacturers to protect the memory contents from being lost should there be a power or memory module failure. Still others use various integrated circuit (IC) memory technologies and design schemes that will protect the memory contents without the use of a battery backup. A typical memory section of the CPU module has a memory size of 96,000 (96K) bytes. This size tells us how many locations are available in the memory for storage. Additional memory modules can be added to your PLC system as the need arises for greater memory size. These expansion modules are added to the PLC system as the quantity of I/O modules are added or the software program becomes larger. When this is done, the memory size can be as high as 1,024,000 (1024K) bytes. Manufacturers will state memory size in either "bytes" or "words." A byte is eight bits, and a bit is the smallest digit in the binary code. It's either logic "1" or logic "0." A word is equal in length to two bytes or 16 bits. Not all manufacturers use 16-bit words, so be aware of what your PLC manufacturer has defined as its memory word bit size.

- 10 -

Copyright Chisholm Institute

PLC BASICS OMRON

The Program Software Section.


The PLC not only requires electronic components to operate, it also needs a software program. The PLC programmer is not limited to writing software in one format. There are many types available, each lending itself more readily to one application over and above another. Typical is the RLL type previously discussed. Other S/W programs include "C," State Language, and SFC (Sequential Function Charts). Regardless of which software is chosen, it will be executed by the PLC's CPU module. The software can be written and executed with the processor in an online state (while the PLC is actually running) or in the off-line state (whereby the S/W execution does not affect current operation of the I/O base). In the RLL software program, we find several types of programming elements and functions to control processes both internal to the PLC (memory and register) as well as external (field) devices. Listed below are some of the more common types of elements, functions, and instructions: Contacts can be either normally open or normally closed; highlighted on the monitor means they are active. Coils (can be normal or latched; highlighted means they are energized). Timers (coil can either be ON or OFF for the specified delay). Counters (can count by increments either up or down). Bit shift registers (can shift data by one bit when active). One-shot (meaning active for one scan time; useful for pulse timer). Drums (can be sequenced based on a time or event). Data manipulation instructions (enable movement, comparison of digital values). Arithmetic instructions (enable addition, subtraction, multiplication, and division of digital values).

Input Output Section


Input module The input module has two functions: reception of an external signal and status display of that input point. In other words, it receives the peripheral sensing unit's signal and provides signal conditioning, termination, isolation and/or indication for that signal's state. The input to an input module is in either a discrete or analogue form. If the input is an ON-OFF type, such as with a push button or limit switch, the signal is considered to be of a discrete nature. If, on the other hand, the input varies, such as with temperature, pressure, or level, the signal is analogue in nature. Peripheral devices sending signals to input modules that describe external conditions can be switches (limit, proximity, pressure, or temperature), push buttons, or logic, binary coded decimal (BCD) or analogue-to-digital (A/D) circuits. These input signal points are scanned, and their status is communicated through the interface module or circuitry within each individual PLC and I/O base.

Copyright Chisholm Institute

- 11 -

PLC BASICS OMRON Some typical types of input modules are listed below. DC voltage (110, 220, 14, 24, 48, 15-30V) or current (4-20 mA). AC voltage (110, 240, 24, 48V) or current (4-20 mA). TTL (transistor-transistor logic) input (3-15VDC). Analogue input (12-bit). Word input (16-bit/parallel). Thermocouple input. Resistance temperature detector. High current relay. Low current relay. Latching input (24VDC/110VAC). Isolated input (24VDC/85-132VAC). Intelligent input (contains a microprocessor). Positioning input. PID (proportional, integral, differentiation) input. High-speed pulse. Output module The output module transmits discrete or analogue signals to activate various devices such as hydraulic actuators, solenoids, motor starters, and displays the status (through the use of LEDs) of the connected output points. Signal conditioning, termination, and isolation are also part of the output module's functions. The output module is treated in the same manner as the input module by the processor. Some typical output modules available today include the following: DC voltage (24, 48,110V) or current (4-20 mA). AC voltage (110, 240v) or current (4-20 mA). Isolated (24VDC). Analogue output (12-bit). Word output (16-bit/parallel). Intelligent output. ASCII output. Dual communication port.

- 12 -

Copyright Chisholm Institute

PLC BASICS OMRON

PLC block diagram


The block diagram below shows how a PLC can be used to control a simple security system. The security switches are used to activate an automatic telephone dialler. The light level detector is used to control the lighting through a remote control. The smoke detectors turn on a fire alarm when activated.

The sensors and switches are connected to the input of the PLC and the outputs are connected to the output devices. A software program is used to write the control program which is downloaded into the user memory of the PLC. When the PLC is switched into the run mode, the microprocessor executes the user program. This involves detecting the state of the inputs and controlling the outputs according to the user program.

Copyright Chisholm Institute

- 13 -

PLC BASICS OMRON

Peripheral devices
Peripheral devices to the PLC and its I/O base(s) can be anything from a host computer and control console to a motor drive unit or field limit switches. Printers and industrial terminals used for programming are also peripheral devices. Peripheral devices can generate or receive AC or DC voltages and currents as well as digital pulse trains or single pulses of quick length (pulse width). These external operating devices, with their sometimes harsh and/or fast signal characteristics, must be able to interface with the PLC's sensitive microprocessor. Various types of I/O modules (using the proper shielded cabling) are available to do this job.

- 14 -

Copyright Chisholm Institute

PLC BASICS OMRON

Inside the PLC


The PLC mainly consists of a CPU, memory areas, and appropriate circuits to receive input/output data. We can actually consider the PLC to be a box full of hundreds or thousands of separate relays, counters, timers and data storage locations. Do these counters, timers, etc. really exist? No, they don't "physically" exist but rather they are simulated and can be considered software counters, timers, etc. These internal relays are simulated through bit locations in registers (more on that later).

Input Relays (Contacts)


These are connected to the outside world. They physically exist and receive signals from switches, sensors, etc. Typically they are not relays but rather they are transistors.

Internal Utility Relays (Contacts)


These do not receive signals from the outside world nor do they physically exist. They are simulated relays and are what enables a PLC to eliminate external relays. There are also some special relays that are dedicated to performing only one task. Some are always on while some are always off. Some are on only once during power-on and are typically used for initializing data that was stored.

Counters
These again do not physically exist. They are simulated counters and they can be programmed to count pulses. Typically these counters can count up, down or both up and down. Since they are simulated they are limited in counting speed. Some manufacturers also include high-speed counters that are hardware based. We can think of these as physically existing. Most times these counters can count up, down or up and down.

Timers
These also do not physically exist. They come in many varieties and increments. The most common type is an on-delay type. Others include off-delay and both retentive and non-retentive types. Increments vary from 1ms through 1s.

Output Relays (Coils)


These are connected to the outside world. They physically exist and send on/off signals to solenoids, lights, etc. They can be transistors, relays, or triacs depending upon the model chosen.

Data Storage
Typically these are registers assigned to simply store data. They are usually used as temporary storage for maths or data manipulation. They can also typically be used to store data when power is removed from the PLC. Upon power-up they will still have the same contents as before power was removed. Very convenient and necessary!!

Copyright Chisholm Institute

- 15 -

PLC BASICS OMRON

PLC Operation
A PLC works by continually scanning a program. We can think of this scan cycle as consisting of 3 important steps. 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.

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 which is 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.

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.

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 this example it would now turn on the first output. 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.

- 16 -

Copyright Chisholm Institute

PLC BASICS OMRON

Response Time
The total response time of the PLC is a fact we have to consider when shopping for a PLC. Just like our brains, the PLC takes a certain amount of time to react to changes. In many applications speed is not a concern, in others though. If you take a moment to look away from this text you might see a picture on the wall. Your eyes actually see the picture before your brain says "Oh, there's a picture on the wall". In this example your eyes can be considered the sensor. The eyes are connected to the input circuit of your brain. The input circuit of your brain takes a certain amount of time to realize that your eyes saw something. (If you have been drinking alcohol this input response time would be longer!) Eventually your brain realizes that the eyes have seen something and it processes the data. It then sends an output signal to your mouth. Your mouth receives this data and begins to respond to it. Eventually your mouth utters the words "that's a really ugly picture!". Notice in this example we had to respond to 3 things: Input It took a certain amount of time for the brain to notice the input signal from the eyes. Execution It took a certain amount of time to process the information received from the eyes. Consider the program to be: If the eyes see an ugly picture then output appropriate words to the mouth. Output The mouth receives a signal from the brain and eventually spits (no pun intended) out the words "that's a really ugly picture!"

Response Time Concerns


Now that we know about response time, here's what it really means to the application. The PLC can only see an input turn on/off when it's looking. In other words, it only looks at its inputs during the check input status part of the scan. It is possible that an input pulse may not be detected if the pulse is too short (the pulse is shorter than the program scan. To avoid this we say that the input should be on for at least 1 input delay time + one scan time. But what if it was not possible for the input to be on this long? Then the PLC doesn't see the input turn on. Therefore it becomes a paper weight! Not true... of course there must be a way to get around this. Actually there are 3 ways. Pulse stretch function. This function extends the length of the input signal until the PLC looks at the inputs during the next scan (It stretches the duration of the pulse.) Interrupt function. This function interrupts the scan to process a special routine that you have written.

Copyright Chisholm Institute

- 17 -

PLC BASICS OMRON (As soon as the input turns on, regardless of where the scan currently is, the PLC immediately stops what its doing and executes an interrupt routine.) A routine can be thought of as a mini program outside of the main program. After its done executing the interrupt routine, it goes back to the point it left off and continues on with the normal scan process. Immediate update Some PLCs have an instruction that allows you to set points in the program where the inputs are updated. Instead of just one input update per scan, you can set as many as you need to ensure that the input pulse is seen by the PLC

Relays
Now that we understand how the PLC processes inputs, outputs, and the actual program we are almost ready to start writing a program. But first lets see how a relay actually works. After all, the main purpose of a PLC is to replace "real-world" relays. We can think of a relay as an electromagnetic switch. Apply a voltage to the coil and a magnetic field is generated. This magnetic field sucks the contacts of the relay in, causing them to make a connection. These contacts can be considered to be a switch. They allow current to flow between 2 points thereby closing the circuit. Let's consider the following example. Here we simply turn on a bell (Lunch time!) whenever a switch is closed. We have 3 real-world parts. A switch, a relay and a bell. Whenever the switch closes we apply a current to a bell causing it to sound.

Notice in the picture that we have 2 separate circuits. The bottom(thin) indicates the DC part. The top (thick) indicates the AC part. Here we are using a DC relay to control an AC circuit. That's the fun of relays! When the switch is open no current can flow through the coil of the relay. As soon as the switch is closed, however, current runs through the coil causing a magnetic field to build up. This magnetic field causes the contacts of the relay to close. Now AC current flows through the bell and we hear it. Lunch time! - 18 Copyright Chisholm Institute

PLC BASICS OMRON

Replacing Relays
Next, lets use a PLC in place of the relay. (Note that this might not be very cost effective for this application but it does demonstrate the basics we need.) The first thing that's necessary is to create what's called a ladder diagram. After seeing a few of these, it will become obvious why its called a ladder diagram. We have to create one of these because, unfortunately, a PLC doesn't understand a schematic diagram. It only recognizes code. Fortunately most PLCs have software which converts ladder diagrams into code. This shields us from actually learning the PLC's code. First step We have to translate all of the items we're using into symbols the PLC understands. The PLC doesn't understand terms like switch, relay, bell, etc. It prefers input, output, coil, contact, etc. It doesn't care what the actual input or output device actually is. It only cares that it is an input or an output. First we replace the battery with a symbol. This symbol is common to all ladder diagrams. We draw what are called bus bars. These simply look like two vertical bars; one on each side of the diagram. Think of the left one as being +ve voltage and the right one as being ve voltage or ground. Further think of the current (logic) flow as being from left to right. Next we give the inputs a symbol. In this basic example we have one real world input. (i.e. the switch) We give the input that the switch will be connected to, to the symbol shown below. This symbol can also be used as the contact of a relay.

A contact symbol Next we give the outputs a symbol. In this example we use one output (i.e. the bell). We give the output that the bell will be physically connected to the symbol shown below. This symbol is used as the coil of a relay.

A coil symbol The AC supply is an external supply so we don't put it in our ladder. The PLC only cares about which output it turns on and not what's physically connected to it.

Copyright Chisholm Institute

- 19 -

PLC BASICS OMRON

Second step We must tell the PLC where everything is located. In other words we have to give all the devices an address. Where is the switch going to be physically connected to the PLC? How about the bell? We start with a blank road map in the PLCs town and give each item an address. Could you find your friends houses if you didn't know their addresses? You know they live in the same town but which house? The PLC town has a lot of houses (inputs and outputs) but we have to figure out who lives where (what device is connected where). We'll get further into the addressing scheme later. The PLC manufacturers each do it a different way! For now let's say that our input will be called "0000". The output will be called "500". Final step We have to convert the schematic into a logical sequence of events. This is much easier than it sounds. The program we're going to write tells the PLC what to do when certain events take place. In our example we have to tell the PLC what to do when the operator turns on the switch. Obviously we want the bell to sound but the PLC doesn't know that.

The picture above is the final converted diagram. Notice that we eliminated the real world relay from needing a symbol. It's actually "inferred" from the diagram. Now let's examine some of the basic instructions is greater detail to see more about what each one does.

- 20 -

Copyright Chisholm Institute

PLC BASICS OMRON

Basic PLC instructions


Load
The load (LD) instruction is a normally open contact. It is sometimes also called examine if closed (XIC), as in examine the input to see if its physically on. The symbol for a load instruction is shown below.

A Load (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. This symbol normally can be used for internal inputs, external inputs and external output contacts. Remember that internal relays don't physically exist. They are simulated (software) relays.

Example

Ladder

Mnemonics

Assume that a normally open switch is connected to input 0.00 and a lamp is connected to output 10.00. When the switch is closed the input instruction will be true and the lamp will turn on. When the switch is open the input instruction will be false and the lamp will turn off.

Copyright Chisholm Institute

- 21 -

PLC BASICS OMRON

LoadBar/LoadNot
The LoadBar instruction is a normally closed contact. It is sometimes also called LoadNot or examine if open (XIO), as in examine the input to see if its physically off. The symbol for a LoadBar instruction is shown below.

LoadNot 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. This symbol normally can be used for internal inputs, external inputs and sometimes, external output contacts. Remember again that internal relays don't physically exist. They are simulated (software) relays. It is the exact opposite of the Load instruction. Note: With most PLCs this instruction (Load or Loadbar) MUST be the first symbol on the left of the ladder. Logic State 0 1 Load False True LoadNot True False

Example

Ladder

Mnemonics

Assume that a normally open switch is connected to input 0.00 and a lamp is connected to output 10.00. When the switch is closed the input instruction will be false and the lamp will turn off. When the switch is open the input instruction will be true and the lamp will turn on.

- 22 -

Copyright Chisholm Institute

PLC BASICS OMRON

Out
The Out instruction is sometimes also called an Output energise instruction. The output instruction is like a relay coil. Its symbol looks as shown below.

OUT (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. This instruction can be used for internal coils and external outputs.

Example

Ladder

Mnemonics

Assume that a normally open switch is connected to input 0.00 and a lamp is connected to output 10.00. When the switch is closed the input instruction will be true and the lamp will turn on. When the switch is open the input instruction will be false and the lamp will turn off.

Copyright Chisholm Institute

- 23 -

PLC BASICS OMRON

OutBar
The OutBar instruction is sometimes also called an OutNot instruction. Some vendors don't have this instruction. Its symbol looks like that shown below.

OutBar symbol When there is a path of false instructions preceding this on the ladder rung, it will be true. When the instruction is true it is physically on. This instruction can be used for internal coils and external outputs. It is the exact opposite of the Out instruction. Logic State 0 1 Load False True LoadNot True False

Example

Ladder

Mnemonics

Assume that a normally open switch is connected to input 0.00 and a lamp is connected to output 10.00. When the switch is closed the input instruction will be true and the lamp will turn off. When the switch is open the input instruction will be false and the lamp will turn on.

- 24 -

Copyright Chisholm Institute

PLC BASICS OMRON

PLC programming example


Now let's compare a simple ladder diagram with its real world external physically connected relay circuit and see the differences.

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).

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

Copyright Chisholm Institute

- 25 -

PLC BASICS OMRON

Level Application
Consider the following application: We are controlling lubricating oil being dispensed from a tank. This is possible by using two sensors. We put one near the bottom and one near the top, as shown in the picture below.

Here, we want the fill motor to pump lubricating oil into the tank until the high level sensor turns on. At that point we want to turn off the motor until the level falls below the low level sensor. Then we should turn on the fill motor and repeat the process. We have a need for 3 I/O (i.e. Inputs/Outputs). 2 are inputs (the sensors) and 1 is an output (the fill motor). Both of our inputs will be NC (normally closed) fibre-optic level sensors. When they are NOT immersed in liquid they will be ON. When they are immersed in liquid they will be OFF. We will give each input and output device an address. This lets the PLC know where they are physically connected. The addresses are shown in the following tables: Inputs Low High Address 0000 0001 Outputs Motor Address 5000 Internal Utility 1000

- 26 -

Copyright Chisholm Institute

PLC BASICS OMRON Below is what the ladder diagram will actually look like. Notice that we are using an internal utility relay in this example. You can use the contacts of these relays as many times as required. Here they are used twice to simulate a relay with 2 sets of contacts. Remember, these relays DO NOT physically exist in the PLC but rather they are bits in a register that you can use to simulate a relay.

We should always remember that the most common reason for using PLCs in our applications is for replacing real-world relays. The internal utility relays make this action possible. It's impossible to indicate how many internal relays are included with each brand of PLC. Some include 100's while others include 1000's while still others include 10's of 1000's! Typically, PLC size (not physical size but rather I/O size) is the deciding factor. If we are using a micro-PLC with a few I/O we don't need many internal relays. If however, we are using a large PLC with 100's or 1000's of I/O we'll certainly need many more internal relays. If ever there is a question as to whether or not the manufacturer supplies enough internal relays, consult their specification sheets. In all but the largest of large applications, the supplied amount should be MORE than enough.

Copyright Chisholm Institute

- 27 -

PLC BASICS OMRON

The Program Scan


Let's watch what happens in this program scan by scan.

Initially the tank is empty therefore, input 0000 is TRUE and input 0001 is also TRUE.

Scan 1 Gradually the tank fills because 5000 (fill motor) is on.

Scan 2-100

- 28 -

Copyright Chisholm Institute

PLC BASICS OMRON After 100 scans the oil level rises above the low level sensor and it becomes open. ( false)

Scan 101-1000 Notice that even when the low level sensor is false there is still a path of true logic from left to right. This is why we used an internal relay. Relay 1000 is latching the output (5000) on. It will stay this way until there is no true logic path from left to right (i.e. when 0001 becomes false). After 1000 scans the oil level rises above the high level sensor at it also becomes open (false)

Scan 1001

Scan 1002

Copyright Chisholm Institute

- 29 -

PLC BASICS OMRON Since there is no more true logic path, output 5000 is no longer energized (true) and therefore the motor turns off. After 1050 scans the oil level falls below the high level sensor and it will become true again.

Scan 1050 Notice that even though the high level sensor became true there still is NO continuous true logic path and therefore coil 1000 remains false! After 2000 scans the oil level falls below the low level sensor and it will also become true again. At this point the logic will appear the same as SCAN 1 above and the logic will repeat as illustrated above.

- 30 -

Copyright Chisholm Institute

PLC BASICS OMRON

Getting Started
To start the program
Double click on the CX-program icon on your desktop.

The CX workspace

You can move around and select the various screen functions and options either by using the keyboard buttons or the mouse. The menu options at the top of the screen identify the alternative key operations. If you are only using the keyboard, you will not need to display the tool bars (see Tool bars note below). Hint: You can jump between the project workspace and the ladder diagram by pressing the Alt-O keys. Using Tool bars The tool bar is a row of icons below the menu options that you can click on with the mouse to activate a variety of commands and functions. These are not needed if you use the keyboard to select items. Hint: You may not see the tool bars you need when the screen is first displayed. To display specific tool bars, select Tool Bars from the View menu; when the tool bar dialogue window is displayed, click the tool bar tick-boxes needed and press OK. It is possible to customise the tool bars.

Copyright Chisholm Institute

- 31 -

PLC BASICS OMRON Select file new to start your program. The following dialog box will appear

Complete the windows in the box as shown and press ok. You are now ready to write your program

- 32 -

Copyright Chisholm Institute

PLC BASICS OMRON

Program Creation
Following is a step by step example of how to enter a simple program which consists of 2 Input instructions (contacts) in series and a single Output instruction (coil). The contact in parallel with input 0.01 is known as a hold in or latching contact.

First place the cursor at the start of network1

button in the User Instruction Bar. If you hold the mouse pointer Click on the "new contact" over any of these buttons for a second or two, you should see a short "ToolTip" which describes the function or name of the instruction that the button represents. Write the address in the dialog box and place the contact at the start of the rung.

Copyright Chisholm Institute

- 33 -

PLC BASICS OMRON Repeat the process for the second contact

Click on the new coil

button and place the coil at the end of the rung.

To place the hold in contact, first select the new vertical shown below.

button and place vertical lines as

Insert a contact between the vertical lines. The rung should now look like this.

- 34 -

Copyright Chisholm Institute

PLC BASICS OMRON

Select the new PLC instruction the dialog box window.

button. Place it at the start of the next rung and type end in

button. This checks your program for errors. If the program is Select the program compile error free the compile window at the bottom of the programming window should look like this.

Copyright Chisholm Institute

- 35 -

PLC BASICS OMRON

Documentation
A well written PLC program should contain as much information about the process and program as necessary. This makes the program easier to understand and troubleshoot when necessary. This software allows you to enter symbols and comments. There are many methods of entering your documentation. 1. You may enter your symbols in the symbol table before you write your program. 2. You may enter your symbols as you write your programs. 3. You may use the symbol table to insert symbols after you have finished programming.

Method 1
Select file new and complete the change PLC dialog box. From the project workspace select symbols as shown below.

- 36 -

Copyright Chisholm Institute

PLC BASICS OMRON When the symbols table appears, right click in the first line and select insert symbol

Complete the table as follows

Now simply write your program in the normal manner and the symbols and comments will appear as you address your instructions. Your completed program should now look like this:

Note: You can select tools/options to customise your workplace by modifying the way your program looks. If you are using the hand held programmer to write your program you must write your program using mnemonics.

Copyright Chisholm Institute

- 37 -

PLC BASICS OMRON You can convert your ladder diagram to mnemonics simply by selecting the view mnemonics button on the toolbar. Your completed program now looks like this:

If you accidentally add an instruction which you wish to remove, you may right click on the instruction and then select "cut" or delete from the drop-down menu that appears.

- 38 -

Copyright Chisholm Institute

PLC BASICS OMRON

Testing your Program


When you have completed your program you should test it for errors (compile) before you download it. Click the compile button on the toolbar and check the output window at the bottom of the screen to see if there are any errors. It's now time to "Download" your program to the PLC. Click on the PLC button on the toolbar to initiate the downloading of your program to the PLC. Select work online from the drop down menu:

The program will now prompt you to connect to the PLC and if your communications setup is correct you should now be connected.

Copyright Chisholm Institute

- 39 -

PLC BASICS OMRON

Transfer
Click on the PLC button again and select transfers to PLC

Follow the instructions to download your program into the PLC. Next select PLC/operating mode/run

Your program is now running in the PLC.

- 40 -

Copyright Chisholm Institute

PLC BASICS OMRON

Monitoring
You can now use the software to monitor your program by clicking PLC/monitor/monitoring:

Operate the switches and ensure that your program works properly.

Copyright Chisholm Institute

- 41 -

PLC BASICS OMRON

Latching Instructions
Regular output coils are of course an essential part of our programs but we must remember that they are only TRUE when all instructions before them on the rung are also TRUE. What happens if they are not? Then of course, the output will become false (turn off). Think back to the lunch bell example we did a few chapters ago. What would've happened if we couldn't find a "push on/push off" switch? Then we would've had to keep pressing the button for as long as we wanted the bell to sound (a momentary switch). The latching instructions let us use momentary switches and program the PLC so that when we push one the output turns on and when we push another the output turns off. Here is a real world example. Picture the remote control for your TV. It has a button for ON and another for OFF. When you push the ON button the TV turns on. When you push the OFF button the TV turns off. You don't have to keep pushing the ON button to keep the TV on. This would be the function of a latching instruction. The latch instruction is often called a SET or OTL (output latch). The unlatch instruction is often called a RES (reset), OTU (output unlatch) or RST (reset). The diagram below shows how to use them in a program.

Here we are using 2 momentary push button switches. One is physically connected to input 0000 while the other is physically connected to input 0001. When the operator pushes switch 0000 the instruction "set 0500" will become true and output 0500 physically turns on. Even after the operator stops pushing the switch, the output (0500) will remain on. It is latched on. The only way to turn off output 0500 is turn on input 0001. This will cause the instruction "res 0500" to become true thereby unlatching or resetting output 0500. Here's something to think about. What would happen if input 0000 and 0001 both turn on at the exact same time? Will output 0500 be latched or unlatched? To answer this question we have to think about the scanning sequence. The ladder is always scanned from top to bottom, left to right. The first thing in the scan is to physically look at the inputs. 0000 and 0001 are both physically on. Next the PLC executes the program. Starting from the top left, input 0000 is true therefore it should set 0500. Next it goes to the next rung and since - 42 Copyright Chisholm Institute

PLC BASICS OMRON input 0001 is true it should reset 0500. The last thing it said was to reset 0500. Therefore on the last part of the scan when it updates the outputs it will keep 0500 off.

Latching Example
Stop/Start using set (SET) and reset (RSET) For this exercise we need two Normally Open momentary switches (push buttons) and a lamp. Add the following three rungs to your program. Once you have the rungs entered correctly, download and run your program.

Ladder

Mnemonics

Activate the Start and Stop switches and ensure that the S and R output instructions are responding correctly. Once you have the lamp ON, could you turn it off if power was lost in the Stop Switch circuit? (E.g. broken wire) Now modify your program so that it operates correctly when you substitute the N.O. Stop switch (I0.1) with a Normally Closed Switch. If we now lost power on the N.C. Stop switch circuit, what would happen to the state of Lamp (Q0.0)? Stop/Start using the (KEEP) instruction The Omron PLC also uses the keep instruction to latch bits in a program. An example of this is shown below. Write the program and enter it into the PLC.

Copyright Chisholm Institute

- 43 -

PLC BASICS OMRON

Ladder

Mnemonics

Activate the Start and Stop switches and ensure that the keep output instruction is responding correctly.

- 44 -

Copyright Chisholm Institute

PLC BASICS OMRON

Timers
Let's now see how a timer works. What is a timer? Its exactly what the word says... it is an instruction that waits a set amount of time before doing something. When we look at the different kinds of timers available the fun begins. As always, different types of timers are available with different manufacturers. Here are most of them: On-Delay timer This type of timer simply "delays turning on". In other words, after our sensor (input) turns on we wait x-seconds before activating a solenoid valve (output). This is the most common timer. It is often called TON (timer on-delay), TIM (timer) or TMR (timer). This type of timer is the opposite of the on-delay timer listed above. This timer simply "delays turning off". After our sensor (input) sees a target we turn on a solenoid (output). When the sensor no longer sees the target we hold the solenoid on for x-seconds before turning it off. It is called a TOF (timer off-delay) and is less common than the on-delay type listed above. Retentive or Accumulating timer This type of timer needs 2 inputs. One input starts the timing event (i.e. the clock starts ticking) and the other resets it. The on/off delay timers above would be reset if the input sensor wasn't on/off for the complete timer duration. This timer however holds or retains the current elapsed time when the sensor turns off in mid-stream. For example, we want to know how long a sensor is on for during a 1 hour period. If we use one of the above timers they will keep resetting when the sensor turns off/on. This timer however, will give us a total or accumulated time. It is often called an RTO (retentive timer) or TMRA (accumulating timer). Let's now see how to use them. We typically need to know 2 things: 1. What will enable the timer? Typically this is one of the inputs.(a sensor connected to input 0000 for example) 2. How long we want to delay before we react. Let's wait 5 seconds before we turn on a solenoid, for example. When the instructions before the timer symbol are true the timer starts "timing". When the time elapses the timer will automatically close its contacts. When the program is running on the PLC, the program typically displays the elapsed or "accumulated" time for us so we can see the current value. Typically timers can time from 0 to 9999 or 0 to 65535 times. Why the weird numbers? Again its because most PLCs have 16-bit timers. 0-9999 is 16-bit BCD (binary coded decimal) 0 to 65535 is 16-bit binary. Each tick of the clock is equal to x-seconds. Typically each manufacturer offers several different ticks.
Copyright Chisholm Institute

Off-Delay timer

- 45 -

PLC BASICS OMRON Most manufacturers offer 10 and 100 ms increments (ticks of the clock). A "ms" is a milli-second or 1/1000th of a second. Several manufacturers offer 1ms as well as 1 second increments. These different increment timers work the same as above but sometimes they have different names to show their timebase. Some are TMH (high speed timer), TMS (super high speed timer) or TMRAF (accumulating fast timer) Shown below is a typical timer instruction symbol we will encounter (depending on which manufacturer we choose) and how to use it. Remember that while they may look different they are all used basically the same way. If we can setup one, we can setup any of them. This timer is the on-delay type and is named Txxx.

When the enable input is on the timer starts to tick. When it ticks yyyyy (the preset value) times, it will turn on its contacts that we will use later in the program. Remember that the duration of a tick (increment) varies with the vendor and the timebase used. (i.e. a tick might be 1ms or 1 second or...) Below is the symbol shown on a ladder diagram:

In this diagram we wait for input 0001 to turn on. When it does, timer T000 (a 100ms increment timer) starts ticking. It will tick 100 times. Each tick (increment) is 100ms so the timer will be a 10000ms (i.e. 10 second) timer. - 46 Copyright Chisholm Institute

PLC BASICS OMRON 100ticks X 100ms = 10,000ms. When 10 seconds have elapsed, the T000 contacts close and output 500 turns on. When input 0001 turns off(false) the timer T000 will reset back to 0 causing its contacts to turn off(become false) thereby making output 500 turn back off. An accumulating/retentive timer would look similar to this:

This timer is named Txxx. When the enable input is on the timer starts to tick. When it ticks yyyyy (the preset value) times, it will turn on its contacts that we will use later in the program. Remember that the duration of a tick (increment) varies with the vendor and the timebase used. (i.e. a tick might be 1ms or 1 second or...) If however, the enable input turns off before the timer has completed, the current value will be retained. When the input turns back on, the timer will continue from where it left off. The only way to force the timer back to its preset value to start again is to turn on the reset input. The symbol is shown in the ladder diagram below.

In this diagram we wait for input 0001 to turn on. When it does timer T000 (a 10ms increment timer) starts ticking. It will tick 100 times. Each tick (increment) is 10ms so the timer will be a 1000ms (1 second) timer. (100ticks X 10ms = 1,000ms). When 1 second has elapsed, the T000 contacts close and 5000 turns on. If input 0001 turns off while the timer is timing the accumulated value will be retained. When 0001 turns back on the timer will continue where it left off.
Copyright Chisholm Institute

- 47 -

PLC BASICS OMRON When input 0002 turns on (true) the timer T000 will reset back to 0 causing its contacts to turn off (become false). Always remember that although the symbols may look different they all operate the same way. Typically the major differences are in the duration of the ticks increments.

CPM1A Timer instructions


On delay TIM

Description A timer is activated when its execution condition goes ON and is reset (to SV) when the execution condition goes OFF. Once activated, TIM measures in units of 0.1 second from the SV. If the execution condition remains ON long enough for TIM to time down to zero, the Completion Flag for the TC number used will turn ON and will remain ON until TIM is reset (that is, until its execution condition goes OFF). Operand Data Areas: N: SV: TC Number 000 - 511 IO, AR, DM, HR, #

Set value (word, BCD)

Use the TIM instruction to turn an output on or off after the timer has been on for a preset time interval. This output instruction begins timing when its rung goes "true." It then waits the specified amount of time (as set in the set value SV), keeps track of the accumulated intervals which have occurred, and sets the TIM000 bit when the current time equals zero.

- 48 -

Copyright Chisholm Institute

PLC BASICS OMRON

Example (TIM )
Enter the following program being careful to enter the addresses exactly as shown. Confirm that you have entered the number 100 as the timer's set value. This value represents a 10 second timing interval (100x0.1) as the timebase is fixed at 0.1 seconds:

Ladder

Mnemonics

Once you have your program entered and compiled, download it to the PLC. Ensure that Switch 0.00 is Open, and then place the PLC into the Run mode. Note the initial value of timer TIM000's present value (PV) and set value (SV) in the spaces below. Also indicate the state of each of the timer's control bits in the spaces provided: Initial State (Switch I0.0=Open): TIM000 (PV) = _____ TIM000 (SV) TIM000 (contact) = _____ = _____

Copyright Chisholm Institute

- 49 -

PLC BASICS OMRON Close switch 0.00, and carefully observe the incrementing of the timer's accumulator, and the state of its control bit (timer contact). Once the Timer reaches zero, note the final value of timer TIM000's accumulator, preset, and the state of its control bit below: Accumulated = preset (Switch I0.0=Closed): TIM000 (PV) = _____ TIM000 (SV) TIM000 (contact) = _____ = _____

Toggle the state of switch 0.00 a number of times, and observe the operation of the Timer in the Ladder Rung program display. Confirm that when the rung is taken false, the accumulator and its control bit is set to the SV. This type of timer is a non-retentive instruction. Conclusion: Use the TIM instruction to turn an output on or off after the timer has been on for a preset time interval. This output instruction begins timing when its rung goes "true". It waits the specified amount of time (as set in the SV), keeps track of the accumulated intervals which have occurred and sets the timer contact when the accumulated time equals zero. As long as rung conditions remain true, the timer adjusts its accumulated value each evaluation until it reaches zero. The accumulated value is reset when rung conditions go false, regardless of whether the timer has timed out. Note: The Omron CPM1A does not support timer off delay and retentive timer instructions.

- 50 -

Copyright Chisholm Institute

PLC BASICS OMRON

Counters
A counter is a simple device intended to do one simple thing - count. Using them, however, can sometimes be a challenge because every manufacturer (for whatever reason) seems to use them a different way. The following information will let you simply and easily program anybody's counters.

Types of counters
What kinds of counters are there? Well, there are up-counters (they only count up 1,2,3...). These are called CTU,(count up) CNT,C, or CTR. There are down counters (they only count down 9, 8, 7, ...). These are typically called CTD (count down) when they are a separate instruction. There are also up-down counters (they count up and/or down 1, 2, 3, 4, 3, 2, 3, 4, 5, ...). These are typically called UDC (up-down counter) when they are separate instructions. Many manufacturers have only one or two types of counters but they can be used to count up, down or both. To further confuse the issue, most manufacturers also include a limited number of high-speed counters. These are commonly called HSC (high-speed counter), or CTH (Counter High-speed?). Typically a high-speed counter is a "hardware" device. The normal counters listed above are typically "software" counters, in other words they don't physically exist in the plc but rather they are simulated in software. Hardware counters do exist in the plc and they are not dependent on scan time. A good rule of thumb is simply to always use the normal (software) counters unless the pulses you are counting will arrive faster than 2x the scan time. (i.e. if the scan time is 2ms and pulses will be arriving for counting every 4ms or longer then use a software counter. If they arrive faster than every 4ms (3ms for example) then use the hardware (high-speed) counters. (2 x scan time = 2 x 2ms = 4ms) To use them we must know 3 things: 1. Where the pulses that we want to count are coming from. Typically this is from one of the inputs (a sensor connected to input 0000 for example). 2. How many pulses we want to count before we react. Let's count 5 bottles before we box them, for example. 3. When/how we will reset the counter so it can count again. After we count 5 bottles lets reset the counter, for example. When the program is running on the PLC the program typically displays the current or "accumulated" value for us so we can see the current count value.

Copyright Chisholm Institute

- 51 -

PLC BASICS OMRON Typically counters can count from "0 to 9999", "-32,768 to +32,767" or "0 to 65535". Why the weird numbers? This is because 0-9999 is 16-bit BCD (binary coded decimal) and -32,768 to 32767 and 0 to 65535 require 16-bit binary and most PLCs use 16-bit numbers Here are some of the instruction symbols we will encounter (depending on which manufacturer we choose) and how to use them. Remember that while they may look different they are all used basically the same way. If we can program one, we can program any of them.

In this counter we need 2 inputs. One goes before the reset line. When this input turns on the current (accumulated) count value will return to zero. The second input is the address where the pulses we are counting are coming from. For example, if we are counting how many bottles pass in front of the sensor that is physically connected to input 0001 then we would put normally open contacts with the address 0001 in front of the pulse line. Cxxx is the name of the counter. If we want to call it counter 000 then we would put "C000" here. yyyy is the number of pulses we want to count before doing something. If we want to count 5 bottles before turning on a physical output to box them we would put 5 here. If we wanted to count 100 bottles then we would put 100 here, etc. When the counter is finished (i.e. we counted yyyy bottles) it will turn on a separate contact that we also label Cxxx. Note that the counter accumulated value ONLY changes at the off to on transition of the pulse input. Here's the symbol on a ladder showing how we set up a counter (we'll name it counter 000) to count 100 bottles from input 0001 before turning on output 500. Sensor 0002 resets the counter.

- 52 -

Copyright Chisholm Institute

PLC BASICS OMRON Below is one symbol we may encounter for an up-down counter. We'll use the same abbreviation as we did for the example above.(i.e. UDCxxx and yyyyy)

In this up-down counter we need to assign 3 inputs. The reset input has the same function as above. However, instead of having only 1 input for pulse counting, we now have 2. One is for counting up and the other is for counting down. In this example we will call the counter UDC000 and we will give it a preset value of 1000. (we'll count 1000 total pulses) For inputs we'll use a sensor which will turn on input 0001 when it sees a target and another sensor at input 0003 will also turn on when it sees a target. When input 0001 turns on we count up and when input 0003 turns on we count down. When we reach 1000 pulses we will turn on output 500. Again note that the counter accumulated value ONLY changes at the off to on transition of the pulse input. The ladder diagram is shown below.

One important thing to note is that in some PLCs counters and timers can't have the same address. This is because they typically use the same registers.

Copyright Chisholm Institute

- 53 -

PLC BASICS OMRON

CPM1A Counter instructions


Count down CNT

Description CNT is used to count down from SV when the execution condition on the count pulse, CP, goes from OFF to ON, that is, the present value (PV) will be decremented by one whenever CNT is executed with an ON execution condition for CP and the execution condition was OFF for the last execution. If the execution condition has not changed or has changed from ON to OFF, the PV of CNT will not be changed. The Completion Flag for a counter is turned ON when the PV reaches zero and will remain ON until the counter is reset. CNT is reset with a reset input, R. When R goes from OFF to ON, the PV is reset to SV. The PV will not be decremented while R is ON. Counting down from SV will begin again when R goes OFF. The PV for CNT will not be reset in interlocked program sections or by power interruptions. Operand Data Areas: N: TC Number SV: Set value (word, BCD) 000 - 511 IO, AR, DM, HR, #

Since there is one current value for each counter, do not assign the same counter number to more than one counter. (Up Counters, Up/Down Counters, and Down Counters with the same number access the same current value.) This output instruction counts down for each false-to-true transition of conditions preceding it in the rung and produces an output when the accumulated value reaches the preset value. Rung transitions might be triggered by a limit switch or by parts travelling past a detector. - 54 Copyright Chisholm Institute

PLC BASICS OMRON The ability of the counter to detect false-to-true transitions depends on the speed (frequency) of the incoming signal. The on and off duration of an incoming signal must not be faster than the scan time. Each count is retained when the rung conditions again become false.

Example (CNT)
Enter the following program being careful to enter the addresses exactly as shown.

Ladder

Mnemonics

Confirm that you have entered the number 10 as the counter's set value. This value is optionally used to set the point at which the counter's completion flag will be Set, indicating that the count is complete. Once you have your program entered, and have ensured that it is correct, download it to the PLC. Ensure that Switches 0.00 and 0.01 are Open, and then place the PLC into the Run mode. Close switch 0.01 momentarily to set the counter to its SV. Note the value of Counter C0's present value PV, set and completion flag (contact) in the spaces provided below.

Copyright Chisholm Institute

- 55 -

PLC BASICS OMRON Initial State (Switch I0.0=Open): CNT000 PV = _______ CNT000 SV = _______

CNT000 contact = _______ Open and Close switch 0.00 a number of times and carefully observe the decrementing of C0's accumulator and the operation of the output bit. Close switch 0.01 and observe the effect that the "R" input has on the counter. Attempt to decrement the counter while switch I0.1 is closed. You should not be able to decrement the counter while the "R" input is held "True". Open switch 0.01 to allow the "R" input to go false, and then decrement the counter until the PV equals zero. Decrement the counter 2 or 3 more times and note the final value of C0's accumulator, preset and status bits in the spaces below. Final State CNT000 PV CNT000 SV = _______ = _______

CNT00 contact = _______ Conclusion: The CNT output instruction counts down for each false-to-true transition of conditions preceding it in the rung and produces an output when the accumulated value reaches zero. Rung transitions might be triggered by a limit switch or by parts travelling past a detector etc. The ability of the counter to detect a false-to-true transition depends on the speed (frequency) of the incoming signal. The on and off duration of an incoming signal must not be faster than the scan time.

- 56 -

Copyright Chisholm Institute

PLC BASICS OMRON

Up/down counter (reversible) CNTR

Description The CNTR(12) is a reversible, up/down circular counter, that is, it is used to count between zero and SV according to changes in two execution conditions, those in the increment input (II) and those in the decrement input (DI). The present value (PV) will be incremented by one whenever CNTR(12) is executed with an ON execution condition for II. The present value (PV) will be decremented by one whenever CNTR(12) is executed with an ON execution condition for DI and the last execution condition for DI was OFF. If OFF to ON changes have occurred in both II and DI since the last execution, the PV will not be changed. If the execution conditions have not changed or have changed from ON to OFF for both II and DI, the PV of CNT will not be changed. When decremented from 0000, the present value is set to SV and the Completion Flag is turned ON until the PV is decremented again. When incremented past the SV, the PV is set to 0000 and the Completion Flag is turned ON until the PV is incremented again. CNTR(12) is reset with a reset input, R. When R goes from OFF to ON, the PV is reset to zero. The PV will not be incremented or decremented while R is ON. Counting will begin again when R goes OFF. The PV for CNTR(12) will not be reset in interlocked program sections or by the effects of power interruptions. (retentive) Operand Data Areas: N: TC Number SV: Set value (word, BCD) 000 - 511 IO, AR, DM, HR, LR, #

Copyright Chisholm Institute

- 57 -

PLC BASICS OMRON

Exercises and Assessment items


Exercise 1

Stop Start Station. When the start button is operated the line contactor is energised, closing the hold in contact. The line contactor will remain energised until the stop button is pressed.

- 58 -

Copyright Chisholm Institute

PLC BASICS OMRON

Exercise 2

Multiple Stop Start Station. Operation of either PB3 or PB4 will energise the line contactor and operation of PBI or PB2 will de-energise the circuit.

Copyright Chisholm Institute

- 59 -

PLC BASICS OMRON

Exercise 3

Direct OnLine Motor Starter. A D.O.L. motor starter is used to connect AC motors to the supply mains in one switching step. A typical D.O.L. starter would cater for; a. Stop button input. b. Start button input. c. Thermal overload protection. d. Motor stop/run indicators.

- 60 -

Copyright Chisholm Institute

PLC BASICS OMRON

Exercise 4

Conveyor Control The above circuit operates as follows. When the conveyor is stopped 'Motor stopped' light is on. When the reverse start button is pressed the conveyor starts in reverse and the reverse indicator light comes on. When the forward start button is pressed the conveyor starts in forward and the forward indicator light comes on. The Conveyor must be stopped before changing from reverse to forward and vice versa. The conveyor shuts down if either 'Thermal overload' or 'master stop' is pressed.

Copyright Chisholm Institute

- 61 -

PLC BASICS OMRON

Exercise 5

Conveyor Control Operation PB2 starts the conveyor in fast forward mode. PB3') starts the conveyor in fast reverse mode. Interlocking prevents forward and reverse being energised at the same time. PB5 puts the conveyor into slow mode. (Only when fast forward or reverse is selected).

- 62 -

Copyright Chisholm Institute

PLC BASICS OMRON

Assessment Item 1 Door Simulation


Take the time to familiarize yourself with the components used in the Door system, and take particular note of the current state of the limit switches. When the door is in the closed position, the lower limit is activated and the upper limit is deactivated. Both upper and lower limit switches are normally open switches and only close when the striker on the bottom of the door comes in contact with them. Don't continue on with the exercise until you are confident that you understand the operation of the system.

In this exercise we want you to apply your knowledge of Relay Logic Instructions to design a program which will control the Door. The Door System includes a Reversible Motor, a pair of Limit Switches and a Control Panel, all connected to your PLC. The program you create will monitor and control this equipment while adhering to the following criteria: The Open and Close pushbuttons will be used to control the movement of the door. Movement will not be maintained when either switch is released. Pressing the Open Switch will cause the door to move upwards (open) if not already fully open. The opening operation will continue as long as the switch is held down. If the switch is released, or if limit switch LS1 closes, the door movement will halt immediately. Pressing the Close Switch will cause the door to move down (close) if not already fully closed. The closing operation will continue as long as the switch is held down. If the switch is released, or if limit switch LS2 closes, the door movement will halt immediately. If the Door is already fully opened, pressing the Open Switch will not energize the motor. If the Door is already fully closed, pressing the Close Switch will not energize the motor. Under no circumstance will both motor windings be energized at the same time.
Copyright Chisholm Institute

- 63 -

PLC BASICS OMRON The Open Lamp will be illuminated if the door is in the Fully Open position. The Shut Lamp will be illuminated if the door is in the Fully Closed position. The Ajar lamp will be illuminated when the door is ajar. Design, debug, and test your Program. Avoid the use of Set or Reset latching instructions, and make a concerted effort to minimize the number of rungs employed. Ensure that you have made effective use of both instruction and rung comments to clearly document your program. All I/O components referenced within your program should be clearly labelled, and rung comments should be employed to add additional clarity as required.

- 64 -

Copyright Chisholm Institute

PLC BASICS OMRON

Assessment Item 2 Level Application (Using Latching instructions.)


Write a PLC program to control the following process using latch (S) and unlatch (R) instructions We are controlling the level of lubricating oil being dispensed from a tank. This is possible by using two sensors. We put one near the bottom and one near the top, as shown in the picture below.

The fill motor is to pump lubricating oil into the tank until the high level sensor turns on. At that point the motor is turned off until the level falls below the low level sensor. The fill motor should turn on again and repeat the process. Both inputs are NC (normally closed) fibre-optic level sensors. When they are NOT immersed in liquid they will be ON. When they are immersed in liquid they will be OFF.

Copyright Chisholm Institute

- 65 -

PLC BASICS OMRON

Assessment Item 3 Carton Filling Timer.

This circuit places a ten second shot of liquid into a carton each time a carton position limit switch is operated. The circuit must provide for; a. Carton position limit input. b. Dosing solenoid output.

- 66 -

Copyright Chisholm Institute

PLC BASICS OMRON

Assessment Item 4 Pallet Loading Counter.

This system batches boxes onto a pallet. A solenoid is energised when the eighth box is loaded, and de-energised when a full pallet moves out. The circuit provides for the following inputs and outputs; a. Box detector limit switch, LSI, actuated by boxes arriving on the pallet. b. Pallet change limit switch, LS2, actuated by an outgoing pallet. c. Pallet change solenoid.

Copyright Chisholm Institute

- 67 -

You might also like