Ladder logic 104: Memory organization
Memory allocation varies from platform to platform. All platforms have input and output (I/O) memory and it is assigned and labeled in different ways depending on the platform.
One of the first decisions that needs to be made when designing a programmable logic controller (PLC) system is memory allocation and organization. In the early years of the PLC, memory came at a premium. 1K (one kilobyte) of memory for the program and data may have been all that was available for the programmer to use in a particular PLC. It was not unusual for programmers to assign unused I/O memory as data registers if the program grew to the point where the rest of the data registers had been assigned.
Memory allocation varies from platform to platform. All platforms have input and output (I/O) memory; this is because rather than accessing I/O directly, programs read the inputs at the beginning of the scan, writing them to a memory table. The program then processes the logic, using the saved input values and updating memory and the output table. At the end of the scan the output table is written to the physical outputs.
I/O memory is assigned and labeled in different ways. For this post, I am going to use three platforms as an example.
The letter designators for I/O differ as do the way they are assigned to physical points. This is even further complicated by the fact that for Siemens, analog I/O starts at different points depending on the platform (example: PIW256 or PIW800 designates Process Input Word.) Allen-Bradley still follows the slot number, (i.e. I:6.0) while AutomationDirect's Koyo platform uses V-Memory locations for analog, i.e. V7630-V7633 may hold four analog values from an I/O card.
Timers and counters also need to have memory assigned to them. Since they have special data types such as presets, accumulated values and "done" bits, they are generally assigned special areas reserved for them. T0 or C2 (Siemens) or CT5 (Koyo) are examples. Allen-Bradley has registers pre-assigned for timers and counters, T4 and C5. Examples of AB addresses for these might be T4:1 or C5:3. These are then appended with /DN for the "done" bit or .pre for a preset value.
Allen-Bradley also pre-assigns registers for bits (B3), integers (N7) and REALs (F8). New registers can be opened up as required for timers, counters, bits, integers, REALs or floating point values, and strings. Examples might look like N14, B33, F27, T88 and so on.
For both Siemens and Koyo special areas are assigned for discrete bits. Siemens uses M bits or words for general programming use; bits may have addresses such as M10.2 while words, double words and bytes may be assigned as MW42, MD60 or MB16. Floating point values are placed in double word locations.
Koyo's control relays are discrete only and use the designation "C". They are also octal, and have addresses such as C10 or C217.
All of Koyo's addresses, even the I/O, is overlaid with the "V" designation. V0 starts with timer current values, I/O may land somewhere in the V40000 range, while user data words of the volatile (non-retentive) and non-volatile (retentive) types fall somewhere in between. The system parameters are also located here. Locations also vary across the 200, 300 and 400 platforms.
Siemens PLCs also allow data to be organized into data blocks (DBs). These are structured by the programmer and can contain mixed data types. Most memory usage is placed here rather than in the "M" or marker memory. This allows for more application specific data organization. User-defined types (UDTs) can be used to further define data.
The previous descriptions apply to the older original platforms for these three types of PLCs. For Allen-Bradley this includes the PLC5, SLC500 and Micrologix families. For AutomationDirect/Koyo, it covers the 200, 300 and 400 families and for Siemens the S5 and S7 series, 200, 300 and 400s.
All three of these companies also have newer tag-based systems. For Allen-Bradley the ControlLogix and CompactLogix platforms allow users to add memory in the form of tags, or text-based addresses that are added as needed. Since these are readable by the programmer and usually descriptive, tag-based programming allows programs to be uploaded and read easier without the requirement of descriptions.
Siemens TIA Portal platform is tag-based, however it is still important to have the program since data structures are not as easily correlated when uploaded. The S7-1200 and S7-1500 are Siemens' tag-based PLCs.
Koyo's Productivity 3000 platform is their tag-based PLC. Tag-based programming is more efficient than the previously mentioned register-based systems and much easier to organize.
All of the previously mentioned platforms also allow for import and export of tags or descriptions by address. This enables programmers to manage and organize memory in an efficient way using Microsoft Excel.
Planning memory usage and assignment before starting to program is useful and can save the user a lot of time.
Frank Lamb is the founder of Automation Consulting Services Inc. This article originally appeared on the Automation Primer blog. Automation Primer is a CFE Media content partner. Edited by Chris Vavra, production editor, Control Engineering, CFE Media, email@example.com.
For more articles on PLCs and programming, see related articles below.
- Events & Awards
- Magazine Archives
- Digital Reports
- Global SI Database
- Oil & Gas Engineering
- Survey Prize Winners
- CFE Edu