• No results found

FILES, MEMORY AREAS, AND ADDRESSING

Memory is the place in the PLC-5 processor where information is stored. There are two basic types of PLC-5 processor memory: program and data. The program area of memory holds the instructions that make up the ladder logic of the application. These are the program files of the project. The data area is generally used for temporary storage of information required by the project files. The project files use various methods of addressing to move information into and out of the data areas.

MEMORY AREAS

Memory is an information storage area for the processor. Exactly what is stored and where it is stored depends on how the processor module was engineered. The important point here is that not all processors use memory in the same way. However, all PLC-5 processors have two basic memory areas: program and data.

For Review Only,

Not For Reproduction

Program Memory Area

The program area of processor memory is where the ladder logic is stored. Ladder logic includes the main control program, subroutines, fault handling routines, and any processor input interrupts. The program area is also where the system files for the processor are stored. The PLC5/20 processor supports up to 16 main control programs. User-defined ladder logic files may be numbered from 2 to 999.

Subroutines, fault routines, and interrupts are numbered from 3 to 999. These files appear in the Project Files folder of the Project window as shown in Figure 39.

Figure 39: Program Area File Assignments

For Review Only,

Not For Reproduction

How to Create a New Program File

1. Go off-line with the processor, or place the processor in the program mode. You will not be able to create a program data file if you are on-line with a processor.

2. Move the mouse pointer over the Program Files folder in the Project window and right-click the mouse. This opens the popup window shown in Figure 40.

Figure 40: Program Files Popup Window

For Review Only,

Not For Reproduction

3. Left-click NEW from the popup window. This opens the Create Program File popup window shown in Figure 41.

Figure 41: Create Program File Popup Window

4. Type a number for the file in the “Number:” field. The number 50 is used as an example in this illustration.

For Review Only,

Not For Reproduction

5. Enter a name for the new file and a description in the respective fields. A name can be up to 10 characters in length, and a description up to 50 characters.

Remember that the file name and description should relate to the function of the software. Keep in mind that any documentation you associate with the file may be useful for troubleshooting problems at some future date. As an example, this ladder file is given the name “SUBR-1” with a description of “sample ladder file.”

An example of the completed popup window is shown in Figure 42.

Figure 42: Completed Create Data File Popup Window

For Review Only,

Not For Reproduction

6. Select the OK button after you enter the name and description. This enters the new file with the assigned name in the Program Files folder as shown in Figure 43.

Figure 43: New File in Program Files Folder

For Review Only,

Not For Reproduction

7. Double click the “LAD 50 – SUBR-1” program file to open the file for programming. Notice the new file opens over anything you may already have open in the ladder window as shown in Figure 44. The name you entered for the file appears on the tab at the bottom of the ladder window, and the description you entered, as well as the name of the file, appear in the title bar the top of the ladder window.

Figure 44: LAD 50 – SUBR-1 File Open for Editing in Ladder Window

For Review Only,

Not For Reproduction

Data Memory Area

The smallest storage location in processor memory is a bit. Eight bits are grouped together to form a byte. Sixteen bits (2 bytes) are grouped together to form a word.

The Allen-Bradley PLC-5/40 processor has 48 K-words of data area memory space.

This memory space is set aside for the requirements of the data table. The data table includes the input image, output image, bit, timer, counter, and other files in the Data Files folder of the Project window. An example of the files in the Data Files folder is shown in Figure 45.

For Review Only,

Not For Reproduction

Files with numbers zero through 8 are default files for the PLC-5. The letter and number designations for each data file relate to the type (format) of information that can be stored in the file as described in Table 17.

Table 17: PLC-5 Default Data Files

File No.

File Type Notes

O0 Output Image Table

Bits in this memory area control the status of all outputs.

I1 Input Image Table Bits in this memory area indicate the status of all inputs.

S2 Status A processor configuration and status report.

B3 Bit or binary Binary (0 or 1) information.

T4 Timers Timer information.

C5 Counters Counter information.

R6 Control Used for advanced file instructions.

