programmable logic controller

46
Chapter 5 Programmable Logic Controller (PLC) Contents:- 5.1 Introduction 5.2 Brief History of PLC 5.3 Area of Application of a PLC 5.4 How works PLC 5.5 Types of PLC 5.5.1 Fixed PLCs 5.5.2 Modular PLCs 5.6 Basic Components of PLC 5.6.1 Processor (Control Processing Unit) 5.6.2 Input/output system 5.6.3 Memory unit 5.6.4 Programming language & device 5.6.5 Power supply 5.7 Advantages 5.8 Allen Bradley MicroLogix 5.8.1 MicroLogix 1200 controller 5.8.1.1 Power and I/O Configuration of MicroLogix 1200 controller 5.8.1.2 Advantages for MicroLogix 1200 controller 5.9 PLC programming 5.9.1 RSLogix 500 5.9.2 Ladder Logic 5.9.3 Main Ladder Program 1

Upload: jinesh-patel

Post on 06-May-2015

10.984 views

Category:

Education


7 download

DESCRIPTION

It is good for basic ideas of programmable logic controller. It is must necessary now a days in every automation sector.

TRANSCRIPT

Page 1: Programmable Logic Controller

Chapter 5

Programmable Logic Controller (PLC)

Contents:-

5.1 Introduction5.2 Brief History of PLC5.3 Area of Application of a PLC5.4 How works PLC5.5 Types of PLC

5.5.1 Fixed PLCs5.5.2 Modular PLCs

5.6 Basic Components of PLC5.6.1 Processor (Control Processing Unit)5.6.2 Input/output system5.6.3 Memory unit5.6.4 Programming language & device5.6.5 Power supply

5.7 Advantages5.8 Allen Bradley MicroLogix

5.8.1 MicroLogix 1200 controller5.8.1.1 Power and I/O Configuration of MicroLogix 1200 controller5.8.1.2 Advantages for MicroLogix 1200 controller

5.9 PLC programming 5.9.1 RSLogix 5005.9.2 Ladder Logic5.9.3 Main Ladder Program5.9.4 Explanation of Program

5.9.4.1 Explanation of Instructions 5.9.4.2 Explaining of Control of X-Motor5.9.4.3 Explaining of Control of Electromechanical Gripper

1

Page 2: Programmable Logic Controller

5.1 Introduction to PLC :-

A Programmable Logic Controller (PLC) or Programmable Controller is a digital computer used for automation of electromechanical processes, such as control of machinery on factory assembly lines, control of amusement rides, or control of lighting fixtures.

A formal definition Of a PLC comes from the National Electrical Manufacturers Association (NEMA):

“A digitally operating electronic system, designed for use in an industrial environment, which uses a programmable memory for the internal storage of user-oriented instructions for implementing specific functions such as logic, sequencing, timing, counting and arithmetic, to control, through digital or analogue inputs and outputs, various types of machines or processes. Both the PC and its associated peripherals are designed so that they can be easily integrated into an industrial control system and easily used in all their intended functions."

PLCs are used in many different industries and machines such as packaging and semiconductor machines. Unlike general-purpose computers, the PLC is designed for multiple inputs and output arrangements, extended temperature ranges, immunity to electrical noise, and resistance to vibration and impact. Programs to control machine operation are typically stored in battery-backed or non-volatile memory. A PLC is an example of a real time system since output results must be produced in response to input conditions within a bounded time, otherwise unintended operation will result.

5.2 Brief History of PLC :-

In 1960s and 1970s, electromachanical relays, timer, counters and sequencers were the standard. Many Control Panels Contained Hundreds of these electromachanical devices and in some cases, a mile or more of wire. The primary negative aspect of mechanical control was that reliability was low, in contrast to maintenance costs associated with keeping these panels operating, which were extremely high. The auto industry complained that the real cost of purchase and replace a single relay could run as high as $50. A second major factor was time, expense, and labor required when a change in control needs dictated a control panel modification. In fact, during the model year changeovers, the auto industry discarded entire control panels and replaced them with new ones as the quickest and cheapest solution.

The programmable controller is a solid state electronic device designed in the early 1970s to replace electromechanical relays, mechanical timers, counters, and sequencers. The Hydromatic division of General Motors was the first to see the need for a device that would become what we know as the programmable logic controller. High speed manufacturing, as in the auto industry, required reliable control devices that was smaller, consumed less power featured

2

Page 3: Programmable Logic Controller

fast switching, and were quickly and easily changeable. These devices must also be able to withstand the harsh industrial environment. Keep in mind that the first PLCs were little more than relay replacers.

5.3 Area of Application of a PLC :-

Every system or machine has a controller. Depending on the type of technology used, controllers can be divided into pneumatic, hydraulic, electrical and electronic controllers. Frequently, a combination of different technologies is used. Furthermore, differentiation is made between hard-wired programmable (e.g. wiring of electro-mechanical or electronic components) and programmable logic controllers. The first is used primarily in cases, where any reprogramming by the user is out of the question and the job size warrants the development of a special controller. Typical applications for such controllers can be found in automatic washing machines, video cameras, and cars.

Fig (A): Example of a PLC application

3

Page 4: Programmable Logic Controller

However, if the job size does not warrant the development of a special controller or if the user is to have the facility of making simple or independent program changes, or of setting timers and counters, then the use of a universal controller, where the program is written to an electronic memory, it is the preferred option. The PLC represents such a universal controller. It can be used for different applications and, via the program installed in its memory, provides the user with a simple means of changing, extending and optimizing control processes.

5.4 How works PLC :-

The original task of a PLC involved the interconnection of input signals according to a specified program and, if "true", to switch the corresponding output. Boolean algebra forms the mathematical basis for this operation, which recognizes precisely two defined statuses of one variable: "0" and "1" (see also chapter 3). Accordingly, an output can only assume these two statuses. For instance, a connected motor could therefore be either switched on or off, i.e. controlled.

