1. Field of the Invention
The invention generally relates to process control routines and, more specifically, to control routines using ladder logic.
2. Brief Description of Related Technology
Ladder logic has often been used to express control routines implemented in process control systems. Ladder logic has its origins in expressing relay-based logic, where each relay is expressed as a coil and one or more contacts controlling whether the coil is energized. To that end, the contacts and coil for each relay are arranged on a rung connected between two power rails, thereby presenting a ladder. Outside of relays and relay networks, ladder logic has been extensively applied as a standard programming paradigm for programmable logic controllers (PLCs), which have been used to implement control logic for a variety of process control operations. The logic and routines executed by PLCs may often be expressed in other programming paradigms, such as Boolean logic. However, ladder logic has remained one of the preferred programming paradigms, particularly when the logic can be easily expressed as a series of relay coils and contacts.
To address the increased complexity of process control routines, process control systems utilizing PLCs have been upgraded to incorporate more advanced digital controllers that execute control logic expressed via higher level programming structures or languages, such as object-oriented programming languages. These advanced controllers are routinely integrated in widespread networks that rely on distributed process control techniques having one or more operator workstations to provide user interfaces for configuration, maintenance, and other control functions. In these cases, the user interfaces provide the capability of reprogramming a controller remotely. To this end, the workstations and other user interfaces execute configuration software and other routines that enable control personnel to view and modify the control logic being implemented throughout the process control system. As a result of these innovations, maintaining a process control system that integrates a number of controllers can be handled without requiring personnel to visit each controller individually with a handheld or other portable device for programming and other work, as was often the case with PLCs.
Despite these advances and innovations in process control, many systems are still using ladder logic to express the control logic executed by controllers or other devices within the network. Unfortunately, personnel responsible for maintaining the system may now be more comfortable working with the higher level programming languages and Boolean logic, rather than ladder logic. As a result, maintenance and other work directed to improving or re-configuring ladder logic systems may inefficiently require one or more manual translations of the logic. More specifically, a first translation process may be required to convert the control routine from ladder logic into Boolean logic to enable those individuals more familiar with Boolean logic to diagnose problems or design improvements in the control routine. Because this translation is often performed manually, the process is often time-consuming and prone to errors, in which case further translations may become necessary.
U.S. Pat. No. 5,623,401 issued to Baxter describes a control system operating method that involves a technique for converting ladder logic of a limited and simplistic nature (e.g., only coils and contacts) into flow type programs of Boolean gates for the purpose of improving the response time of a control system. The end result is a sequence of transition routines that ensures that only changes in certain variables are processed during operation. Thus, these transition routines are generated to optimize execution, rather than for supporting the types of logic design, configuration, maintenance or other work described above in the context of advanced process control systems. As a result, the results are not made available, stored or expressed in a way that supports further design, configuration, maintenance or other work on the logic routine.
Disclosed herein is an automated logic conversion technique that may be implemented as a system, method or computer program for automated translation or conversion of a routine expressed in ladder logic. The disclosed technique converts the ladder logic into a set of Boolean logic elements in a manner that enables further design, configuration, maintenance, and other work on the routine and the underlying logic.
In accordance with one aspect of the conversion technique, a method is useful for processing a routine expressed via ladder logic elements arranged in a plurality of ladder rungs and in accordance with an execution order. The method includes collecting Boolean representations of the ladder logic elements in a respective logic expression for each ladder rung of the plurality of ladder rungs, resolving Boolean logic elements from the logic expressions, and storing information regarding the Boolean logic elements in a memory in accordance with the execution order to express the routine in Boolean logic.
In certain embodiments, the resolving step is performed if further collection of the Boolean representations in one of the respective logic expressions would result in a combination of dissimilar Boolean logic functions.
The collecting step may include the steps of evaluating each ladder logic element to determine an operation effected thereby and updating the respective logic expression to reflect the operation. The storing step may include the step of writing to the memory a definition of the Boolean logic element as an object disassociated from the logic expression. The object may be written to a position in the memory relative to further objects associated with further Boolean logic elements that preserves the execution order of the routine. The ladder logic elements may be arranged in columnar positions within each ladder rung and wherein the execution order proceeds in columnar fashion.
In one embodiment, the method further includes the step of proceeding to a different ladder rung of the plurality of ladder rungs for a subsequent ladder logic element evaluation prior to evaluating another ladder logic element in the first-named ladder rung.
In cases where the ladder logic has special functions, the method includes the steps of (i) identifying a non-Boolean function having units spread over multiple ladder rungs of the plurality of ladder rungs, and (ii) resolving a further Boolean logic element from a respective logic expression for the ladder rung of the plurality of ladder rungs connected to an input of the non-Boolean function. The method may further include the step of storing an object representative of the non-Boolean function in the memory in accordance with the execution order.
In one embodiment, the collecting step includes the step of combining two or more respective logic expressions for adjacent ladder rungs of the plurality of ladder rungs linked via one or more OR functions to create a composite logic expression for each of the two or more respective logic expressions. The combining step may include the step of executing a recursive procedure.
In accordance with another aspect of the conversion technique, a system includes a processor, a computer-readable memory coupled to the processor, and a logic conversion routine stored in the computer-readable memory and configured to be executable by the processor. The logic conversion routine, in turn, includes a ladder logic element processing routine that collects Boolean representations of the ladder logic elements in a respective logic expression for each ladder rung of the plurality of ladder rungs. The ladder logic element processing routine then resolves a Boolean logic element from the respective logic expression when further collection would set forth dissimilar Boolean functions in the respective logic expression.
In one embodiment, the logic conversion routine further includes an OR function processing routine that, when an OR function is encountered, (i) combines multiple, respective logic expressions for adjacent ladder rungs of the plurality of ladder rungs connected by the OR function to reflect a combination of the multiple, respective logic expressions and, (ii) modifies each of the multiple, respective logic expressions to reflect the combination. The OR function processing routine may execute a recursive procedure.
The ladder logic element processing routine may include a coil processing routine that, when a coil is encountered in a current ladder rung of the plurality of ladder rungs, resolves the logic expression for the current ladder rung into a further Boolean logic element.
In accordance with yet another aspect of the conversion technique, a computer program product is stored on a computer-readable medium for conversion of a ladder logic routine. The computer program product includes first, second and third instructions sets. The first instruction set collects Boolean representations of the ladder logic elements in a respective logic expression for each ladder rung of the plurality of ladder rungs. The second instruction set then determines whether to resolve Boolean logic elements from the logic expressions. The third instruction set then stores the Boolean logic elements in a memory in accordance with an order in which the Boolean logic elements are resolved.
In one embodiment, the second instruction set may be executed when further collection of the Boolean representations in one of the logic expressions by the first instruction set would result in a combination of dissimilar Boolean logic functions.
The first instruction set may evaluate each ladder logic element to determine an operation effected thereby and update the respective logic expression to reflect the operation.
The third instruction set may write to the memory respective definitions of each Boolean logic element as a respective object disassociated from the logic expression from which the Boolean logic element was resolved. In one embodiment, the order in which the objects are stored preserves an execution order of the ladder logic routine.
For a more complete understanding of the invention, reference should be made to the following detailed description and accompanying drawing wherein:
While the disclosed conversion technique is susceptible of embodiments in various forms, there are illustrated in the drawing (and will hereafter be described) specific embodiments of the invention, with the understanding that the disclosure is intended to be illustrative, and is not intended to limit the invention to the specific embodiments described and illustrated herein.
The disclosed embodiments generally relate to automated conversion or translation of ladder logic to Boolean logic and, thus, may be useful in connection with a process control system having devices that execute routines expressed in ladder logic. More particularly, configuration, design, maintenance, programming, or other work toward maintaining or improving the operation of such process control systems may benefit from such conversion or translation if, for instance, operators or other personnel are unfamiliar with ladder logic. However, even though the disclosed embodiments are particularly well suited for converting process control routines, practice of the disclosed embodiments is not limited to application within any particular type of system or context, or execution on any particular workstation or other hardware arrangement. Rather, the automated conversion technique disclosed herein may be applied to any one of a number of different computing platforms without regard to the context or application in which the underlying ladder logic is executed. Thus, any direct or implied reference herein to a particular type of routine (e.g., a process control routine), context, application, or system in which the disclosed embodiments are incorporated or practiced is made only for the convenience of illustrating the disclosed technique.
Practice of the disclosed embodiments is also not limited to any one particular ladder logic paradigm or convention. In fact, the disclosed conversion technique is compatible with a wide variety of ladder logic rules. For instance, the disclosed conversion or translation technique may be applied to a routine including non-standard ladder logic elements (i.e., other than contacts and coils), such as timers, flip-flops, and other special functions. Such functions are generally addressed as one of a catalog of special functions addressed by one embodiment of the disclosed technique. The underlying ladder logic may also have a vertical, horizontal, or other execution order, as will be explained further herein, such that the logic underlying such execution ordering will be preserved in the translation or other output of the conversion routine.
More generally, and in accordance with one embodiment, the disclosed conversion technique is based in part on the collection of Boolean representations of ladder logic elements in separate logic expression dedicated to each rung of the ladder in which the ladder logic elements are arranged. Each respective logic expression is updated or modified as the automated conversion technique sequentially processes or evaluates each ladder logic element in the ladder. The logic expressions generated by the conversion routine do not, however, constitute the output of the disclosed system, method or computer program. The logic expressions are, in fact, intermediate results (i.e., working or temporary parameters) utilized during the conversion processing, even though the Boolean representations in the logic expressions may, in some embodiments, set forth formal Boolean logic having a complete or cohesive set of elements, operators, operations, or functions. Instead, distinct Boolean logic elements are resolved from the logic set forth in the expressions as the processing of the ladder progresses. An element is resolved during certain processing to avoid the collection of dissimilar Boolean function in a logic expression, although elements may be resolved under several different circumstances. These Boolean logic elements are then stored in the order in which they are generated and in a manner that (i) supports subsequent maintenance and other work on the routine being converted, and (ii) maintains the execution order of the underlying ladder logic.
The process control system 10 includes user interfaces 12 and 14, which may be, for example, workstations or computers connected in a communication network to a number of other devices such as a data storage device or historian 16 and any number of controllers 18 via a system level data bus 20. The system level data bus 20 may be an Ethernet data bus or any other data bus suitable for the transmission of data. The controllers 18 may be, for example, a DCS (distributed control system) controller and may communicate with the user interfaces 12 and 14 using a proprietary communication protocol, or in any other suitable manner, via the system level data bus 20, to execute the underlying ladder or resultant Boolean logic. The underlying ladder or resultant Boolean logic may be implemented in the controller 18 as control algorithms or routines for use in controlling field devices that are connected to the controller 18 in any conventional or any other desired manner.
As shown in
Either one of the user interfaces 12, 14, or both, may be an engineering station such as the Ovation workstation available from Emerson Process Management, Power & Water Systems (Pittsburgh, Pa.) or any other similar workstation running on a UNIX platform. Alternatively, or in addition, one of user interfaces 12, 14, or both, may be a personal computer running on any one of a number of other operating systems, such as Microsoft Windows. Either one of the user interfaces 12 or 14, or both, may be relied upon to implement, or support the implementation of, the disclosed logic conversion technique. As set forth above, however, implementation of the conversion routine does not require either user interface 12, 14 (or any other process control system workstation or device), and may instead rely on a standard personal computer outside of the network associated with the system 10. Thus, in one embodiment, one of the user interfaces 12, 14 may not be coupled to the bus 20 as shown in
In certain cases, the disclosed conversion technique may be implemented or practiced within a process control system as part of a package of software utilities or tools. Regardless of the degree to which it is integrated with other tools or software, the conversion routine may be configured to execute on any one of a number of different hardware and software platforms, and is not limited to any proprietary operating system, hardware, programming language, or software configuration. While the disclosed logic conversion technique may be implemented in software as a computer program executed by one or more general-purpose processors, the disclosed technique may also be implemented using dedicated hardware, firmware, software, or any combination thereof. In either case, the disclosed logic conversion technique may be implemented as part of a broader suite of utilities or functions available for controlling the process and the process control system 10 more generally. These utilities and functions may include, for instance, configuration and edit functions that allow an operator to create the ladder logic routines to be converted by the disclosed technique.
With continued reference to the exemplary embodiment of
The processor 28 may be any type of processor but, preferably, is a general purpose, programmable processor such as those generally used in personal computers, UNIX workstations, and the like. The memory 27 may be any desired type of memory.
The controller 18 also includes a processor that implements or oversees one or more process control routines (stored in a memory), which may include control loops, stored therein or otherwise associated therewith and communicates with the devices 22, 23, the user interfaces 12 and 14, and the data historian 16, to control a process in accordance with, for instance, the underlying ladder logic routine to be converted. It should be noted that the underlying routine may have parts thereof implemented or executed by different controllers or other devices if so desired. Likewise, the underlying routine may take any form, including software, firmware, hardware, etc. For the purpose of this disclosure, control routines, which may be modules or any part of a control procedure such as a subroutine, parts of a subroutine (such as lines of code), etc., may be designed using any design tools, including graphical design tools or any other type of software/hardware/firmware programming or design tools.
In an embodiment where the underlying routine is executed by the controller 18, the user interfaces 12, 14 may provide on- and off-line, graphical monitoring and other control functionality in connection therewith. The underlying routine may therefore be expressed in graphical ladder logic, as shown in
Ladder logic generally, as well as the logic elements of the control routine shown in
The exemplary routine of
In accordance with one embodiment of the disclosed conversion technique, the ladder logic of the control routine to be converted is organized or parsed into a number of cells or units indicated generally at 42. For example, in the routine of
As is well known to those skilled in the art, the ladder logic may be stored in a textual, graphical or other manner, but in any case, the attribute data for each cell is associated therewith to completely define the logic.
Parsing the routine into the units or cells 42 organizes the routine into a number of columns indicated generally at 44 and rows indicated generally at 46. Apart from defining the location of each cell 42 by column and row number, such organization is typically used by those skilled in the art to establish an ordered sequence for the logic. In other words, the parsing of the ladder into the cells 42 is a straightforward way of establishing or defining the execution order of the routine. Without knowing the execution order, the execution of the routine may not be consistent, particularly when logic elements such as the coil 38A are used to determine the state of other logic elements within the routine, such as the contact 36C. In such cases, proceeding through the ladder in a different order would, in execution, change the way the underlying routine executes and, in conversion to Boolean logic, result in an erroneous translation.
In the event that a ladder has yet to be organized into cells, a parsing routine known to those skilled in the art can be used to organize the ladder routine into columns, rows, and/or cells, provided that the execution order or other convention for the ladder is known or can be easily surmised. Parsing the underlying logic need not result in a set of rectilinear units or cells defined by columns and rows, however. For instance, the underlying routine may have a sequence of units or other portions that are defined in accordance with the execution order. In fact, as long as the execution order (or, equivalently, the operation) of the ladder is known, established, or otherwise defined, the conversion routine will be able to sequentially process the portions of the ladder appropriately to generate an accurate translation.
Thus, despite the advantages of parsing the routine into cells or units, practice of the disclosed technique is not limited to ladder logic systems that have defined cells or units. Rather, the disclosed technique may be applied to any ladder logic having an ordered or defined sequence of logic elements. In that way, the disclosed technique progresses through the ladder in the proper sequence of logic elements, thereby preserving the execution order of the logic in the process.
As explained above in connection with the routine of
One scanning convention establishes a horizontal execution order, such that the logic elements in a row are all evaluated, generally moving from left to right, prior to moving on to the next row, typically the one immediately below the current row. Of course, such horizontal scanning may begin with any cell of the ladder, and then proceed either right-to-left, or from bottom rows toward the top of the ladder. Alternatively, the ladder may have a scanning convention that establishes a vertical or columnar execution order, in which the logic elements in a column are evaluated prior to moving to an adjacent column. Typically, evaluation would proceed from left to right, top to bottom, but other starting points and evaluation directions may be selected. For the purposes of ease in illustration, the following description of the disclosed conversion technique will assume a vertical execution order, beginning with the upper, left-most cell.
One other ladder logic convention is directed to the connection of two or more ladder rungs at certain instances between the rails 30 and 32. Such connections create an OR function with two or more operands. In one embodiment of the disclosed conversion technique, the parsing of the ladder into cells or units also identifies which cells are identified as having the connection, or the “OR” function. For the sole purpose of ease in illustration, and in one exemplary embodiment, the aforementioned “OR” attribute will be assigned a value of “TRUE” only for the bottom of the two cells making the connection. In the exemplary embodiment shown in
In the process control context, these conventions or rules are established by the process control application or system (e.g., configuration software) utilized to design and/or execute the ladder logic. For each given process control system or application, conversion of the underlying ladder logic of the control routine may then proceed in a sequence in accordance with its ladder logic conventions. Generally speaking, this sequence, or the order in which the underlying ladder logic is evaluated by the disclosed logic conversion routine, is the same as the execution order, i.e., the order in which the underlying logic is evaluated during execution. Thus, the logic conversion routine translates the underlying logic in systematic fashion in accordance with the execution order, generating the Boolean logic output on the fly and storing the output in a manner that maintain the execution order. Generation “on the fly” refers to how the output of the conversion routine is generated gate-by-gate, or element-by-element, as the control routine is processed in systematic, element-by-element fashion, rather than after all of the underlying logic has been evaluated or processed. While not every ladder logic element encountered will give rise to the separate generation of a corresponding Boolean logic element in the output, the disclosed conversion technique generates each element or portion of its output in response to, and as a result of, encountering a subsequent ladder logic element. Nonetheless, the order in which the Boolean logic elements or gates are generated is also indicative of the order in which they should be evaluated during execution of the Boolean logic output. Thus, this sequential approach to conversion results in an ordered set of Boolean logic elements that maintains the original execution order of the underlying ladder logic.
As briefly mentioned above, the disclosed conversion technique utilizes a number or set of logic expressions, one dedicated to each row or rung of the ladder, to maintain an account of the logic elements encountered thus far in connection with each ladder rung. Each logic expression therefore serves as a collection mechanism for the logic encountered, as will be described in greater detail below. After the coil compression is performed, control may pass to a block 52 to initialize each of these logic expressions. The block 52 may generate the logic expressions in connection with initializing them if, for instance, the expressions were not already created, or the correct number of expressions had not previously been created). In one embodiment, the block 52 includes generation of an array, EXP, having the appropriate number of elements, EXP0, EXP1, . . . EXPi, where the subscript, i, denotes the row or ladder rung with which the logic expression is associated.
Whether each logic expression is stored as an array element or arranged in any one of a number of other ways, the block 52 generally enables the logic expressions to be stored as character or textual strings containing information or data resulting from the translation, e.g., the Boolean operators, operands, and gates or other functions. Such information is generally set forth using Boolean representations of the ladder logic elements. However, the logic expressions need not present the information strictly or solely in formal Boolean logic terms (e.g., C=A1 AND B2), insofar as the logic expressions are not the final output of the disclosed conversion technique, but rather an intermediate step. Thus, the Boolean representations may set forth the Boolean logic elements in a manner representative of, but not necessarily identical to, the manner in which the Boolean logic would formally be recited. However, in one embodiment, the information stored in the EXP1 string takes the form of the text reciting the Boolean function established by the ladder logic elements within a particular rung. As an example, after analyzing a normally open contact in the first column of the first row, the string may look like EXP0=A, where A is the contact variable. The collection of other ladder logic in that row (or other rows) will then result in the modification of that EXP string as will be explained herein below. Generally speaking, such collection and modification includes updating the respective logic expression to reflect a combination of the current logic expression with a representation of the next ladder logic element sequentially encountered in the row or ladder rung.
At this initial point, each EXP string is initialized in the block 52 to a value of “TRUE” to signify the potential for a connection to the rung 30. The value “TRUE” will then be combined with the ladder logic present in the cell of the first column to determine how the EXP1 string should be modified.
After the EXP strings have been generated and/or initialized, control passes to a block 54 that causes the conversion routine to proceed to the first column to be evaluated, which, in the exemplary embodiment, is the cell 42 in the left-most column of the ladder. Multiple stages of evaluation and processing of the cells in the column are then conducted in a block 56. The multiple stages are directed to different types of ladder logic elements that may be present in each cell. This multiple-stage evaluation and processing of the cells generally proceeds sequentially from cell-to-cell within the column in accordance with the execution order, i.e., from the top-most rung of the ladder down. Although, in some embodiments, all of the cells within a column may be evaluated and processed in accordance with one stage, before the evaluation and processing for the second stage begins. Alternatively, all of the evaluation and processing of each cell may be conducted prior to proceeding to the next cell.
Generally, the evaluation performed in the block 56 determines an operation effected by the ladder logic element in the cell, such that the processing involves modifying the logic expression for the rung or row in which the cell is disposed to reflect the operation. For example, if a contact is disposed in the cell being evaluated, the modification performed in the block 56 updates the logic expression to reflect the result of the combination of the contact and the logic already collected in the logic expression.
When modifying or updating the logic expression, to update the logic expression, the block 56 may resolve a Boolean logic element from the information in the EXPi string to avoid certain combinations. More particularly, a Boolean logic element is resolved from the logic expression when the combination would result in mixed or dissimilar logic functions (e.g., AND, OR, NOT) in a compound logic expression. For example, the following logic expression is compound, as it has more than one operator, and involves two different functions or operators: (A1 OR B2) AND B3. As explained further below, there may be other instances where a Boolean logic element is resolved. In any case, the new Boolean logic element is then stored in a memory, which, in one embodiment, involves storing the element in the next available position within a one-dimensional vector of data defining the Boolean logic elements. Additionally, a new identifier is created to represent the output of the Boolean logic expression.
Continuing with the foregoing example, if the logic expression prior to modification was EXPi=A1 OR B2, then the information stored may be representative of the Boolean function, C=A1 OR B2. Once this new Boolean logic element has been resolved, the block 56 combines it with the logic introduced by the cell being evaluated. More particularly, the logic expression “A1 OR B2” is replaced by an identification or symbol for the new Boolean logic element, namely “C”. Because the latest cell might present a contact, B3, the modified EXPi string becomes EXPi=C AND B3. This modification process will be described in further detail below in connection with certain ladder logic elements, but generally speaking, it is an iterative procedure that (i) avoids building complex strings of Boolean logic having, for instance, one or more parenthetical expressions in compound or nested arrangements involving mixed or dissimilar functions or operators, while (ii) generating an ordered sequence of distinct Boolean logic elements in accordance with the execution order. To these ends, the distinct logic elements are stored as objects disassociated and apart from the logic expressions from which they were generated.
In the exemplary case of converting the ladder logic of
The remaining blocks shown in
With reference now to
In the event that a coil is present in the current row, a block 70 determines whether the coil is compressible. Generally speaking, the block 70 evaluates adjacent cells in both the current row and an adjacent row to perform this evaluation. Ladder logic in an adjacent rung may be relevant if, for instance, an OR function is present that connects the adjacent rungs. In this exemplary embodiment, compressibility is determined by evaluating whether two conditions are met, namely (i) whether a pass-through or line is present without an OR function in the cell in the previous column (e.g., the next column to the left) of the current row, and (ii) whether the current row is the last row in the ladder, or whether the cell in the next row and previous column does not have an OR function. If both conditions are met, then the current coil is compressible.
If the coil is not compressible, control returns to the block 66. If the coil is compressible, control passes to a block 72 that moves or shifts the coil in the current cell into the previous column. A block 74 then decrements the current column such that the routine can proceed to evaluate whether the coil can be further compressed. If a block 76 determines that the current column is now the left-most column in the ladder, then no further compression is possible, and control returns to the block 66 to see if any further rows are present. If the current cell is not in the first column, then control returns to either the block 64 to determine whether further compression can occur within the current row. Because the coil has just been shifted into the current column, the block 64 will pass control to the block 70 for another compressibility evaluation.
After the coil compression routine has progressed through the entire ladder, then the ladder is ready for processing by the remainder of the conversion routine. More generally, the ladder may be modified in any manner in preparation for conversion. Modifications may be necessitated by the ladder logic rules or conventions for execution, such as an execution order, or for any other reason, as desired.
Referring now to
Each stage of the evaluation and processing is implemented by one or more routines or subroutines that evaluates and processes the ladder logic elements encountered. The processing portion of each stage includes collecting Boolean representations of the ladder logic elements in the respective logic expressions for each ladder rung. In one embodiment, such collection, in turn, involves sequentially modifying each logic expression to represent the current state of the evaluation of each rung of the ladder. In this way, the logic conversion routine proceeds through the ladder in the execution order, sequentially updating the respective logic expression for the row of the cell being processed to reflect the logic element(s) encountered. As set forth above, the block 54 (
The first processing stage involves a block 78 that evaluates the current cell for rungs (i.e., a pass-through or a line), contacts, and coils. Even though the logic presented by these elements warrants different conversion processing, each of these ladder logic elements are single-rung elements, insofar as they are disposed completely within a row or rung such that the cells in which they are disposed do not present a connection with any other row or rung. When a contact is encountered, the block 78 collects the contact by modifying the logic expression for the current rung to reflect the contact through a combination of the contact with the logic expression. Because, in this embodiment, the logic expression is a textual string expressing the logic in Boolean form, this combination may result in the addition of text to the string, or one or more replacements of text within the string, where a Boolean gate or element may be substituted for the logic function that they represent, as will be explained in detail below. Generally speaking, however, the value of the logic expression may be substituted or resolved when the EXPi string contains a complex object, such as “A1 AND B2.” Such complex objects are in contrast to non-complex logic expressions having only one logic element term, as in when EXPi=TRUE or EXPi=A1. Resolving the string includes, in one embodiment, building a Boolean gate or element in accordance with the logic set forth in the expression. As an example, the gate could be represented by the identification symbol, C, and C could be set equal to the logic function, “A1 AND B2”. In such cases, the new identification symbol, i.e., the Boolean element C, created as a result of the evaluation is then inserted back into the expression, replacing the portion of the expression of which it is now representative and thereby enabling the collection and incorporation of the new contact into the logic expression.
Resolving a Boolean element from the logic expression may involve or include any act by the conversion routine that forms, determines, or generates a Boolean element from the information set forth in the logic expression. An identification symbol for the new Boolean element is then assigned and used to set forth a modified logic expression. In other words, a representation of the Boolean element, the new identification symbol, is re-inserted into the logic expression from which the Boolean element was resolved. The logic expression has thus been updated and simplified, and a complex element, such as “A1 AND B2,” has been replaced by the new identification symbol of the resolved Boolean element, a non-complex element (e.g., C) defined as equal to the previous complex element, i.e., A1 AND B2.
After the current cell has been processed by the block 78, a block 80 determines whether the last row in the column has been reached. If not, a block 82 increments the current row and returns control to the block 78 for collection and processing of the next cell within the current column. Once all of the cells within a column have been processed, the block 80 passes control to a block 84 that resets the current row to the first row in preparation for the next processing stage.
The second stage of processing is implemented in a block 86, and is directed to evaluating the current cell for special function blocks. The collection and processing routine of the block 86 also may result in the modification of the logic expression for the rung in which the current cell is disposed, which may, in turn, result in one or more Boolean logic elements or gates being resolved from the EXPi string for the current cell. Such steps taken here in connection with special functions may, nevertheless, utilize procedures or routines used by other processing stages. For example, multiple processing stages may call the same procedure for resolving a Boolean logic element from the current EXPi string. Further detail regarding the processing of special functions is presented below in connection with an exemplary ladder logic convention.
After the current cell has been evaluated and processed for special functions, a pair of blocks 88 and 90 implement the same loop as the blocks 80 and 82 in order to process each of the cells within the current column. In fact, the blocks 88 and 90 may involve the same routine or subroutine as the blocks 80 and 82, and are shown separately only for ease in illustration. In similar fashion to the block 84, a block 92 resets the current row to the first row in preparation for the next processing stage once processing of the current column is complete.
Next, a block 94 implements an evaluation and subsequently processes the logic for OR functions associated with the current cell. The manner in which OR functions are processed may depend upon the ladder logic rules or conventions governing OR functions. For example, the current cell might be implicated by an OR function without having the OR function formally said to be contained within the cell. Stated differently, in the exemplary ladder logic system described above in which cells have attributes, a cell may be implicated by an OR function without having its OR attribute set equal to TRUE. Again, this situation is merely a matter of convention. In this case, the OR function may be disposed in the lower of the two cells joined by the OR function. However, regardless of how the ladder logic handles OR functions, the processing of OR functions in accordance with the disclosed technique generally results in a modification of the logic expressions of each ladder rung, or row, associated with, or connected by, the OR function. Further details regarding the processing of OR functions are set forth below in connection with the exemplary embodiment of
After the current cell has been processed for OR functions by the block 94, blocks 96 and 98 form a loop to support such processing of each cell within the current column and, to that end, may call the same procedure as the blocks 80 and 82. Once the last cell within the column is reached, however, control passes to the block 58 (see also
With reference now to
The single-rung element routine may continue in a block 102 that determines whether the current cell presents a pass-through or line, in which case control passes to a block 103 that maintains the current logic expression, or EXPi value. At this point, the single-rung routine may end because the cell will not have any other elements. Alternatively, and as shown in
If the EXPi string is complex, then a block 109 determines what type of operator or function is present. If the string contains one or more AND operators, then control passes to the block 108, where the collection of the contact appends another AND function and an identification of the contact variable as a new operand. If the string contains one or more OR operators, then a block 110 resolves a new Boolean element representative of the logic expressed via the one or more OR operators, substituting the symbol or other identification of the new Boolean element into the string in combination with the contact. An example of this process will be shown below in connection with Table I. In this manner, the conversion routine avoids the commingling or mixing of different Boolean operators, i.e., the creation of a logic expression where more than one type of operator or function is present in a logic expression. More generally, however, collection and processing of contacts involves updating the EXPi string by adding and/or replacing text to reflect the effect of the contact operation.
An example of the procedure executed in the blocks 107-119 for updating the logic expression is set forth below in Table I, in which logic variables and Boolean elements are identified by exemplary point names. To distinguish between the different point names involved, the point name X refers to the variable introduced by the newly encountered logic element, a contact. When a new Boolean element or gate is resolved as a result of the combination, then the new element is identified via a new, unique name, in this example, Y. Also, references to the logic expression “A1 AND B2” should be understood to refer to any string having one or more AND operators. Similarly, references to the logic expression “A2 OR B1” should be understood to refer to any string having one or more OR operators. The “Combination Type” column of Table I is established by the nature of the ladder logic encountered and, more specifically, indicates the context for the combination of the contact X, i.e., whether the contact X is being combined via an AND or an OR function. The manner in which combinations occur based on an OR function will be described further below. The “Resolve” column indicates whether a new Boolean element is resolved as a result of the combination, resulting in a substitution of the new, unique element, Y.
Table I shows that a new Boolean element or gate is not resolved in cases involving simple EXPi strings, i.e., the first six entries in the table. Only when a complex EXPi string is combined in a way that mixes AND and OR operators is a new Boolean element resolved. Otherwise, the complex EXPi string may remain a string having multiple AND operators, or multiple OR operators.
With continued reference to
The block 114 resolves a new Boolean element to avoid a combination of dissimilar or mixed Boolean functions in a logic expression, in this case, the combination of NOT and one of the functions, AND and OR.
Each time that a new Boolean element is resolved via execution of the blocks 110 or 114, information or data indicative or defining the new Boolean element is saved in a memory in the order in which they were created. In one embodiment, the information is recorded in the next step taken by the conversion routine. Alternatively, the information is recorded at a later time but in a manner that preserves the order in which the Boolean element was resolved (relative to other resolved Boolean elements). For instance, the recordation of the resolved Boolean element may occur at the point that the next Boolean element is to be created. In any event, storing the Boolean elements in the order in which they were resolved is a way of preserving the execution order of the ladder logic, which is based on the manner in which the disclosed logic conversion technique sequentially processes the ladder logic. To this end, the memory in which the Boolean elements are stored may be one-dimensional, or a vector, in the sense that the elements are stored in a one-dimensional sequence or order. It should be noted, however, that the information related to the Boolean element (e.g., MAKE NOTIN, IN1=D1, OUT=MIG-DX-0000) may be stored in multiple components (e.g., TYPE, IN, OUT, etc.) rather than as a single, integrated instruction. It should also be noted that the memory in which the Boolean elements are stored may, but need not, be any one or more of the memories within the process control system 10, such as one of the memories 27, and may or may not constitute the same memory in which any other routine or information associated with the conversion is stored.
Once each new Boolean element is stored in the vector or other memory, the single-rung element processing routine may end (as shown in
With continued reference to the processing of coil elements as shown in
The evaluation and processing steps set forth in connection with the exemplary embodiment of
In the example shown in
The components of the special function are arranged in accordance with the cell attribute, SHAPE, where the beginning or start of the special function has a SHAPE=TOP, and then the last cell or end of the special function has a SHAPE=BOT. Therefore, the upper cell of the special function 40 has a TOP shape, while the lower cell has a BOT shape. Cells in between the start and end of the special function may have another SHAPE value, such as MID. In this way, the conversion routine “remembers” that it is still in the midst of processing a special function when it moves to the next vertically adjacent cell, despite having proceeded as if the cell was any other cell (by executing, for instance, the routine of
The evaluation and processing of special functions will now be set forth in greater detail in connection with the exemplary embodiment of
Cells associated with special functions may have a number of attributes only used in connection with special functions. The attributes INUB and ONUB are TRUE or FALSE depending on whether the cell has an input or an output, respectively. The NUMBER attribute may be used to identify the number of the cell in the special function (e.g., the first cell having NUMBER set equal to 1), which may be used in identifying special function parameters by cell number. In the example of
Generally speaking, the values of the foregoing attributes will define one or more parameters of each cell of the special function. During the evaluation of a special function, the disclosed conversion technique processes the special function by sequentially processing the parameters of each cell in accordance with the nature of the special function. Evaluation and processing of the parameters provides the foundation for mapping, or translating, the special function from the ladder logic configuration scheme to the Boolean logic scheme.
Eventually, control passes to a decision block 144 that determines whether the current cell has an output by analyzing the ONUB parameter. If ONUB is TRUE, then a block 146 that creates a unique, point name for this output, applies the name to the output for the cell (defining the output as equal to the name), and stores this association in the EXPi string, replacing any prior text in the string. If the cell does not have an output cell, a block 148 stores FALSE in the EXPi string.
Control then passes to a block 150 that processes any other (i.e., non-input, non-output) special function parameters in each cell. Other parameters may define aspects of the special function. For instance, if the special function is a timer, then a parameter that may be defined in one of the cells of the special function is the constant that establishes how long the timer counts. The block 150 notes this time constant, and saves it to help define the special function in the Boolean logic scheme. The value may be saved in association with the cell number, as explained above.
Control then passes to a decision block 152 that determines whether the last cell in the special function has been reached by analyzing the SHAPE attribute. If the current cell does not have a SHAPE of BOT, then control returns to a block 154 that proceeds to the next vertically adjacent cell within the special function, and control returns to the block 140 for another iteration of processing of the special function. If the current cell has a SHAPE of BOT, then control passes to a block 156 that translates the special function into the corresponding function utilized in the Boolean logic scheme into which the routine is being converted. In some cases, this function may have the same name, parameters, and other characteristics as the ladder logic function. In other cases, the function may have different characteristics, but in either case, the block 156 may utilize a look-up table or other mapping information to identify the corresponding special function and transfer the special function parameters from the ladder logic scheme to the target scheme appropriately.
After the special function has been translated, a block 158 stores the special function and any parameter definitions in the vector or other memory that lists each of the logic elements generated by the disclosed conversion technique. Further processing of cells within the same column as the recently translated special function may then occur, with this stage of the routine generally evaluating the cells to determine whether to implement the steps shown in
After scanning each cell in the current column for special functions, control passes to the final processing stage, which implements an OR function processing routine, an exemplary embodiment of which is shown in
Two or more OR functions may be used in combination, in which case the EXPi strings of three or more rungs may be combined. Due to this possibility, the OR evaluation and processing routine may be a recursive procedure that processes one or more OR functions to make each of the necessary combinations. In the above-referenced embodiment where the OR function is present in the lower cell of the two connected cells, execution of the recursive procedure may be initiated when the current cell being evaluated does not have an OR function. Despite not having an OR function in the cell, the OR routine may be relevant because the cell below may have the OR function, thereby connecting the two adjacent rungs and implicating the current cell.
The OR function processing routine generally uses a temporary parameter to collect the logic expressions of each ladder rung connected by the OR function. This collection may involve combinations of logic elements, and such combinations are conducted in accordance with the disclosure in Table I hereof. For instance, when two logic expressions are combined as a result of an OR function, the combination type is “OR” and the fourth column of Table I may be consulted (e.g., consulted via a look-up table in a memory) to determine the manner in which they should be combined.
With reference now to the exemplary embodiment shown in
If the current cell is not empty, then a decision block 162 determines whether there is an OR function present in the cell. If an OR function is present, then the routine may also end, because the cells and rungs associated with that OR function will have already been processed by the recursive procedure to be described below.
If the current cell is not empty and does not contain an OR function, then a block 164 initializes a temporary string parameter, TEMP, in preparation for execution of the recursive procedure. More particularly, the initialization sets the TEMP parameter equal to the value set forth in the EXPi string for the rung in which the current cell is disposed. The recursive procedure is then called in a block 166 with TEMP, i.e., the EXPi string of the current rung, as an input parameter. This call of the recursive procedure returns the combined EXPi string generated as a result of the combinations established by the OR function. As a result, the returned result becomes (i.e., is stored as) the EXPi string for the current rung.
When an OR function is present in the cell below the current cell, then the two rungs are connected by an OR function, and the combination of the two strings, EXPi and EXPi+1, is performed in a block 172. More specifically, the combination involves the TEMP parameter and the EXPi+1 string. Further details regarding this combination will be set forth below in connection with
Next, a block 174 establishes the recursive nature of the procedure shown in
This recursion continues until either the last row is reached (see block 168), or an OR function is not encountered in the cell below the current cell (see block 170). In either case, control may pass to a block 176 that resolves a Boolean element from the TEMP parameter.
Each layer of execution of the recursive procedure ends with the TEMP parameter being written back into the current EXPi string for the procedure call (see the block 178). In this manner, each one of the strings eventually is assigned the value of the TEMP parameter.
The processing steps implemented by the block 172 to perform an OR combination will now be described in greater detail in connection with
Otherwise, control passes to a decision block 186 to determine whether the EXPi+1 string needs to be resolved (i.e., whether a Boolean element needs to be resolved from the string). If the EXPi+1 string has an AND operator, then control passes to a block 188 that resolves the string, stores the newly created Boolean element in the vector or other memory, and sets the TEMP parameter to the newly created output from the resolved logic. If the EXPi+1 string does not have an AND operator, a decision block 190 determines whether the EXPi+1 string is currently set to FALSE, in which case the TEMP parameter is unmodified by the string, and the routine ends. Alternatively, if a decision block 192 determines that the EXPi+1 string is currently set to TRUE, then control passes to a block 194 that sets the TEMP parameter to TRUE as a result of the OR combination.
If the EXPi+1 string is not set to TRUE, then control passes to a decision block 196 to determine whether the TEMP parameter has an AND operator and, therefore, needs to be resolved in preparation for an OR combination. If so, a block 198 resolves the TEMP parameter, thereby creating a new Boolean element, data representative of which is stored in the vector or memory, and sets the TEMP parameter to the newly created output from the resolved logic. After the TEMP parameter has been resolved, a block 200 performs the OR combination by setting TEMP equal to the logic expression having TEMP and EXPi+1 separated by an OR operator.
To provide an example of the processing steps taken by the disclosed conversion routine, the processing of the exemplary ladder logic of
After the coil compression processing, the conversion routine begins to process the ladder cell-by-cell in sequential fashion according to the execution order, and therefore starts with the cell and column having the contact 36A. To continue with the example, the following point names are associated with the contacts and coils shown in
The EXP strings will be identified by row number, starting with row 0, and are initialized to the value, TRUE. The conversion routine begins the three stages of collection and processing with the routine shown in
As shown in
The routine proceeds to the second column as a result of reaching the blocks 58 and 60 of
The conversion routine continues with the third column, where the first stage of processing retains the value of the logic expression of the first rung before encountering the normally closed contact 36D in the second row. Until this point, modifications of the logic expressions have occurred, but no Boolean logic elements have been resolved from the logic expressions. The first Boolean logic element resolved and recorded, a NOT gate, is necessitated by the normally closed aspect of the contact 36D. Specifically, the block 114 resolves or generates a NOT gate, storing its definition in the first position of the vector or memory as the first object in the Boolean logic output. The NOT gate may be defined via storage of information, such as the string “MAKE NOTIN, IN1=D, OUT=MIG-DX-0001”. After the NOT gate is resolved, the operation of the blocks 107 and 108 cause the EXP2 string to be modified to reflect the collection of the contact 36D. Specifically, the EXP2 string becomes the string “B1 AND MIG-DX-0001”. With no other contacts or coils in the third column, the routine proceeds to the second processing stage.
In the second stage, the routine next encounters the special function 40, where the block 140 (
The routine then proceeds to the third processing stage, where the first OR function of the exemplary ladder is encountered. The first cell of the third column has a line, but with a connection to an OR function in the cell below, which is uncovered by the block 170 (
The fourth column contains the coils 38A and 38D as a result of coil compression. As a result, the conversion routine next encounters the coil 38A, and the block 128 resolves an OR function from the EXP0 string, such that the following is stored as the next resultant Boolean element: MAKE OR8, IN1=MIG-DX-0004, OUT=C. Subsequently, the coil 38D is processed such that the MAKE OR8, IN1=MIG-DX-0002, OUT=E, and the routine has resolved its final Boolean element.
The results of the routine conversion are shown below, where the order of execution begins with the first (or top) MAKE command, and continues through the remainder of the commands to generate each of the portions of the resultant Boolean logic routine.
Embodiments of the disclosed system and method may be implemented in hardware or software, or a combination of both. Some embodiments may be implemented as computer programs executing on programmable systems comprising at least one processor, a data storage system (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Program code may be applied to input data to perform the functions described herein and generate output information. The output information may be applied to one or more output devices, in known fashion. For purposes of this application, a processing system includes any system that has a processor, such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
The programs may be implemented in a high level procedural or object oriented programming language to communicate with a processing system. The programs may also be implemented in assembly or machine language, if desired. In fact, practice of the disclosed system and method is not limited to any particular programming language. In any case, the language may be a compiled or interpreted language.
The programs may be stored as one or more sets of instructions, whether or not compiled, on a storage media or device (e.g., floppy disk drive, read only memory (ROM), CD-ROM device, flash memory device, digital versatile disk (DVD), or other storage device) readable by a general or special purpose programmable processing system, for configuring and operating the processing system when the storage media or device is read by the processing system to perform the procedures described herein. Embodiments of the disclosed system and method may also be considered to be implemented as a machine-readable storage medium, configured for use with a processing system, where the storage medium so configured causes the processing system to operate in a specific and predefined manner to perform the functions described herein.
When implemented in software, the routines described herein may be stored in any computer readable memory such as on a magnetic disk, a laser disk, an optical disk, or other storage medium, in a RAM or ROM of a computer or processor, etc. Likewise, this software may be delivered to a user-or to a process control system via any known or desired delivery method including, for example, on a computer-readable disk or other transportable computer storage mechanism or modulated over a communication channel such as a telephone line, the internet, etc. (which is viewed as being the same as or interchangeable with providing such software via a transportable storage medium).
The foregoing description is given for clearness of understanding only, and no unnecessary limitations should be understood therefrom, as modifications within the scope of the invention may be apparent to those having ordinary skill in the art.