N7 Integer Integer values in the range -32,768 to +32,767.

F8 Floating-point Numbers containing a decimal point such as 5.6 or 6.2.

Data files numbered 9 through 999 are user defined to contain a specific data type. The user defined data file types are listed in Table 18.

Table 18: PLC-5 User Defined Data File Types

Identifier File Type

How to Create a New Data File

You must first determine the format of the data that is going to be stored in the file. You then pick a new file type that is consistent with the format of this data. Assume for this example that additional space is required in memory to store integer data. Based on the information in Table 18, we are going to create a data file having an “N” identifier.

This example creates an integer data file with a file number of 100. Note that this number assignment is arbitrary, but it must be in the range of 9 to 999, which are reserved for the user-defined files. Follow these steps to create a new data file, which, in this case, is identified as N100.

1. Go off-line with the processor, or place the processor in program mode. You will not be able to create a new data file if you are on-line with a processor.

2. Move the mouse pointer over the Data Files folder in the Project window and right-click the mouse. This opens the popup window shown in Figure 46.

For Review Only,

Not For Reproduction

3. Left-click NEW from the popup window. This opens the Create Data File popup window shown in Figure 47.

Figure 47: Create Data File Popup Window

4. Type “100” in the “File:” field. This is the user defined reference number of the new file for this example. Valid file numbers are from 9 to 999.

For Review Only,

Not For Reproduction

5. Open the “Type:” drop down menu and select INTEGER from the list as shown in Figure 48.

Figure 48: Data File Type Selection

6. Enter a name for the new file and a description in the respective fields. A name can be up to 10 characters in length, and a description up to 50 characters. The name and description should reflect what information is being held in the file.

Keep in mind that any documentation you associate with the file may be useful

For Review Only,

Not For Reproduction

7. Enter the number of elements the file contains in the “Elements:” field. The number of elements is the number of individual pieces of information being stored in the file. This sets aside sufficient data memory to hold your information.

This example uses 10 elements of memory. The completed popup window is shown in Figure 49.

Figure 49: Completed Create Data File Popup Window

For Review Only,

Not For Reproduction

8. Click the OK button from the bottom of the popup window. This creates the new integer file N100 – TEST in the Data Files folder of the Project window as shown in Figure 50.

Figure 50: New Integer Data File Created

For Review Only,

Not For Reproduction

You can examine the contents of any data file by double-clicking the mouse over it.

This opens a popup window for that data file with the memory contents displayed.

Double clicking the mouse over the new N100 – TEST file opens the popup window shown in Figure 51. Notice the description in the title bar, and that the file contains ten elements labeled 0 through 9. All ten elements contain 0 for data as shown in Figure 51.

Figure 51: File N100 – TEST Popup Window ADDRESSING

An address is a location in memory where information is stored. Addressing is the method by which this information is moved to that location. RSLogix uses a variety of addressing schemes in order to manipulate data. You must understand these schemes to ensure that the information you need goes where you want at the time you want it there.

There are several basic types of addressing schemes as follows:

• Logical

Logical addresses are codes that specify the location of information in the data table.

Variations of a logical addressing allow indexed and indirect addressing schemes. The general format of a logical address is as follows:

#TN:0.s/b

For Review Only,

Not For Reproduction

Table 19 explains the details of the logical address format.

Table 19: Logical Address Format

Symbol Description

# The # symbol indicates an indexed address.

Omit the # symbol if you are not using an indexed address.

T This indicates the file type. Any of the following letters are valid file types:

• B – binary • A - ASCII

N This indicates the file number. Allowable numbers are from 0 to 999. The file number is that which is associated with the file type for the files in the Data File folder.

: The ‘:’ symbol is a delimiter separating the file reference from the word reference (which is the location within the file where the data is found).

0 The 0 is the word number within the file. This number must be in octal for input or output files, and decimal for other file types.

. The ‘.’ Symbol is a delimiter that indicates a structure member mnemonic follows.