This function has coined the name PLC: Programmable logic controller, i.e. the input/output behavior is similar to that of an electromagnetic relay or pneumatic switching valve controller; the program is stored in an electronic memory.

In our Project, we are going to work with Controlling of a stepper motor, so that it is required pulses to rotate a motor. And pulse is given to PLC by using Parallel Port.

However, the tasks of a PLC have rapidly multiplied: Timer and counter functions, memory setting and resetting, mathematical computing operations all represent functions, which can be executed by practically any of today’s PLCs.

5.5 Types of PLC :-

PLC hardware falls into two physical configurations:I. Fixed PLCs

II. Modular PLCs

5.5.1 Fixed PLCs :-

A Fixed PLC has all of its components-the input section, CPU and associated memory, power supply, and output section-built into one self-contained unit. All input and output terminals are built into the PLC package and are fixed, not removable. This style of PLC is also called a Packed Controller. With miniaturization of modern electronics component, today’s more compact fixed PLCs are referred to as micro PLCs.

4

Page 5: Programmable Logic Controller

Fig (B): Fixed PLC Fig (C): Modular PLC

5.5.2 Modular PLCs :-

The modular PLC comes as separate pieces. A modular PLC is purchased piece by piece. There may be two or three power supplies to choose from, a handful of different processors (CPUs), many separate input and output cards or modules, and selection of assemblies, called racks, chassis, or base plates to hold the pieces together. When purchasing a modular PLC you select and purchase the specific pieces you need to build the PLC specifically for the needs of your control situation.

5.6 Basic Components of PLC :-

Regardless of Size, cost, or complexity, all programmable controllers share the same basic components and functional characteristics. A Programmable controller will always consist of following components:

I. Processor (Control Processing Unit)II. Input/output system

III. Memory unitIV. Programming language & deviceV. Power supply

5.6.1 Processor (CPU) :-

The Processor consists of one or more standard or custom microprocessor and other integrated circuits that perform the computing and control function of the PC system. Since the processor in most programmable controller system is microprocessor-based.

The CPU is the focal point of the system, it must have facilities for storing the control program, and there must be some sort of data storage. In executing a program, the microprocessor uses the data buses to exchange information in a well-defined manner. The

5

Page 6: Programmable Logic Controller

complete sequence of information exchange that carries out one program stop is known as an “Instruction cycle”.

Fig (D): PLC Components

5.6.2 Input/output System :-

Input/output (I/O) system provides the physical connection between the process equipment and the processor. The programmable controller system uses various input modules to sense and measure physical quantities of the process, such as motion, level, temperature, pressure, position, current, and voltage. Based on the status sensed or values measured, the processor controls various output modules to drive field devices such as valves, motors, pumps, and alarms to exercise control over a machine or a process.

There are different types of Input/output (I/O) modules:I. Analog I/O Modules,

II. Digital I/O Modules,III. AC I/O Modules,IV. DC I/O Modules andV. Intelligent I/O Modules.

6

Page 7: Programmable Logic Controller

5.6.3 Memory Unit :-

Memory is used to store control program for the PC System; it is usually located in the same housing as the CPU. The information stored in memory determines how the input and output data will be processed.

Memory elements store individual pieces of data called bits. A bit has two states: 1 or 0, on or off, true or false, etc. Memory units are mounted on circuit boards and are usually specified in thousands or “K” increments where 1K is 1024 words (i.e., 210 =1024) of storage space. Programmable controller memory capacity may vary from less than one thousand words to over 64,000 words (64K words) depending on the programmable controller manufacturer. The complexity of the control plan will determine the amount of memory required.

5.6.4 Programming Language & Device :-

The Programming language allows the user to communicate with the PLC via a programming device. Programmable controller manufacturers use several different programming languages; but they all convey to the system, by means of instruction a basic control plan.

The control plan or program is defined as a set of instructions that are arranged in a logical sequence to control the actions of a process or machine. A program is written by combining instruction in a certain order. Rules govern the manner in which instructions are combined and the actual form of the instructions. These rules and instructions combine to form a language.

The four most common types of languages encountered in programmable logic controllers are as follows:

I. Ladder ProgrammingII. Statement List Programming

III. Function Block ProgrammingIV. Boolean Logic

The Programming device is used to enter, store, and monitor the programmable controller software. Programming devices can be dedicated or personal computers that normally have four basic components: keyboard, visual display, microprocessor, and communication cable.

The programming terminal is normally connected only to the programmable logic controller system during programming or during troubleshooting of the control system. Otherwise the programming device is disconnected from the system.

The most common programming terminals are as follows:I. Hand-held manual programmer (HMI)

II. Industrial programming terminal

7

Page 8: Programmable Logic Controller

III. Personal computer-based programmer(PLC Software)

5.6.5 Power Supply :-

The power supply converts ac line voltage to dc voltage to power the electronics circuits in a programmable controller system. These power supplies rectify, filter, and regulate voltages and currents to supply the correct amounts of voltage and current to the system. The power supply normally converts 120 V ac or 240 V ac line voltages into direct voltages into direct current voltages such as + 5 or ± 15 V.

The power supply for a programmable controller system may be integrated with the processor, memory, and I/O module into a single housing or it may be a separate unit connected to system through a cable.

Fig (E): programmable controller system with process graphics.

8

Page 9: Programmable Logic Controller

5.7 Advantages of PLC :-

PLCs have been gaining popularity on the factory floor and will probably remain predominant for some time to come. Most of this is because of the advantages they offer:

