POGRAMMABLE LOGIC CONTROLLERS AND MICROCONTROLLERS LIST OF CONTENTS Unit1 Introduction to PLC, Concept of PLC - Building blocks of PLC - Functions of various blocks, limitations of relays - Advantages of PLCs over electromagnetic relays - Different programming languages - PLC manufacturer etc. Unit 2 Working of PLC, Basic operation and principles of PLC, Architectural details processor Memory structures - I/O structure Programming terminal - Power supply Unit 3 Instruction Set - Basic instructions bit.-Timer instruction like retentive timers, resetting of timers Counter instructions like up counter, down counter, resetting of counters.- Arithmetic Instructions (ADD,SUB,DIV,MUL etc.)- MOV instruction - Comparison instructions like equal, not equal, greater, greater than equal, less than, less than equal 1|P a g e UNIT I 1.1 Introduction to PLC The hydramatic Division of the General Motors Corporation specified the design criteria for the first programmable controller come in 1968. Programmable logic controllers, also called programmable controllers or PLCs, are solid-state members of the computer family, using integrated circuits instead of electromechanical devices to implement control functions. They are capable of storing instructions, such as sequencing, timing, counting, arithmetic, data manipulation, and communication, to control industrial machines and processes Purposes - Initially designed to replace relay logic boards, Sequence device actuation, Coordinate activities accepts input from a series of switches, Sends output to devices or relays What is PLC? Programmable Logic Controller (PLC) is a digital computer used for the automation of various electro-mechanical processes in industries. These controllers are specially designed to survive in harsh situations and shielded from heat, cold, dust, and moisture etc. PLC consists of a microprocessor which is programmed using the computer language. The program is written on a computer and is downloaded to the PLC via cable. These loaded programs are stored in non – volatile memory of the PLC. During the transition of relay control panels to PLC, the hard wired relay logic was exchanged for the program fed by the user. A visual programming language known as the Ladder Logic was created to program the PLC. 1.2 Advantages of PLCs over electromagnetic relays • Ability to interface / communicate with computers but not with reley • Simple programming is possible using ladder logic but not with relay • Plc have High reliability • High controllability due to the use of timers and counters. • Easy maintenance • Rugged construction - can operate in extremely harsh conditions • Small size • Easy expandability • Economical in long term 1.3 Limitation of Relay• • • • It suffer from contact wear and reliability problems Unsuitable for designing complex control circuit Relay occupies large space Relay takes large time to actuate 2|P a g e 1.4 Building blocks of PLC 1.5 Functions of various blocks PLCs have input/output devices like switches, push buttons, limit switches,sensors,lamp indicators,relays solenoids motors etc. block diagram of a PLC shown in above Fig. It has three major units/sections. • I/O (Input/Output) Modules. • CPU (Central Processing Units). • Programmer/Monitor. The input section converts the field signals supplied by input devices/sensors to logic-level signals that the PLC's CPU can read. The Processor Section reads these inputs, Processes the signal, and prepares the output signals. The output section converts the logic level output signals coming from processor section to high level signals and used to actuate various output field devices. The programmer/monitor is used to enter the user's program into memory and to monitor the execution of the program. I/O Section:The I/O section establishes the interfacing between physical devices in the real world outside the PLC and the digital arena inside the PLC. The input module has bank of terminals for physically connecting input devices, like push buttons, limit switches etc. to a PLC. The role of an input module is to translate signals from input devices into a form that the PLC's CPU can understand. The Output module also has bank of terminals that physically connect output devices like solenoids, motor starters, indicating lamps etc. to a PLC. The role of an output module is to translate signals from the PLC's CPU into a form that the output device can use. The tasks of the I/O section can be classified as: • Conditioning 3|P a g e • Isolation • Termination • Indication An electronic system for connecting I/O modules to remotely located I/O devices can be added if needed. The actual operating process under PLC Control can be thousands of feet from the CPU and its I/O modules. CPU Section:The Central Processing Unit, the brain of the system is the control portion of the PLC. It has three Subparts. • Memory System • Processor • Power Supply Memory System:The memory is the area of the CPU in which data and information is stored and retrieved. The total memory area can be subdivided into the following four Sections. I/O Image Memory The input image memory consists of memory locations used to hold the ON or OFF states of each input field devices, in the input status file. The output status file consists of memory locations that stores the ON or OFF states of hardware output devices in the field. Data is stored in the output status file as a result of solving user program and is waiting to be transferred to the output module's switching device. Data Memory - It is used to store numerical data required in math calculation, bar code data etc. User Memory - It contains user's application program. Executive Memory - It is used to store an executive program or system software. An operating system of the PLC is a special program that controls the action of CPU and consequently the execution of the user's program. A PLC operating system s designed to scan image memory, interprets the instruction of user's program stored in main memory, and executes the user's application program the operating system is supplied by the PLC manufacturer and is permanently held in memory. Processor:-The processor, the heart of CPU is the computerized part of the CPU in the form of Microprocessor / Micro controller chip. It supervises all operation in the system and performs all tasks necessary to fulfill the PLC function. • It reads the information i.e. status of externally connected input devices with input module. It stores this information in memory for later use. It carries out mathematical and logic operations as specified in application program. After solving the user's program, it writes the result values in the memory. It sends data out to external devices like output module, so as to actuate field hardware. It performs peripheral and external device communication. 4|P a g e Power Supply The power supply provides power to memory system, processor and I/O Modules. It converts the higher level AC line Voltage to various operational DC values. For electronic circuitry. It filters and regulates the DC voltages to ensure proper computer operations. Programmer/Monitor The Programmer/Monitor (PM) is a device used to communicate with the circuits of the PLC. The programming unit allows the engineer/technicians to enter the edit the program to be executed. In its simplest form it can be hand-held device with membrane keypad for program entry and a display device (LED or LCD) for viewing program steps of functions. More advanced systems employ a separate industrial terminal or personal computers with type-writer type keyboard and CRT monitors. With the help of proprietary software, it allows programmer to write, view and edit the program and download it into the PLC. It also allows user to monitor the PLC as it is running the program. With this monitoring systems, such things as internal coils, registers, timers and other items not visible externally can be monitored to determine proper operation. Also, internal register data can be altered, if required. to fine tune program operation while debugging. Communication between PM and PLC is done via a cable connected to a special programming port on PLC. Connection to the personal computer can be through a serial port or from a dedicated card installed in the computer. 1.6 PLC Programming language - Using flowcharts, Using ladder logic and Using statement logics or mnemonics 1.7 PLC manufacturer - Allen Bradley, Rockwell Automation, Mitsubishi, Omron, Siemens etc. Programmable Logic Controllers Multiple Choice Questions Q1. The acronym PLC stands for: (A) Pressure Load Control (B) Programmable Logic Controller (C) Pneumatic Logic Capstan (D) PID Loop Controller (E) Pressure Loss Chamber Q2. The PLC was invented by A) Bill Gates B) Dick Morley C) Bill Landis D) Tod Cunningham Q3. Ladder logic programming consists primarily of: (A) Virtual relay contacts and coils (B) Logic gate symbols with connecting lines (C) Function blocks with connecting lines (D) Text-based code (E) Hieroglyphics 5|P a g e Q4. In a PLC, the scan time refers to the amount of time in which ….. (A) the technician enters the program (B) timers and counters are indexed by (C) one “rung” of ladder logic takes to complete (D) the entire program takes to execute (E) transmitted data communications must finish Q5. Which one of the following is not a PLC manufacturer a. Siemens b. Mitsubishi c. Microsoft d. ABB Short/long answer types questions Q1 Define PLC Q2 What are the limitations of relay over PLC Q3 Explain building blocks of PLC in detail Q4 List the names of PLC manufacturer. UNIT 2 6|P a g e 2. Working of PLC (Programmable Logic Controller) The Programmable logic controller functions in four steps. Input scan: The state of the input is scanned which is connected externally. The inputs include switches, pushbuttons, and proximity sensors, limit switches, pressure switches. Ideally, they are transformers and not relays. Program scan: The loaded program is executed to carry out the function appropriately. Output scan: The input sources have a control over the output ports to energize or de-energize them. The outputs include solenoids, valves, motors, actuator, and pumps. Depending on the model of PLC, these relays can be transistors. 2.1 PLC ARCHITECTURE • The input sources convert the real time analog electric signals to suitable digital electric signals and these signals are applied to the PLC through the connector rails. • These input signals are stored in the PLC external image memory in locations known as bits. This is done by the CPU • The control logic or the program instructions are written onto the programming device through symbols or through mnemonics and stored in the user memory. • The CPU fetches these instructions from the user memory and executes the input signals by manipulating, computing, processing them to control the output devices. • The execution results are then stored in the external image memory which controls the output drives. • The CPU also keeps a check on the output signals and keeps updating the contents of the input image memory according to the changes in the output memory. • The CPU also performs internal programming functioning like setting and resetting of the timer, checking the user memory. 7|P a g e Program Loader PC Switches Printer Processor I/O Modules Memory Power Supply Machines Cassette Loader EPROM Loader Peripherals External Devices 2.2 PLC Hardware • The hardware components of a PLC system are CPU, Memory, Input/Output, Power supply unit, • and programming device. Below is a diagram of the system overview of PLC. CPU – Keeps checking the PLC controller to avoid errors. They perform functions including logic operations, arithmetic operations, computer interface and many more. • Memory – Fixed data is used by the CPU. System (ROM) stores the data permanently for the operating system. RAM stores the information of the status of input and output devices, and the values of timers, counters and other internal devices. • I/O section – Input keeps a track on field devices which includes sensors, switches. • O/P Section - Output has a control over the other devices which includes motors, pumps, lights and solenoids. The I/O ports are based on Reduced Instruction Set Computer (RISC). • Power supply – Certain PLCs have an isolated power supply. But, most of the PLCs work at • 220VAC or 24VDC. Programming device – This device is used to feed the program into the memory of the processor. The program is first fed to the programming device and later it is transmitted to the PLC’s memory. System Buses – Buses are the paths through which the digital signal flows internally of the PLC. The four system buses are: • Data bus is used by the CPU to transfer data among different elements. • • Control bus transfers signals related to the action that are controlled internally. Address bus sends the location’s addresses to access the data. • System bus helps the I/O port and I/O unit to communicate with each other 8|P a g e 2.3 The memory space can be divided into two broad categories: Program and Data Memory: Advanced ladder logic functions allow controllers to perform calculations, make decisions and do other complex tasks. Timers and counters are examples of ladder logic functions. They are more complex than basic inputs contacts and output coils and relay heavily upon data stored in the memory of the PLC. The user program will account for most of the memory of a PLC system. Program files contain the logic controlling machine operation. This logic consists of instructions that are programmed in a ladder logic format. The data file portion of memory stores input and output status, processor status, the status of various bits and numerical data. 9|P a g e Multiple Choice Questions Q.1 one of the following is an input device a. Motor b. Light c. Valve d. Sensor Q.2 Solenoids, lamps, motors are connected to: a. Analog output b. Digital output c. Analog input d. Digital input Q.3 The type of memory which is fast and temporarily stores the data which are immediately required for use is called as______. a. HDD b. ROM c. RAM d. SSD Q.4 how is the speed of operation of conventional relay system as compared to digital controllers? a. very slow b. very fast c. same d. almost similar Q.5 The PLC is used in _______. a. machine tools b. automated assembly equipment c. moulding and extrusion machines d. all of the above 10 | P a g e UNIT 3 INSTRUCTION SETS 3. PLC Instructions 3.1 Bit instructions 3.2 Timer and Counter instructions 3.3 Program Control Instructions 3.4 Compare Instructions 3.5 Math Instructions 3.1 Bit Instructions Mnemonic Name Symbol Description XIC Examine If Closed Examines a bit for an On (set, high) condition. XIO Examine If Open Examines a bit for an Off (cleared, low) condition. OTE Output Energize When rung conditions are true, the OTE will either set or clear the data bit. OTL Output Latch When enabled, the instruction signals to the controller to turn on the addressed bit. The bit remains on, regardless of the rung condition. OTU Output Unlatch When enabled, it clears (unlatches) the data bit. The bit remains Off, regardless of rung condition. 3.2 Timer and Counter Instructions Mnemonic Name TON Timer On Delay 11 | P a g e Symbol Description A non-retentive timer that accumulates time when the instruction is enabled. The accumulated value is reset when rung conditions go false. TOF Timer Off Delay A non-retentive timer that accumulates time when the rung makes a true-tofalse transition. RTO Retentive Timer On A retentive timer that accumulates time when the instruction is enabled. Retains its accumulated value when rung conditions become false. TON Count Up An instruction that counts false-to-true rung transitions. It counts upward and the accumulated value is incremented by one count on each of these transitions. TOF Count Down This instruction counts downward on each false-to-true rung transition. The accumulated value is decremented by one count on each of these transitions. RTO Retentive Timer On A retentive timer that accumulates time when the instruction is enabled. Retains its accumulated value when rung conditions become false. CTU Count Up An instruction that counts false-to-true rung transitions. It counts upward and the accumulated value is incremented by one count on each of these transitions. CTD Count Down This instruction counts downward on each false-to-true rung transition. The accumulated value is decremented by one count on each of these transitions. RES Reset 12 | P a g e This instruction is used to reset a timer, counter or control structure. The accumulated value of these instructions are cleared when the RES instruction is enabled. 3.3 Move/Logical Instructions Mnemonic Name MOV Move MVM Masked Move CLR Clear DTR Data Transitional Passes the Source value through a Mask and compares the result with the Reference value. SWPB Swap Byte Instruction Rearranges the bytes of a tag and stores the bytes in the new order. SWP Swap Byte Instruction Swaps the lower and higher bytes of a specified number of words. BTD Bit Field Distribute Copies the specified bits from the Source, shifts the bits to the appropriate position, and writes the bits into the Destination. 13 | P a g e Symbol Description Copies the Source (which remains unchanged) to the Destination. Copies the Source to a Destination and allows segments of the data to be masked. Clears all the bits of the Destination. AND Bitwise AND Performs a logical AND operation by using the bits in Source A and Source B and placing the result in the Destination. OR Bitwise OR Performs a logical AND operation by using the bits in Source A and Source B and placing the result in the Destination. XOR Bitwise Exclusive OR Performs a bitwise XOR operation using the bits in Source A and Source B and stores the result in the Destination. NOT Bitwise NOT Executes a bitwise NOT operation by using the bits in the Source and placing the result in the Destination 3.4 Program Control Instructions Mnemonic Name JSR Jump to Subroutine This instruction jumps execution to a specific routine and initiates the execution of this routine, called a subroutine. SBR Subroutine Stores recurring sections of program logic. RET Return Used to return to the instruction following the a JSR operation. JMP Jump to Label LBL Label 14 | P a g e Symbol Description Skips sections of ladder logic. Target of the JMP instruction with the same label name. MCR Master Cont. Res. Used in pairs to create a program zone that can disable all rungs between the MCR instructions. AFI Always False Disables all instructions on a rung. NOP No Operation This instruction functions as a placeholder. TND Temporary End When enabled, it lets the controller execute logic only up to this instruction. IOT Immediate Output This instruction immediately updates the specified output data. 3.5 Compare Instructions Mnemonic Name EQU Equal GEQ Greater Than or Equal To Determines whether Source A is greater than or equal to Source B. If the value at Source A is greater than or equal to the value at Source B, then the instruction is true. GRT Greater Than This instruction is used to test whether one value (Source A) is greater than another value (Source B). LEQ Less Than or Equal To Determines whether one value (Source A) is less than or equal to another (Source B). 15 | P a g e Symbol Description This instruction is used to test whether two values are equal. If Source A is equal to Source B, the instruction is logically true. LES Less Than This instruction determines whether Source A is less than Source B. LIM Limit This instruction is used to test for values within the range of the Low Limit to the High Limit. MEQ Mask Equal To NEQ Not Equal To Passes the Source and Compare values through a Mask and compares the results. This instruction tests whether Source A is not equal to Source B. 3.6 Math Instructions Mnemonic Name ADD Add SUB Subtract Subtracts Source B from Source A and places the result in the Destination. MUL Multiply Multiplies Source A by Source B and stores the result in the destination. 16 | P a g e Symbol Description Adds Source A to Source B and stores the result in the Destination. DIV Divide Divides Source A by Source B and places the result in the Destination. MOD Modulo Divides Source A by Source B and stores the remainder in the Destination. SQR Square Root NEG Negate ABS Absolute Calculates the square root of the source and places the integer result in the Destination. Changes the sign (+, -) of the Source and stores the result in the Destination. Takes the absolute value of the Source and places the result in the Destination. Multiple Choice Questions Question 1: Examine-on instruction in PLC language is symbolically represented by what shape? A. -] [B. -( )C. -]/[D. None of these Question 2: The symbol -(L)- represent what instruction in the PLC language? A. OUT output unlatch instruction. B. OTL output latch instruction. C. Examine off instruction. D. Output energizes instruction. Question 3: The address T4:6.ACC is used to address what? A. Accumulator for timer 4 in file 6. 17 | P a g e B. Preset value of timer 6 in file 4. C. Accumulator for timer 6 in file 4. D. Accumulator for counter 6 in file 4. Q4: To reset the time for a PLC what condition must be true? A. Reset rung of TON must be true. B. Reset rung of TON must be false. C. RST instruction with timer address must be true. D. RST instruction with associated timer address must be false. Question 5: To increase the number of inputs and outputs of the PLC, one can use expansion modules. A. True. B. False. C. None of the above. Question 6: Solenoids, lamps, motors are connected to: A. Analog output. B. Digital output. C. Analog input. D. Digital input Question 7: In a counter instruction if the accumulator value becomes greater than or equal to the preset value then which of the following is true? A. CU bit goes on. B. DN bit goes on. C. Both CU and DN bits go on. D. None of the above. Short / long Answer type Questions Q1 Explain time instructions in detail Q2 Explain Counter instructions in detail 18 | P a g e