Presentation on theme: "Chapter 5 PLC Programming Instructions"— Presentation transcript:
1Chapter 5 PLC Programming Instructions PLC Programming Diagrams • Processor Files • Program Files • Data Table Files • Data Table File Addresses • Input and Output File Addresses • Status File Addresses • Bit File Addresses • Programming Diagram Logic • Programming Diagram Rules • Bit Instructions • Scan Execution
2A hardwired motor control application is depicted by symbols in a ladder diagram. In a hardwired (non-PLC) application, the contacts of pushbuttons, selector switches, limit switches, timers, and counters, and the coils of relays, pilot lights, solenoids, and motor starters are connected together with wire. Hardwired devices and components are typically depicted using ladder diagrams. A ladder diagram is a type of drawing that contains the logic for an application and is typically used to test and troubleshoot hardwired applications. See Figure 5-1.
3A PLC motor control application is depicted by instructions in a programming diagram. A PLC programming diagram contains the logic for the PLC application and is used to test and troubleshoot PLC applications. PLC programming and instructions take the place of control wiring and control devices such as relays, timers, and counters. See Figure 5-2.
4The memory of a PLC contains the processor file, which contains the program files and data table files.Processor files are downloaded (copied) from programming devices to PLCs. Typically, processor files are thought of as file cabinets, and the program files and data table files as drawers within the cabinet. The various program files and data table files are folders within the drawers. See Figure 5-3.
5There are 256 possible program files, with the function of program files 0, 1, and 2 defaulted by the PLC.A program file is data in the memory of a PLC that contains technician-developed PLC programs and related information. Two hundred fifty-six program files are possible in many PLCs, and the files are numbered 0 through 255. See Figure 5-4. Three of the program files are always used: the system file (file 0), the reserved file (file 1), and the main program file (file 2). Files 3 through 255 are subroutine files and may or may not be used depending upon the application.
6The status of the CPU, all input devices and output components, and all instructions used in the program are found in the 256 data table files.A data table file is the section of memory in the PLC that contains the status of all input devices and output components, the CPU, and all instructions used in a program. There are 256 data table files, numbered 0 through 255. See Figure 5-5. The data table files are arranged by the type of data they contain. Nine of the data table files, numbered 0 through 8, are default files. Data table files 0 through 8 are preconfigured and the file type cannot be changed. Data table files 9 through 255 are configured by the technician.
7The instructions within each data table file each have a unique address based on the file identifier and file number.Each type of data table file has a unique file identifier letter and file number. Each type of file has a variety of instructions associated with the file. The instructions within the file each have a unique address based on the file identifier and file number. See Figure 5-6. Different instructions use different amounts of memory. Instructions can use a bit, word, or a group of words. The address of an instruction includes the file identifier, file number, and memory location of the instruction.
8Input and output terminals are addressed as slot. word/bit or slot/bit Input and output terminals are addressed as slot.word/bit or slot/bit. Standard I/O modules have 16 points (terminals) and require 1 word of memory. High-density modules have 32 points and require 2 words of memory.The addressing of input devices and output components varies slightly from other instructions because the addresses represent the terminal where real-world devices are connected to a PLC. The variations are as follows:• The output (O) and input (I) files are defaulted to file 0 and file 1 respectively and cannot be used in any other data table file location.• The size of input and output files depends upon the number of input devices and output components.• File numbers are typically omitted from addresses.• Addresses contain the slot number of the module where input devices or output components are connected. Slot 0 is typically reserved for the CPU of the PLC. The maximum number of slots, using expansion racks, is considered to be 30.• Addresses are formatted as slot.word/bit or as slot/bit. See Figure 5-7.
9Information in status files is formatted as word/bit or as a word Information in status files is formatted as word/bit or as a word. The addressing format depends on the contents of the status file.Status file addresses are different from other instructions because the CPU creates status files. See Figure 5-8. The differences are as follows:• Status files, or “S” files, are defaulted to file 2 and cannot be used in any other data table file location.• S files cannot be added to, deleted, or changed in any way.• File numbers are omitted from status file addresses.• Addresses are formatted as word/bits or as words.
10The default bit file is B3 The default bit file is B3. Bit file addresses are formatted as word/bit, bit, or as a word.Bit file addresses use words and bits. The maximum size of a bit file is 256 sixteen-bit words, or 4096 bits. See Figure 5-9. The specifics of bit file addressing are as follows:• Bit files, or “B” files, are defaulted to file 3, and files can also be configured as B files.• File numbers are included in addresses.• Addresses are formatted as word/bits, words, or bits.
11A PLC or programming software will not accept a program when the program does not follow standard rules.When writing a programming diagram for a PLC, certain rules must be followed. A PC with programming software will not allow a program that does not follow the standard programming rules. See Figure 5-10.
12Ladder diagrams depict the flow of current through hardwired devices and components, while PLC program diagrams depict the flow of logic through instructions.Control devices in a ladder diagram are either ON (closed) or OFF (open). There must be continuity through hardwired inputs in order to energize the hardwired output components. While ladder diagrams depict the flow of current, PLC programming diagrams depict logical continuity. See Figure 5-11.
13The type of input instruction, XIC or XIO, determines how the rung of a program will operate with a normally open (NO) input device.Bit instructions can be confusing when using real-world input devices and output components with input (I) and output (O) files. The confusion stems from the fact that real-world input devices (pushbuttons, selector switches, and limit switches) can be normally closed (NC) or normally open (NO). See Figure Because there are two normal conditions, two types of input bit instructions (XIC and XIO) are used.
14The type of input instruction, XIC or XIO, determines how the rung of a program will operate with a normally closed (NC) input device.A “0” at the instructions data table file address corresponds to no voltage being present at the terminal of the PLC for the input device or output component. A “1” at the instructions data table file address corresponds to voltage being present at the terminal of the PLC for the input device or output component. The condition of input devices, NC or NO, and the type of input instruction, XIC or XIO, determine how a PLC program will function. See Figure 5-13.
15The XIC holding contact uses the same address as an OTE instruction but is not a hardwired contact and only exists in the memory of a PLC.One of the main benefits of a PLC is that an address can be used more than once and for more than one type of instruction. A programming diagram that represents a hardwired 3-wire motor start/stop circuit is a good example. In 3-wire motor start/stop circuits, the address for an OTE instruction is also the address for the XIC instruction that serves as a holding contact. The XIC holding contact only exists in the memory of the PLC and is not a hardwired contact. See Figure 5-14.
16OTL (latch) instructions can only turn a bit ON, and OTU (unlatch) instructions can only turn a bit OFF.Output latch (OTL) and output unlatch (OTU) are types of bit instructions. OTL and OTU instructions differ from OTE instructions in that OTL and OTU instructions must be used together. OTL can only turn a bit ON (1 at the instruction’s address), and OTU can only turn a bit OFF (0 at the instruction’s address). OTL and OTU instructions share the same address. ΟΤL and OTU can be thought of as latching relays in software. See Figure 5-15.
17PLCs scan program diagrams in a specific manner, with the placement of instructions impacting scan times.A scan is a method by which the CPU of a PLC looks at a program. PLCs scan the programming diagram from left to right and top to bottom. The scan begins at the top rung. When a CPU finds an instruction that is true, the CPU continues to scan the rung. When a CPU finds an instruction that is false, the CPU stops scanning the rung and goes to the next rung. For an output to affect another instruction during a specific scan, the instruction must be in a rung below the output. When an output instruction is in a rung above the output, the instruction will change state on the next scan. See Figure 5-16.