Smaller physical size than the hard-wire solution. Easier and faster to make changes. PLCs have integrated diagnostics and override functions. Reliability of the plc is greater and maintenance is easier. Diagnostics are centrally available. Applications can be immediately documented. Applications can be dublicated faster and less expensively. Cost effective for controlling complex systems. Flexible and can be reapplied to control other systems quickly and easily. Computational abilities allow more sophisticated control. Trouble shooting aids make programming easier and reduce downtime.

5.8 Allen Bradley MicroLogix PLCs :-

The MicroLogix family of controllers provides five levels of control. Small on size, big on performance, the MicroLogix 1000 controller offers control capabilities in an affordable, compact package. The MicroLogix 1200 controller is small enough to fit in tight spaces, but powerful enough to accommodate a broad range of applications. Designed to grow as your needs grow, the MicroLogix 1500 controller helps you achieve high-level control in a variety of applications. The MicroLogix family’s newest members, the MicroLogix 1100 and 1400 controllers, further enhance the MicroLogix family by expanding the application coverage area while offering great new features at an affordable price.

9

Page 10: Programmable Logic Controller

Fig (F): The MicroLogix Family of Programmable controller.

In our project, we have used Allen Bradley MicroLogix 1200 controller for controlling Stepper motor. Thus, now we will discuss about MicroLogix 1200 controller and its specification & advantages.

5.8.1 MicroLogix 1200 controller :-

The MicroLogix 1200 controller provides more computing power and flexibility than the MicroLogix 1000 controller to solve a variety of application needs.

Available in 24- and 40-point versions, the I/O count can be expanded by using rack less I/O modules. This results in larger control systems, greater application flexibility and expandability at a lower cost and reduced parts inventory.

10

Page 11: Programmable Logic Controller

A field-upgradable flash operating system that helps to make sure you will always be up-to-date with the latest features, without having to replace hardware. The controller can be easily updated with the latest firmware via a website download.

Fig (G): Use of MicroLogix 1200 PLC

5.8.1.1 Power and I/O Configuration of MicroLogix 1200 controller:-

Table (A):

CAT. NO. LINE VOLTAGE

NUMBER OF INPUTS

NUMBER OF OUTPUTS

HIGH SPEED I/O

1762-L24AWA,1762-L24AWAR

120/240V AC (14) 120V AC (10) Relay N/A

1762-L40AWA,1762 -L40AWAR

120/240V AC (24) 120V AC (16) Relay N/A

1762-L24BWA,1762 -L24BWAR

120/240V AC(10) Standard 24V DC(4) Fast 24V DC

(10) Relay (4) 20 kHz input

1762-L40BWA,1762 -L40BWAR

120/240V AC(20) Standard 24V DC(4) Fast 24V DC

(16) Relay (4) 20 kHz input

1762-L24BXB,1762 -L24BXBR

24V DC(10) Standard 24V DC(4) Fast 24V DC

(5) Relay(4) Standard 24V DC FET(1) Fast 24V DC FET

(4) 20 kHz input(1) 20 kHz output

1762-L40BXB,1762-L40BXBR

24V DC(20) Standard 24V DC(4) Fast 24V DC

(8) Relay(7) Standard 24V DC FET(1) Fast 24V DC FET

(4) 20 kHz input(1) 20 kHz output

11

Page 12: Programmable Logic Controller

5.8.1.2 Advantages for MicroLogix 1200 controller :-

Large 6 KB memory (4 KB User Program with 2 KB User Data) to solve a variety of applications.

High performance expansion I/O options (up to six modules depending on current/power budget).

Four high-speed inputs (for controllers with 24V DC inputs) that can be used individually as latching (pulse-catch) inputs, event interrupts, or alternately combined as one 20 kHz high-speed counter featuring eight modes of operation.

One high-speed output that can be configured as 20 kHz pulse train output (PTO) or as pulse width modulated (PWM) output (available on controllers with embedded 24V DC outputs).

One, 1 ms, selectable timed interrupt (STI). High-resolution, 1 ms timers. The same advanced communication options as the MicroLogix 1000 controller, including

peer-to-peer and SCADA/RTU networks, DF1 full-duplex, DF1 half-duplex slave, DH-485, Device Net and Ethernet/IP , plus DF1 half-duplex master, Modbus master and slave, and DF1 radio modem protocols.

ASCII read/write capability. An additional Programming/HMI Port, providing connectivity to a DF1 full-duplex

compatible device such as an operator interface or programming terminal (MicroLogix 1200R controllers only, catalog number 1762-LxxxxxR).

Optional real-time clock, to allow control to be based on actual time of day, day of week, or other calendar related timing.

Optional memory module, for external program backup, transport and transfer to another controller. Control program and data are securely backed up to internal flash memory when power is not applied.

Data file download protection prevents critical user data from being altered via program downloads from programming computers or memory modules.

Two built-in analog trim potentiometers. 32-bit signed integer math. Floating-point and double integer data file support. Built-in PID capabilities. Finger-safe terminal blocks meet global safety standards. Removable terminal blocks on 40-point controllers allow pre-wiring. Regulatory agency certifications for world-wide market (CE, C-Tick, UL, c-UL, including Class

1 Division 2 Hazardous Location).

12

Page 13: Programmable Logic Controller

5.9 PLC Programming :-

We have used RSLogix 500 as a programming software and Ladder logic as a programming language. So now, we will discuss about RSLogix 500, Ladder logic and main PLC program in this topic.

5.9.1 RSLogix 500 :-

RSLogix 500 software is a 32-bit Windows ladder logic programming package for the SLC 500 and MicroLogix® processors. RSLogix 500 is compatible with SLC 500 and MicroLogix programs created with any of Rockwell Software’s programming packages.

RSLogix 500 software includes: A free-form ladder editor that lets you concentrate on the application logic instead