s The ‘s’ represents the structure member mnemonic of a counter, timer, or control file. The structure member mnemonic is an abbreviation that is two or

For Review Only,

Not For Reproduction

Indexed Addressing

Indexed addressing adds the contents of a special register, known as the index register, to a base address in order to form a new (indexed) address. The PLC-5 uses status register S:24 as the index register. The contents of S:24 are added to the base address to form the indexed address. The program then goes to the indexed address to retrieve or store data. It is up to the programmer to make sure the index register S:24 is loaded with the correct offset before using an indexed address.

Indexed addresses are especially useful with loop structures. The index register can be forced to increment or decrement with each iteration of a loop. The offset from the status register is then combined with the base address, providing access to a sequential range of data registers.

Indexed addresses in a program begin with the pound sign (#). The easiest way to understand the operation of an indexed address is by an example.

Start by examining the contents of status register S:24, shown in Figure 52. Recall that you can open the status register by double clicking the S2 file from the Data Files folder.

From the figure, you can see that the binary number 00000000000000112 is stored in the register, which is equivalent to 3 in decimal.

Figure 52: Status Register S:24

For Review Only,

Not For Reproduction

Now consider the logical address N7:0, which is the address of the first integer in the N7 data file. The contents of this register are displayed in Figure 53. The data stored at address N7:0 is 1.

Figure 53: Integer Register N7

Now modify the logical address N7:0 to form the indexed address #N7:0. When the program encounters the # at the base address, the software goes to status register S:24 to get the offset. In this case, the offset is 3 as shown in Figure 52. This value is added to the base address of N7:0 to yield an indexed address of N7:3. The data at this memory location is 50, which is the value that would be used in any calculation by the program.

Indirect Addressing

Like indexed addressing, indirect addressing is a modification of a basic logical address.

The significant difference is that an indirect address points to another address, which then points to the data. After calculating the offset, the indexed address points to the actual data.

Indirect addresses are identified by brackets somewhere in the instruction. An example of an indirect addressing format is N[N7:2]:1. The value within the brackets becomes part of the address.

For Review Only,

Not For Reproduction

Consider the contents of integer data register N7 shown in Figure 54 as an example.

The data at location N7:2 is 100.

Figure 54: Integer Data Register N7 and Indirect Addressing

For Review Only,

Not For Reproduction

The indirect instruction retrieves this data (100) and substitutes it for what is in the brackets. In this case, N[N7:2]:1 becomes N100:1. N100 is a user-defined data file that will be found in the Data Files folder of the Project window, as shown in Figure 55.

Figure 55: User-Defined N100 Data File

For Review Only,

Not For Reproduction

N100:1 is a logical address that points to word number 1 in the file. The N100 data file is shown in Figure 56. The data at location N100:1 is 33. This value, 33, would then be used in any calculation referenced using the indirect address. This example used an integer register for the indirect address. Valid registers for indirect addressing include the following types: N, T, C, R, B, I, O, and S.

Figure 56: N100 Data File

Symbolic Addressing

Symbolic addressing allows you to substitute a name for a logical address. This symbolic name can then describe the information contained at the address, which should make the program flow easier to understand. There are several restrictions on symbolic names:

1. The symbolic name is limited to 20 characters in length. Allowable characters are:

• The letters A through Z (uppercase)

• The numbers 0 through 9

• The underscore ( _ ) character

2. A symbolic name cannot be only numbers.

3. The following characters are not allowed in a symbolic name: ~ ` ! @ # $ % ^ & * ( ) + = [ ] { } \ | : ; “ < > ? / , .

4. A symbolic name cannot be a number followed by a D, O, H, E, or B. These are considered representations of decimal, octal, hexadecimal, exponential, and binary numbers, respectively.

For Review Only,

Not For Reproduction

5. You cannot start a symbolic name with the letters O, I, or S, and then follow that letter with a number. These are considered representations of logical addresses for output, input, or status files, respectively.

6. No blank spaces are allowed.

How to Create or Edit a Symbolic Name for an Address

There are several ways to create or edit a symbolic name for an address. These steps illustrate one of the easier methods.

1. Determine the name you are going to assign. The name should describe some attribute of the function occurring at the address, and help you to understand the flow of the ladder logic. A little thought at this step could provide a great deal of help during fault diagnosis and troubleshooting.

2. Right click the mouse over the symbol for which you are assigning a symbolic name. This opens the popup window shown in Figure 57.

For Review Only,

Not For Reproduction

3. Select EDIT DESCRIPTION from the popup window. This opens a popup window for the symbol shown in Figure 58.

Figure 58: Symbolic Name Entry

4. Enter or change the description of function in the “Edit Description Type” field, and the actual symbolic name in the “Symbol” field. Be as descriptive as possible with your entries. An example of a completed description and symbolic name is shown in Figure 59.

Figure 59: Symbolic Name Entry Completed

For Review Only,

Not For Reproduction

5. Select the OK button when you are satisfied with the information in the popup window. This enters the symbolic name and description into the ladder logic as shown in Figure 60.

Figure 60: Symbolic Name and Description in Ladder Logic

For Review Only,

Not For Reproduction

I/O Image Addressing

I/O image addressing is used to move data between the processor module and the I/O modules in the equipment chassis. The general format of a logical address is as follows:

M:rng/tb

Table 20 explains the details of this format.

Table 20: I/O Image Address Format

Symbol Description

M This indicates the file type. The following letters are valid file types:

• I – input

• O – output

rn This indicates the I/O rack number. The rack number, which must be in octal format, has a maximum allowable range of 008 to 278. The actual allowable range depends on the model of the PLC-5 processor.

g This indicates the I/O group number. The I/O group number is in octal format and ranges from 08 to 78.

/ The / is a delimiter separating the I/O group number from the terminal number.

tb This indicates the terminal (bit) on an I/O module to which the I/O point is connected.

Figure 61 illustrates how an I/O address appears in the ladder logic.

For Review Only,

Not For Reproduction

Chassis, Slots, I/O Racks, and Groups

This section of the text describes how the software talks to the I/O modules of the hardware. There are several basic concepts that are easily confused. These concepts include the following:

• Chassis

• Slot

• Rack

• Group

Chassis and slots are concepts that refer to the hardware, while racks and groups relate to the software.

Chassis and Slots

The chassis is the piece of equipment that holds the modules. Each module is connected to a slot in the chassis. A single chassis can have up to 16 slots to hold the various modules. Other common chassis sizes are 8-slot and 12-slot.

For Review Only,

Not For Reproduction

I/O Rack

An I/O rack is not the same as an I/O chassis. The chassis is the hardware. Racks are files in software. This means a rack is a logical device, not a physical one.

One I/O rack is 8 words of the output image table and 8 words of the input image table.

Remember that these image tables are the first two files in the Data Files folder in the RSLogix 5 Project window. The contents of the Data Files folder are shown in Figure 62. The output image table is labeled O0, and the input image table is labeled I1.

Figure 62: Data Files Folder

For Review Only,

Not For Reproduction

I/O Group

An I/O group is comprised of two words, one input word (16 bits) and one output word (16 bits) in the data table. This means that one I/O rack consists of 8 I/O groups (because 1 rack is 8 words in each of the output and input image tables).

Slot Addressing for I/O Transfer

Allen-Bradley offers a good deal of flexibility in the types and sizes of I/O modules that you may install in a rack. If, for example, you purchase a digital input module with provisions for 16 inputs, then the inputs from the module correspond nicely to the 16 bits available in an I/O group of the input image table. In this case, the transfer of data between the input module and the processor is relatively straightforward.

Digital input modules, however, have 8, 16, or 32 inputs, depending on the model selected for the application. These inputs somehow have to relate to the input image table, which has a defined size of 16 bits per group and 8 groups per rack.

Digital input modules, however, have 8, 16, or 32 inputs, depending on the model selected for the application. These inputs somehow have to relate to the input image table, which has a defined size of 16 bits per group and 8 groups per rack.

Related documents