1 / 117

Chapter 3—Part 1 Introduction to PLC Programming I

Chapter 3—Part 1 Introduction to PLC Programming I.

mili
Download Presentation

Chapter 3—Part 1 Introduction to PLC Programming I

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Chapter 3—Part 1Introduction to PLC Programming I Number Systems • PLC Memory• Rack/Slot Systems • Tag Systems • PLC 5 I/O Addressing • SLC 500 I/O Addressing • SLC 500 I/O Registers • Tag Based Addressing • SLC 500 Binary Bit Addressing • Logix Binary Bit Addressing • Retentive and Non-retentive Memory

  2. Number SystemsDecimal-Binary-Octal-BCD-Hexadecimal • Everyday tasksemploy the decimal or base 10 number system. • Base 10 is used in manufacturing automation to input or display parameter values. • Four other number systems are used:binary, octal, binary coded decimal (BCD), and hexadecimal. • Binary and hexadecimal are used most often in PLC automation.

  3. Number System Basics 1 of 2Weight Value-Digit Value-Position Weight • Number systems have a base or radix with position and weight values. • In the decimal system the base is 10 (0 through 9 digit values).

  4. Number System Basics2 of 2Weight Value-Digit Value-Position Weight • Position values increase from right to left starting with zero to the left of the decimal point. • The value of a decimal number is determined by adding the product of the digits and their position weight values. • The following formula converts a number from any base to base 10. Number10 = Σposition digits x BasePosition value of the digit

  5. (a) Comparison of number systems Binary Number SystemComparison with Decimal and Octal

  6. Binary Number SystemBase 2 Binary System—Two Digits 0 and 1 • PLCs perform logic and calculations using binary electronic circuits. • The binary system uses just two digits to represent the value of every number in a control system. For example: 1810= 0100102 • 0100102 is pronounced “one zero zero one zero base two” and not “ten thousand ten.” Leading zeros are dropped. • The 1810means 18 in the base 10 number system and the 2 in 0100102 indicates a binary or base 2 number.

  7. Binary to Decimal ConversionConversion Process—Binary to Decimal

  8. Binary to Decimal ConversionConversion Description—Binary to Decimal • The digit value in position 0 in Figure 3-3 is a 1, and each digit value contributes to the final sum. • The digit value of 1 in position 0 contributes a 1 to the sum of products; the digit value of 1 in position 1 produces a 2 in the sum of products; etc. • Digit values of 0 contribute 0 to the final sum, and digit values of 1 contribute their position weight to the sum. • A review of the conversion process indicates that the values in the sum of products column results from multiplying the digit value by the digit weight.

  9. Decimal to Binary ConversionConversion Process—Decimal to Binary

  10. Decimal to Binary ConversionConversion Description—Decimal to Binary • Conversion from decimal to binary uses a series of divisions by 2. • The remainder of the first division (1 in the Figure 3-4) is the least significant bit (LSB) value of the binary equivalent number. • The remainder of the last division (1 in the Figure 3-4) is the most significant bit (MSB) value. • The result of each division (i.e., 42 in the first division) is used for the next division. • The processes indicates that 8510 is equal to 10101012.

  11. (a) Comparison of number systems OctalNumber SystemComparison with Binary and Decimal

  12. OctalNumber SystemBase8Octal System—Eight Digits 0 to 7 • Some PLC data is presented in the Octal values so a conversion is necessary. • The octal system uses digits 0 to 7 represent the value of anumber.For example: 1510=178 • 178 is pronounced “seventeen octal” or “one seven base eight.” • As a result of not using digits 8 or 9, the digits in the zero position value increases from 0 to 7, then start to repeat after 7.

  13. (a) Octal to binary and binary to octal conversion Conversion—Octal and Binary Conversion Process Between Octal and Binary Review Counting Table

  14. Conversion—Octal and Binary Conversion Description—Octal and Binary • Octal to binary—each octal digit, 0 through 7, is replaced with its three-bit binary equivalent. • The three-bit binary groups are appended together to form the binary equivalent for the octal value. • Binary to Octal—The binary number is partitioned into groups of three bits, starting at the least significant bit end of the binary value. • Leading zeros are added if necessary to obtain the final group of three. Then each partition of three-bit binary numbers is converted to its equivalent 0 through 7 octal value.

  15. (a) Octal to decimal conversion Octalto Decimal ConversionConversion Process—Octal to Decimal

  16. Octalto Decimal ConversionConversion Description—Octal to Decimal • Conversion from octal to decimaluses the following formula: Number10 = Σ position digits x 8Position value of the digit • Decimal value is the summation of all position digits times the radix (8) raised to the power of the position value. • The conversion of 158 to decimal is: Number10= 1 x 81 + 5 x 80= 1 x 8 + 5 x 1 = 8 + 5 = 1310 • Conversion from base 10 to base 8 can be performed by first converting from decimal to binary and then converting the binary value into octal. Review Counting Table

  17. Hexadecimal Number System • Due to the large number of digits, the binary number system is hard to use when the number value represented is large. • The hexadecimal system has fewer digits with large numbers and conversion to binary is easy. • The hexadecimal system uses the base 16. These 16 digits are represented by the numbers 0 through 9 and the letters A, B, C, D, E, and F. • Hexadecimal features: • Hex numbers are very compact. • Easy conversion from hex to binary and binary to hex.

  18. Comparison of Numbering Systems Note that a lower case “b” is appended to the binary number, a lower case “q” is appended to the octal number and a lower case “h” is appended to the hexadecimal number.

  19. Binary to Hex Conversion • Conversion from a binary number to hex number: • Break the binary number into 4-bit sections from the LSB to the MSB. • Convert each 4-bit binary number to its hex equivalent. • Convert 10010011001011 into the hex equivalent. 10010011001011 (Binary number) 0010 0100 1100 1101 (Binary in 4-digit sections) 2 4 C D (Hex number equivalent) • Note that there are only 2 digits in the most significant section, and leading zeros are added to make the 4-digit group.

  20. Hex to Binary Conversion • Conversion from a hex number to binary number: • Convert each hex number to its 4-bit binary equivalent. • Combine the 4-bit sections by removing the spaces. • Convert AFB2 into the binary equivalent: A F B 2 (Hex number) 1010 1111 1011 0010 (Binary equivalent) 101011110110010 (Binary digits combined)

  21. Hex to Decimal Conversion 1 of 2 • Conversion from hex to a decimal number is accomplished by the following four steps: • Multiply each hex digit by its weighted value. • Convert the hex digits to their decimal equivalent. • Convert the hex weighted values to decimals and complete the multiplication. • Add all the values.

  22. Hex to Decimal Conversion 2 of 2 Example: Convert AFB2h to decimal A x 163 + F x 162 + B x 161 + 2 x 160 (Weighted values) 10 x 163 + 15 x 162 + 11 x 161 + 2 x 160 (Decimal Equivalents) 10 x 4096 + 15 x 256 + 11 x 16 + 2 x 1 (Conversion) 40,960 + 3,840 + 176 + 2 = 44,978 (Multiplications & result)

  23. Decimal to Hex ConversionRepeated Division Method • Divide the decimal number by 16, and convert the remainder to a hex number, and place it in the least significant digit of the final hex number. • Continued by dividing the quotient by 16 and placing the remainder in the next most significant digit in the hex equivalent. • The conversion is complete when the quotient is 0.

  24. Repeated Division Method

  25. Bits, Bytes, and Words • A single binary digit is a bit, and eight bits are a byte, pronounced like the word bite. • Two bytes or 16-bits is a word, and two words or 32 bits represents a double word.

  26. PLC Memory • PLC memory is organized using either bytes, single words, or double words. • The memory has three binary interfaces: • Data bus carries parameter values and PLC instructions. • Control bus provides the logical control for movement of instruction and data. • Address bus carries the binary address number for all the binary values stored in memory.

  27. PLC MemoryBlocks of Consecutive Bytes or Words Memory layout is 1k x 16-bit words, where 1K memory is actually 1024 locations. Each of the 1024 16-bit words has a10-bit address.

  28. Allen-Bradley Memory Organization • This text presents the memory organization for the Allen-Bradley PLC 5, SLC 500, and Logix processors models. • With a good knowledge of the three AB systems, it is not difficult to learn a second manufacturer’s PLC system. • Allen-Bradley PLCs have two distinctly different memory structures: • Rack-based systems • Tag-based systems

  29. Rack/Slot-Based Memory1 of 2PLC 5 and SLC 500 • Common memory structure for rack/slot address–based PLCs is a two-drawer filing cabinet with one drawer for program files and the second drawer for data files. • The data and program file groups are subdivided into instruction-specific files and file types.

  30. Rack/Slot-Based Memory 2 of 2PLC 5 and SLC 500

  31. Data FilesRack/Slot-Based Systems • Data files are subdivided into 9 (0 to 8) designated file types and 247 (9 to 255) user-defined file types. • Data files contain folders with data bits of memory in rows that are 8-, 16-, or 32-bits wide. • Output data is assigned to specific memory, input is assigned to another, and all the files have specific locations where their values are stored. • A separate block of memory is designated as user-defined space. In this location, the programmer has the option to designate what type of data will be stored.

  32. Program Files • Ladder logic programs are stored in the program files—the size is set by PLC memory size. • Two program file types, system and program, exist, and they are subdivided into systemfunctions (file 0 and 1), main program (file 2), and subroutine programs (files 3 through 255). • File 2 is the default location for the main program, and files 3 through 255 are available for subroutines called from the main program.

  33. Tag-Based SystemsLogix • Logix series PLCs uses a different memory organization called a tag-based memory system. • All data (i.e., output status, input status, integer values, or any of the designated file or data types) are assigned a variable name called a tag, so knowing the location in memory is not necessary. • Programs are developed using only tag names. • Input and output terminals are assigned to input and output tags before the program is executed.

  34. Memory OrganizationPLC 5Rack/Group-based Memory • Data files store processor information obtained from input modules, results sent to output modules, and other system data. • Specific memory is allocated for I/O data based on the rack and group assigned to the I/O module. • Modules are located in a chassis (the unit into which modules are placed) instead of a rack, because a rack may not be limited to one chassis.

  35. Data File ContentPLC 5Rack/Group-based Memory

  36. Memory OrganizationSLC 500Rack/Slot-based Memory • Information is divided into two file groups: program and data. • Data files are organized by the type of process and program data they contain. • Specified data files(numbers 0 through 9) and user-defined datafiles(numbers 10 through 255)are used. • Program files contain controller information, the main ladder program, interrupt subroutines, and all subroutine programs.

  37. Data File Content 1 of 2SLC 500Rack/Slot-based Memory

  38. Data File Content 2 of 2SLC 500Rack/Slot-based Memory • The files commonly used on all SLC PLCs include the following: • Output (file 0)—This file stores the on or off condition at the output terminals for the output module associated with this memory register. • Input (file 1)—This file stores the on or off condition at the input terminals for the input module associated with this memory register. • Status (file 2)—This file stores controller information used for troubleshooting controller and program problems.

  39. Data File Content 3 of 5SLC 500Rack/Slot-based Memory • Bit (file 3)—A bit consists of one binary digit and is often referred to as a Boolean type of data element. Bit files are used most often for bit (relay logic)-type program development. • Timer (file 4)—This file stores the data for each timer used in a program. The data includes timer accumulator and preset values, plus all status and output bits. • Counter (file 5)—This file stores the data for each counter used in a program. The data includes counter accumulator and preset values, plus all status and output bits.

  40. Data File Content 4 of 5SLC 500Rack/Slot-based Memory • Control (file 6)—This file stores the length, pointer position, and status bits for specific PLC instructions. • Integer (file 7)—This file typically includes 256 16-bit words for the storage of unsigned or signed integer values. The storage elements can be addressed at the word and bit level. The range of stored signed integer values is –32,768 to +32,767, and the range for unsigned values is 0 to 65,635.

  41. Data File Content 5 of 5SLC 500Rack/Slot-based Memory • Floating Point (file 8)—This file stores single precision non-extended 32-bit numbers that include their whole and decimal components. The range of values stored is +/– 1.1754944 x 10-38 to +/– 3.4028238 x 10+38. • Network (file 9)—This file with 256 words has network data. • User-defined (files 10–255)—These files can be used to create any file type from 0 through 8. They are used to expand the number of data files available to the programmer.

  42. Program File ContentSLC 500Rack/Slot-based Memory • Program files contain controller information, the main ladder program, interrupt subroutines, and all subroutine programs. These files in the SLC system are: • System Program (file 0)—Contains system-related and user-programmed information, such as processor type, I/O configuration, processor file name, and password. • Reserved (file 1)—This file is reserved. • Main Ladder Program (file 2)—Contains the main program. • Subroutine Ladder Program (files 3 to 255)—Subroutines are ladder logic programs called from the main ladder logic program. All subroutine programs are placed in this program area.

  43. Memory OrganizationLogix Tags • Logix assigns variable names or tags to field device inputs and outputs, internal relays, and data values. • A tag is defined as: A tag is a text-based name for a 4 byte (16 bit) area of the controller’s memory where data is stored. • Tags are use to allocate memory, reference data in programs, and monitor data. • Tags forI/O are assigned to an I/O module and a specific module terminal number.

  44. Variable Data Types 1 of 3Logix • Frequently used data types: Boolean, integer, real, strings, and user defined. • Data types have one definition (Boolean) to as many as eight definitions (integer) to select. • User-defined data types permit the creation of a unique(new) data type specific to the process being controlled. • The tag data islocalor global. Local tag data is restricted to one program,and global tag data can be used in any program. Input and output data types are all global. Return to Logix Tags

  45. Variable Data Types 2 of 3Logix—Basic Data Types Return to Logix Tags

  46. Variable Data Types 3 of 3Logix—Structured Data Types Return to Logix Tags

  47. Program OrganizationCreating Tags in Logix • Three options: • Leave the ? in the tag location in the ladder and then define a tag at a later time. • Define all of the tags for the programming project before the program is developed. • Define the tags as the program is entered. • After tags are defined, those that represent input or output field devices are assigned to the input or output terminal where the field device is attached.

  48. Logix Memory Structure

  49. Memory Structure ElementsLogix—Project • A project (the large white project box in Program Structure) is a collection of all of the program's elements. • When a project is created the new controller dialog box requests the following information: • Controller model and software revision number • Project name and description • Rack size and slot location of the processor • File folder name into which the program is stored Go to Program Structure

  50. Memory Structure ElementsLogix—Continuous Tasks • Logix permits up to 32 tasks, which have two functions: • Holds the information necessary to schedule the program’s execution. • Sets the execution priority for one or more programs. • Two types of tasks are used: • Continuous • Periodic • Continuous tasks execute non-stop. At the creation of a new project, a continuous task (white task box in Program Structure) is created. Go to Program Structure

More Related