of syntax as you write your program. A powerful project verifier that you use to build a list of errors you can navigate to

make corrections at your convenience. drag-and-drop editing to quickly move data table elements from one data file to

another, rungs from one subroutine or project to another, or instructions from rung to rung within a project.

An address wizard that makes entering addresses easier and reduces keying errors. A point-and-click interface called a project tree that lets you access all the folders

and files contained in your project. SLC libraries for storing and retrieving portions of ladder logic for use across any of

Rockwell Software's SLC programming software products. A compare utility that lets you graphically view project differences.

Fig (H): RSLogix 500 for PLC programming

13

Menu toolbar

Icon bar

Online bar

Project tree

Result pane

Status bar

Instruction toolbar

Ladder view

Page 14: Programmable Logic Controller

5.9.2 Ladder Logic :-

Ladder logic is the main programming method used for PLCs. It is defined by “Graphical language for describing output of an electrical switching system as a function of

its inputs”. It is also known as “relay ladder logic” or RLL. Primarily it is used to relate logical inputs (switch closures) to relay coil outputs. (For example, Start switch used to energize a motor contactor relay). And commonly it is used to document control equipment in process plants.

Ladder logic has been developed to mimic relay logic. The decision to use the relay logic diagrams was a strategic one. By selecting ladder logic as the main programming method, the amount of retraining needed for engineers and trades people was greatly reduced.

Ladder logic input contacts and output coils allow simple logical decisions. Functions extend basic ladder logic to allow other types of control. For example, the addition of timers and counters allowed event based control. A longer list of functions is shown below:

Combinatorial Logic- relay contacts and coils

Events- Timer instructions- counter instructions

Data Handling- Moves- Mathematics- Conversions

Numerical Logic- Boolean operations- Comparisons

Lists- shift registers/stacks- Sequencers

Program Control- branching/looping- Immediate inputs/outputs- fault/interrupt detection

Input and Output- PID- Communications- high speed counters- ASCII string functions

Fig (I) shows the simple example of ladder logic to energize a motor by pushing ‘START’ pushbutton. When we press pushbutton output coil set to logic 1 or true.

14

Page 15: Programmable Logic Controller

Fig (I): Simple Example of Ladder logic

5.9.3 Main Ladder program :-

Now, we are explaining our Main Ladder program for stepper motor controlling which is shown in figure (J).

15

Page 16: Programmable Logic Controller

16

Page 17: Programmable Logic Controller

Fig (J): PLC Ladder Program for controlling three stepper motors and one electromagnetic gripper

17

Page 18: Programmable Logic Controller

5.9.4 Explanation of Program:-

For fully explanation of PLC ladder program, we should have knowledge about elements of ladder, and various instructions such as basic, comparison, math, data handling, program flow, application specific, block transfer instructions. But in this topic, we are giving information about those instructions which are used in our PLC program.

In PLC program, we are using following instructions:

1) XIC Examine if Closed 2) XIO Examine if Open 3) OTE Output Energize4) ONS One-shot 5) MOV Move 6) BSL Bit Shift Left7) BSR Bit Shift Right

5.9.4.1 Explanation of Instructions:

1. XIC ( Examine if Closed) :Use the XIC (Normally open) instruction in your ladder program to

determine if a bit is ‘On’. When the instruction is executed, if the bit addressed is on (1), then the instruction is evaluated as true. When the instruction is executed, if the bit addressed is off (0), then the instruction is evaluated as false.

Symbol Table (B):- XIC Bit State

Usage:In our program, this instruction is used for giving the input which comes

from parallel port to X-, Y- or Z-stepper motors.

2. XIO ( Examine if Open) :Use the XIO (Normally closed) instruction in your ladder program to

determine if a bit is ‘Off’. When the instruction is executed, if the bit addressed is off (0), then the instruction is evaluated as true. When the instruction is executed, if the bit addressed is on (1), then the instruction is evaluated as false.

Symbol Table (C):- XIO Bit State

Usage:In our program, this instruction is

used for two purposes. (1) Initial loading of bits in to Bit file which is used for giving the sequence of pulses to the stepper motor. (2) To stop to motor by using limit switch for safety in reverse direction.

18

Bit Address State

XIC Instruction

0 False1 True

Bit Address State

XIC Instruction

0 True 1 False

Page 19: Programmable Logic Controller

3. OTE (Output Energize) :

Use the OTE instruction in your ladder program to turn on a bit when rung conditions are evaluated as true. An example of a device that turns on or off is an output wired to a pilot light (addressed as O: 0/4).

Symbol

OTE instructions are reset when: The SLC enters or returns to the REM Run or REM Test mode or

power is restored. The OTE is programmed within an inactive or false Master Control

Reset (MCR) zone.Usage:

In our program, this instruction is used for giving output signal to the steps of the X-, Y- or Z-stepper motor, when input signal comes on bits of the bit file from the parallel port.

4. OSR (One-shot Rising) :

The ONS instruction is an input instruction that makes the rung true for one program scan upon a false-to-true transition of the conditions preceding the ONS instruction on the rung.

Use the ONS instruction to start events that are triggered by a pushbutton, such as pulling values from thumbwheel switches or freezing rapidly displayed LED values.

You must enter a bit address for the bit. Use either a binary file or integer file address.

Symbol

Entering Parameters:Use a bit address from either the bit or integer data file. The addressed bit is

set (1) for one scan when rung conditions preceding the ONS instruction are true (even if the ONS instruction becomes false); the bit is reset (0) when rung conditions preceding the ONS instruction are false.

19

Page 20: Programmable Logic Controller

Notes:Do not use an input or output address to program the address parameter of

the ONS instruction. The bit address you use for this instruction must be unique. Do not use it elsewhere in the program.

Example:

When the input instruction goes from false-to-true, the ONS instruction conditions the rung so that the output goes true for one program scan. The output goes false and remains false for successive scans until the input makes another false-to-true transition.

Usage:In our program, this instruction is used for initial loading of bits in to Bit file

which is used for giving the sequence of pulses to the stepper motor.

5. MOV (Move) :

This output instruction moves the source value to the destination location. As long as the rung remains true, the instruction moves the data each scan.

Symbol

Entering Parameters:Enter the following parameters when programming this instruction:

Source is the address or constant of the data you want to move Destination is the address where the instruction moves the data

Usage:In our program, this instruction is used for loading and moving of constant

value in a bit file and this bit file contains 16 bits. These bits are used to give pulses in sequence to the stepper motor.

20

Page 21: Programmable Logic Controller

In our project, the aim is to control the stepper motor. The stepper motor has four coils and we are using full step operation on it in which we are giving signals to two coils simultaneously because of high loads acting on the motor.

6. BSL (Bit Shift Left) :

BSL is output instruction that load data into a bit array one bit at a time. The data is shifted left through the array, then unloaded one bit at a time.

Symbol

Entering Parameters:Enter the following parameters when programming these instructions: File is the address of the bit array you want to manipulate. You must

use the file indicator (#) in the bit array address. Control is the control element that stores the status byte of the

instruction and the size of the array (in number of bits). Note that the control address should not be used for any other instruction.

Table (D):- Control File Structure

15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00Word 0 EN DN ER UL Not usedWord 1 Size of bit array (number of bits)Word 2 Reserved

Status bits of the control element may be addressed by mnemonic. They include: Unload Bit UL (bit 10) stores the status of the bit exited from the array

each time the instruction is enabled. Error Bit ER (bit 11), when set, indicates the instruction detected an

error such as entering a negative number for the length or position. Avoid using the output bit when this bit is set.

Done Bit DN (bit 13), when set, indicates the bit array has shifted one position.

Enable Bit EN (bit 15) is set on a false-to-true transition of the rung and indicates the instruction is enabled.

When the register shifts and input conditions go false, the enable, done, and error bits are reset.

21

Page 22: Programmable Logic Controller

Bit Address is the address of the source bit that the instruction inserts in the first (lowest) bit position (BSL) or the last (highest) bit position (BSR).

Length (size of bit array) is the number of bits in the bit array, up to 2048 bits. A length value of 0 causes the input bit to be transferred to the UL bit.

When the rung goes from false-to-true, the processor sets the enable bit (EN bit 15) and the data block is shifted to the left (to a higher bit number) one bit position. The specified bit at the bit address is shifted into the first bit position. The last bit is shifted out of the array and stored in the unload bit (UL bit 10). The shift is completed immediately.

Usage:In our program, once a value is loaded in the bit file by using the MOV

instruction, now we are rotating bits contained in bit file with 16 as a size of array left side. When the rung goes from false-to-true, this process will be done. As the bits are rotating left, motor gets forward sequence and it steps forward.

7. BSR (Bit Shift Right) :

BSR is output instruction that load data into a bit array one bit at a time. The data is shifted right through the array, then unloaded one bit at a time.

Symbol

When the rung goes from false-to-true, the enable bit (EN bit 15) is set and the data block is shifted to the right (to a lower bit number) one bit position. The specified bit at the bit address is shifted into the last bit position. The first bit is shifted out of the array and stored in the unload bit (UL bit 10) in the status byte of the control element. The shift is completed immediately.

Entering Parameters:As discussed above, same entering parameters are used in this instruction.

Usage:In our program, once a value is loaded in the bit file by using the MOV

instruction, now we are rotating bits contained in bit file with 16 as a size of array right side. When the rung goes from false-to-true, this process will be done. As the bits are rotating right, motor gets reverse sequence and it will rotate in reverse direction.

22

Page 23: Programmable Logic Controller

Now, we will explain how stepper motors work by using PLC program. So please refer figure (J) and read following portion carefully.

First, we should clear that we are using 5-wired Unipolar wound stepper motor And we are using Full Step Drive (2 phases on).

Fig (K): Unipolar wound stepper motor construction Fig (L): Excitation Sequence (full step)

In Full Step Drive we are energizing two phases at any given time. The stator is energized according to the sequence A B A B A B A B and the rotor steps from position 1 3 5 7 as show in fig (K). Full step mode results in the same angular movement as 1 phase on drive but the mechanical position is offset by one half of a full step.

5.9.4.2 Explaining of Control of X-Motor:

At the Starting of the program, we are loading the bit stream ‘0011001100110011’ in binary form in the bit file B3:0, because of using the full step drive due to high loads applied on motor so that we are giving pulses on two coils simultaneously. This process is done by MOV instruction as shown in Rung 0000 in fig (J). As the initial loading of bits, bits 0, 1, 4, 5, 8, 9, 12 and 13 set to ‘1’ so that motor will get first step due to bits 0 & 1 as shown in rungs 0003 & 0004.

As shown in Rung 0001, when input I:0/8 (X-Forward) is energized by giving signal from parallel port, the output BSL instruction will energized and bits will rotate in bit file B3:0 with 16 as a size of array Left side. As the rotating will be done, bits in the bit file change to ‘0110011001100110’. Here, bits 1 & 2 set to ‘1’ which will give another step to

23

Page 24: Programmable Logic Controller

the motor as shown in rungs 0004 & 0005. If an another signal is given to the input I:0/8, again bits will rotate in bit file B3:0 with 16 as a size of array left side and change to ‘1100110011001100’. Now, bits 2 & 3 go to state ‘1’ which will give next step to the motor as shown in rungs 0005 & 0006 and so on. This process is called ‘Forward Motion of Motor’.

Now, going to Rung 0002, when input I:0/9 (X-Reverse) is energized by giving signal from parallel port, the output BSR instruction will energized and bits will rotate in bit file B3:0 with 16 as a size of array Right side. As the rotating will be done, bits in the bit file change to ‘1001100110011001’. Here, bits 0 & 4 will set which will give step to the motor which rotates in reverse direction as shown in rungs 0003 & 0006. If an another signal is given to the input I:0/9, again bits will rotate in bit file B3:0 with 16 as a size of array right and change to ‘1100110011001100’. Now, bits 2 & 3 set to ‘1’ which will give next step to the motor I reverse direction as shown in rungs 0005 & 0006 and so on. This process is called ‘Forward Motion of Motor’.

The normally close (XIO) input instruction I:0/17 is used with label ‘X-Limit’ in the rung 0003. When we are applying input I:0/9 no of times, motor will rotate in X-reverse direction over the given limit. The purpose of using this NC input is to stop the motor or pulses given to it over the predefined limit. When the limit switch is pressed the rung 0003 will become false and we will not get any output to motor.

Thus, X-Motion is controlled by above described procedures and similarly we are controlling remaining motors (Y and Z-Motion) by using parallel port and PLC Ladder Logic.

5.9.4.3 Explaining of Control of Electromechanical Gripper:

For controlling Electromechanical Gripper which is attached to bottom of Z-axis slide, we are using somewhat similar logic to that of X-, Y- and Z-motion control. In this, at an initial loading time, we are loading the bit stream ‘1010101010101010’ in binary form in the bit file B3:6 by using the MOV instruction. From rung 0023, we can say that bit 0 of the bit file decides the gripper output. At this initial level, bit 0 is already reset bit and hence, the gripper does not excite.

When all the three motions (X, Y, and Z) are being done by the manipulator, at that time the gripper stands exactly above the object and now we want to pick an object by using electromechanical gripper. As shown in rung 0022, when input I:0/0 (gripper excitation) is energized by giving signal from parallel port, the output BSL instruction will energized and bits will rotate in bit file B3:6 with 16 as a size of array Left side. As the rotating will be done, bits in the bit file change to ‘0101010101010101’ and here bit 0 will set. As the bit B3:6/0 is energized, the gripper excites and picks the object nearest to it.

24

Page 25: Programmable Logic Controller

REFERENCES:-

Books:-

1) Introduction to Programmable Logic Controller By Gary Dunning2) Allen Bradley SLC 500 Instruction set (E-Book in PDF format) 3) MicroLogix Programmable Controller Selection Guide (E-Book in PDF format)

Websites:-

1) www.rockwellautomation.com 2) www.plcs.net 3) www.wikipedia.com 4) www.howstuffworks.com 5) www.google.co.in

25

Page 26: Programmable Logic Controller

Parallel Port Control by MATLAB

The Parallel Port:-

The PC supports up to three parallel ports that are assigned the labels LPT1, LPT2, and LPT3. We can use any of these standard ports as long as they use the usual base addresses, which are (in hex) 378, 278, and 3BC, respectively. The port labels and addresses are typically configured through the PC's BIOS. Additional ports, or standard ports not assigned the usual base addresses, are not accessible by the toolbox.

Most PCs that support MATLAB will include a single parallel port with label LPT1 and base address 378. To create a DIO object for this port,

parport = digitalio('parallel','LPT1');

A. Parallel Port Properties:-

The device-specific parallel port properties are given below.

Table (A): Parallel Port PropertiesProperty Name Description Device

ObjectsBidirectional Bit

Specify the BIOS control register bit that determines bidirectional operation.

DIO

Port Address Indicate the base address of the parallel port. DIO

B. Digital Input/output:-

Digital I/O (DIO) subsystems are designed to transfer digital values to and from hardware. These values are handled either as single bits or lines, or as a port, which typically consists of eight lines. While most popular data acquisition boards include some DIO capability, it is usually limited to simple operations and special dedicated hardware is required for performing advanced DIO operations. The Data Acquisition Toolbox provides access to digital I/O subsystems through a digital I/O object. The DIO object can be associated with a parallel port or with a DIO subsystem on a data acquisition board. The purpose of this chapter is to show you how to perform data acquisition tasks using your digital I/O hardware. The sections are as follows.

26

Page 27: Programmable Logic Controller

Creating a Digital I/O Object Create a MATLAB object that represents the digital I/O subsystem

Adding Lines to a Digital I/O Object Associate hardware lines with the digital I/O object

Writing and Reading Digital I/O Line Values Write values to digital lines, and read values from digital lines

i. Creating a Digital I/O Object:-

We create a digital I/O (DIO) object with the digitalio function. digitalio accepts the adaptor name and the hardware device ID as input arguments. For parallel ports, the device ID is the port label (LPT1, LPT2, or LPT3). For data acquisition boards, the device ID refers to the number associated with the board when it is installed. Note that some vendors refer to the device ID as the device number or the board number. Use the daqhwinfo function to determine the available adaptors and device IDs. Each DIO object is associated with one parallel port or one subsystem. For example, to create a DIO object associated with a National Instruments board:

dio = digitalio('nidaq',1);

The digital I/O object dio now exists in the MATLAB workspace. You can display the class of dio with the whos command.

whos dio Name Size Bytes Class

dio 1x1 1308 digitalio object

Grand total is 40 elements using 1308 bytes

Once the object is created, the properties listed below are automatically assigned values. These general purpose properties provide descriptive information about the object based on its class type and adaptor.

Table (B): Descriptive Digital I/O Properties

Property Name DescriptionName Specify a descriptive name for the device object.Type Indicate the device object type.

You can display the values of these properties for dio with the get function.

get(dio,{'Name','Type'})ans = 'nidaq1-DIO' 'Digital IO'

27

Page 28: Programmable Logic Controller

ii. Adding Lines to a Digital I/O Object:-

After creating the digital I/O (DIO) object, we must add lines to it. As shown by the figure, we can think of a device object as a container for lines. The collection of lines contained by the DIO object is referred to as a line group. A line group consists of a mapping between hardware line IDs and MATLAB indices (see below).

When adding lines to a DIO object, we must follow these rules: The lines must reside on the same hardware device. We cannot add lines from

different devices, or from different subsystems on the same device. We can add a line only once to a given digital I/O objects. However, a line can

be added to as many different digital I/O objects as we desire. We can add lines that reside on different ports to a given digital I/O object.

We add lines to a digital I/O object with the addline function. addline requires the device object, at least one hardware line ID, and the direction (input or output) of each added line as input arguments. We can optionally specify port IDs, descriptive line names, and an output argument. For example, to add eight output lines from port 0 to the device object dio created in the preceding section:

hwlines = addline(dio,0:7,'out');

The output argument hwlines is a line object that reflects the line group contained by dio. We can display the class of hwlines with the whos command.

whos hwlines Name Size Bytes Class

hwlines 8x1 536 dioline object

Grand total is 13 elements using 536 bytes

We can use hwlines to easily access lines. For example, we can configure or return property values for one or more lines.

Once we add lines to a DIO object, the properties listed below are automatically assigned values. These properties provide descriptive information about the lines based on their class type and ID.

28

Page 29: Programmable Logic Controller

Table (C): Descriptive Digital I/O Line Properties

Property Name DescriptionHwLine Specify the hardware line ID.Index Indicate the MATLAB index of a hardware line.Parent Indicate the parent (device object) of a line.Type Indicate a line.

Line and Port Characteristics:-

As described in the preceding section, when we add lines to a DIO object, they must be configured for either input or output. We read values from an input line and write values to an output line. Whether a given hardware line is addressable for input or output depends on the port it resides on. We can classify digital I/O ports into these two groups based on your ability to address lines individually:

Port-configurable devices – We cannot address the lines associated with a port-configurable device individually. Therefore, we must configure all the lines for either input or output. If we attempt to mix the two configurations, an error is returned. We can add any number of available port-configurable lines to a DIO object. However, the engine will address all lines behind the scenes. For example, if one line is added to a DIO object, then we automatically get all lines. Therefore, if a DIO object contains lines from a port-configurable device, and we write a value to one or more of those lines, then all the lines are written to even if they are not contained by the device object.

Line-configurable devices – We can address the lines associated with a line-configurable device individually. Therefore, we can configure individual lines for either input or output. Additionally, we can read and write values on a line-by-line basis. Note that for National Instruments E Series hardware, port 0 is always line-configurable, while all other ports are port-configurable.

We can return the line and port characteristics with the daqhwinfo function. For

example, National Instruments AT-MIO-16DE-10 board has four ports with eight lines per port. To return the digital I/O characteristics for this board:

hwinfo = daqhwinfo(dio);

Display the line characteristics for each port.

hwinfo.Port(1)ans = ID: 0 LineIDs: [0 1 2 3 4 5 6 7] Direction: 'in/out' Config: 'line'

29

Page 30: Programmable Logic Controller

hwinfo.Port(2)ans = ID: 2 LineIDs: [0 1 2 3 4 5 6 7] Direction: 'in/out' Config: 'port'hwinfo.Port(3)ans = ID: 3 LineIDs: [0 1 2 3 4 5 6 7] Direction: 'in/out' Config: 'port'hwinfo.Port(4)ans = ID: 4 LineIDs: [0 1 2 3 4 5 6 7] Direction: 'in/out' Config: 'port'

This information tells we that we can configure all 32 lines for either input or output, and that the first port is line-configurable while the remaining ports are port-configurable.

Parallel Port Characteristics:-

The parallel port consists of eight data lines, four control lines, five status lines, and eight ground lines. In normal usage, the lines are controlled by the host computer software and the peripheral device following a protocol such as IEEE Standard 1284-1994. The protocol defines procedures for transferring data such as handshaking, returning status information, and so on. However, the toolbox uses the parallel port as a basic digital I/O device, and no protocol is needed. Therefore, we can use the port to input and output digital values just as we would with a typical DIO subsystem. To access the physical parallel port lines, most PCs come equipped with one 25-pin female connector, which is shown below. The lines use TTL logic levels. A line is high (true or asserted) when it is a TTL high level, while a line is low (false or unasserted) when it is a TTL low level. The exceptions are lines 1, 11, 14, and 17, which are hardware inverted. The toolbox groups the 17 nonground lines into three separate ports. The port IDs and the associated pin numbers are given below.

Table (D): Parallel Port IDs and Pin Numbers

Port ID Pins Description

0 2-9 Eight I/O lines, with pin 9 being the most significant bit (MSB).

1 10-13, and 15 Five input lines used for status

2 1, 14, 16, and 17 Four I/O lines used for control

30

Page 31: Programmable Logic Controller

Note that in some cases, port 0 lines might be unidirectional and only output data. If supported by the hardware, we can configure these lines for both input and output with your PC's BIOS by selecting a bidirectional mode such as EPP (Enhanced Parallel Port) or ECP (Extended Capabilities Port).

Referencing Individual Hardware Lines:-

As described in the preceding section, we can access lines with the Line property or with a line object. To reference individual lines, we must specify either MATLAB indices or descriptive line names.

MATLAB Indices:

Every hardware line contained by a DIO object has an associated MATLAB index that is used to reference the line. When adding lines with the addline function, index assignments are made automatically. The line indices start at 1 and increase monotonically up to the number of line group members. The first line indexed in the line group represents the least significant bit (LSB), and the highest indexed line represents the most significant bit (MSB). Unlike adding channels with the addchannel function, we cannot manually assign line indices with addline.

For example, the digital I/O object dio created in the preceding section has the MATLAB indices 1 through 8 automatically assigned to the hardware lines 0 through 7, respectively. To swap the first two hardware lines so that line ID 1 is the LSB, we can supply the appropriate index to hwlines and use the HwLine property.

hwlines(1).HwLine = 1;hwlines(2).HwLine = 0;

Alternatively, we can use the Line property.

dio.Line(1).HwLine = 1;dio.Line(2).HwLine = 0;

Descriptive Line Names:

Choosing a unique, descriptive name can be a useful way to identify and reference lines -- particularly for large line groups. We can associate descriptive names with hardware lines with the addline function. For example, suppose we want to add 8 lines to dio, and we want to associate the name TrigLine with the first line added.

addline(dio,0,'out','TrigLine');addline(dio,1:7,'out');

Alternatively, we can use the LineName property.

addline(dio,0:7,'out');dio.Line(1).LineName = 'TrigLine';

31

Page 32: Programmable Logic Controller

we can now use the line name to reference the line.

dio.TrigLine.Direction = 'in';

Example: Adding Lines for National Instruments Hardware:

This example illustrates various ways we can add lines to a DIO object associated with a National Instruments AT-MIO-16DE-10 board. This board is a multiport device whose characteristics are described in Line and Port Characteristics.

To add eight input lines to dio from port 0:

addline(dio,0:7,'in');

To add four input lines and four output lines to dio from port 0:

addline(dio,0:7,{'in','in','in','in','out','out','out','out'});

Suppose we want to add the first two lines from port 0 configured for input, and the first two lines from port 2 configured for output. There are four ways to do this.

i. The first way requires only one call to addline because it uses the hardware line IDs, and not the port IDs.

addline(dio,[0 1 8 9],{'in','in','out','out'});

ii. The second way requires two calls to addline, and specifies one line ID and multiple port IDs for each call.

addline(dio,0,[0 2],{'in','out'});addline(dio,1,[0 2],{'in','out'});

iii. The third way requires two calls to addline, and specifies multiple line IDs and one port ID for each call.

addline(dio,0:1,0,'in');addline(dio,0:1,2,'out');

iv. We can use four addline calls -- one for each line added

32

Page 33: Programmable Logic Controller

iii. Writing and Reading Digital I/O Line Values:-

After we add lines to a digital I/O (DIO) object, you can: Write values to lines Read values from lines

1) Writing Digital Values:-

We write values to digital lines with the putvalue function. putvalue requires the DIO object and the values to be written as input arguments. We can specify the values to be written as a decimal value or as a binary vector (binvec). A binary vector is a logical array that is constructed with the least significant bit (LSB) in the first column and the most significant bit (MSB) in the last column. For example, the decimal value 23 is written in binvec notation as [1 1 1 0 1] = 20 + 21 + 22 + 24. We might find that binvecs are easier to work with than decimal values because there is a clear association between a given line and the value (1 or 0) that is written to it. We can convert decimal values to binvec values with the dec2binvec function. For example, suppose we create the digital I/O object dio and add eight output lines to it from port 0.

dio = digitalio('nidaq',1);addline(dio,0:7,'out');

To write a value of 23 to the eight lines contained by dio, we can write to the device object.

data = 23;putvalue(dio,data)

Alternatively, we can write to individual lines through the Line property.

putvalue(dio.Line(1:8),data)

To write a binary vector of values using the device object and the Line property:

bvdata = dec2binvec(data,8);putvalue(dio,bvdata)

33

Page 34: Programmable Logic Controller

putvalue(dio.Line(1:8),bvdata)

Alternatively, we can create the binary vector without using dec2binvec.

bvdata = logical([1 1 1 0 1 0 0 0]);putvalue(dio,bvdata)

Rules for Writing Digital Values:

Writing values to digital I/O lines follows these rules: If the DIO object contains lines from a port-configurable device, then the data

acquisition engine writes to all lines associated with the port even if they are not contained by the device object.

When writing decimal values, If the value is too large to be represented by the lines contained by the

device object, then an error is returned. We can write to a maximum of 32 lines. To write to more than 32 lines, we

must use a binvec value. When writing binvec values,

We can write to any number of lines. There must be an element in the binary vector for each line we write to.

We can always read from a line configured for output. Reading values is discussed in Reading Digital Values.

An error is returned if you write a negative value, or if we write to a line configured for input.

2) Reading Digital Values:-

We can read values from one or more lines with the getvalue function. getvalue requires the DIO object as an input argument. We can optionally specify an output argument, which represents the returned values as a binary vector. Binary vectors are described in Writing Digital Values. For example, suppose we create the digital I/O object dio and add eight input lines to it from port 0.

dio = digitalio('nidaq',1);addline(dio,0:7,'in');

To read the current value of all the lines contained by dio:

portval = getvalue(dio)portval =

34

Page 35: Programmable Logic Controller

1 1 1 0 1 0 0 0To read the current values of the first five lines contained by dio:

lineval = getvalue(dio.Line(1:5))lineval = 1 1 1 0 1

We can convert a binvec to a decimal value with the binvec2dec function. For example, to convert the binary vector lineval to a decimal value:

out = binvec2dec(lineval)out = 23

Rules for Reading Digital Values:

Reading values from digital I/O lines follows these rules:

If the DIO object contains lines from a port-configurable device, then all lines are read even if they are not contained by the device object. However, only values from the lines contained by the object are returned.

We can always read from a line configured for output. For National Instruments hardware, lines configured for input return a value

of 1 by default. getvalue always returns a binary vector (binvec). To convert the binvec to a

decimal value, use the binvec2dec function.

35