CN117827693A - Batch access method and device for programmable logic controller addresses - Google Patents

Batch access method and device for programmable logic controller addresses Download PDF

Info

Publication number
CN117827693A
CN117827693A CN202311867637.6A CN202311867637A CN117827693A CN 117827693 A CN117827693 A CN 117827693A CN 202311867637 A CN202311867637 A CN 202311867637A CN 117827693 A CN117827693 A CN 117827693A
Authority
CN
China
Prior art keywords
variable
address
target
statement
plc
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311867637.6A
Other languages
Chinese (zh)
Inventor
唐为军
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Kyland Technology Co Ltd
Original Assignee
Kyland Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Kyland Technology Co Ltd filed Critical Kyland Technology Co Ltd
Priority to CN202311867637.6A priority Critical patent/CN117827693A/en
Publication of CN117827693A publication Critical patent/CN117827693A/en
Pending legal-status Critical Current

Links

Landscapes

  • Programmable Controllers (AREA)

Abstract

The application discloses a batch access method and device for addresses of programmable logic controllers, and belongs to the technical field of computers. The access method of the programmable logic controller address comprises the following steps: acquiring an address expression in a target PLC statement; the address expression represents a target PLC address through an array subscript; the target PLC addresses are a batch of PLC addresses; and accessing the target PLC address based on the array subscript. According to the batch access method and device for the programmable logic controller address, compared with the mode of accessing the address of the appointed position based on the semantics of the pointer variable, the method and device are simpler and more convenient, the access to the PLC address is safer, and the convenience and safety of the batch access of the PLC address can be improved.

Description

Batch access method and device for programmable logic controller addresses
Technical Field
The application belongs to the technical field of computers, and particularly relates to a batch access method and device for addresses of programmable logic controllers.
Background
The specification of direct access to the memory address of a programmable logic controller (Programmable Logic Controller, PLC) is specified in the IEC61131-3 programming language standard, and the corresponding entry of the address in the PLC instruction is "direct representation variable (%)". The PLC method specified by the above standard is a direct access address method.
For the scenario requiring batch access to PLC addresses, this is achieved by changing the address to which the variable points. The variables are usually pointer variables, but the semantic implementation of the pointer variables is relatively complex, the use of the pointer variables has high requirements on programmers, the writing amount of codes is large, and the execution of PLC instructions accessing PLC addresses based on the pointer variables has potential safety hazards.
Therefore, the current access of the PLC address is complicated in process and inconvenient to use for a batch access scene.
Disclosure of Invention
The present application aims to solve at least one of the technical problems existing in the prior art. Therefore, the application provides the access method and the device for the programmable logic controller address, which can simply and conveniently access the batch PLC addresses.
In a first aspect, the present application provides a method for accessing addresses of a programmable logic controller in batches, where the method includes:
acquiring an address expression in a target PLC statement; the address expression is used for representing a target PLC address; the address expression is an expression containing an array subscript and directly representing a variable; the target PLC address comprises a plurality of PLC addresses;
and accessing the target PLC address based on the array subscript.
According to the batch access method of the programmable logic controller address, compared with the mode of accessing the address of the appointed position based on the semantics of the pointer variable, the batch access method of the programmable logic controller address is simpler and more convenient, the access to the PLC address is safer, and the convenience and the safety of the batch access of the PLC address can be improved.
According to one embodiment of the present application, accessing the target PLC address based on the array index includes:
determining the value of the array subscript based on the assignment statement of the variable under the condition that the array subscript contains the variable;
determining the target PLC address based on the value of the array subscript;
and accessing the target PLC address.
According to one embodiment of the present application, where the array subscript includes a variable, determining the value of the array subscript based on an assignment statement of the variable includes:
determining the value of the variable based on the assignment statement of the variable under the condition that the index of any dimension in the array index is the variable;
and determining the value of the array subscript based on the value of the variable.
According to one embodiment of the present application, where the array subscript includes a variable, determining the value of the array subscript based on an assignment statement of the variable includes:
under the condition that the index of any one dimension in the array index is an operation expression, acquiring an operation result of the operation expression based on an assignment statement of each variable contained in the operation expression;
and determining the value of the array subscript based on the operation result.
According to one embodiment of the present application, the assignment statement is a statement for assigning a plurality of values; alternatively, the assignment statement includes a statement for assigning an initial value and a statement for performing a self operation.
According to one embodiment of the present application, the assignment statement of at least one of the variables is a statement for assigning a plurality of values; or the assignment statement of at least one of the variables includes a statement for assigning an initial value and a statement for performing a self-operation.
According to one embodiment of the application, the target PLC sentence is used to illuminate a target light; the address of the target lamp is the target PLC address; the subscript of any one dimension in the array subscript is a first variable; the first variable is a circulation control variable;
The accessing the target PLC address based on the array subscript includes:
and executing the target PLC statement, accessing the target PLC address through the circulation of the first variable, and turning on the target lamp.
According to one embodiment of the application, the target PLC sentence is used to illuminate a target light; the address of the target lamp is the target PLC address; the array subscripts comprise a first array subscript and a second array subscript; the subscript of the target dimension in the first array subscript is an operation expression comprising a second variable and a third variable; the subscript of the target dimension in the second plurality of subscripts is an operation expression comprising the second variable and a fourth variable; the second variable is a circulation control variable;
the accessing the target PLC address based on the array subscript includes:
executing the target PLC statement, accessing a first address in the target PLC address based on the second variable and the third variable through the loop of the second variable, illuminating a first part in the target lamp, and accessing a second address in the target PLC address based on the second variable and the third variable, illuminating a second part in the target lamp; the target lamp is composed of the first portion and the second portion.
In a second aspect, the present application provides a batch access device for addresses of programmable logic controllers, the device comprising:
the acquisition module is used for acquiring the address expression in the target PLC statement; the address expression is used for representing a target PLC address; the address expression is an expression containing an array subscript and directly representing a variable; the target PLC address comprises a plurality of PLC addresses;
and the access module is used for accessing the target PLC address based on the array subscript.
According to the access device of the programmable logic controller address, compared with the mode of accessing the address of the appointed position based on the semantics of the pointer variable, the access device of the programmable logic controller address is simpler and more convenient, the access to the PLC address is safer, and the convenience and the safety of the PLC address batch access can be improved.
In a third aspect, the present application provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor implements the method for accessing addresses of a programmable logic controller according to the first aspect when the computer program is executed.
In a fourth aspect, the present application provides a non-transitory computer readable storage medium having stored thereon a computer program which, when executed by a processor, implements a method of bulk access of programmable logic controller addresses as described in the first aspect above.
In a fifth aspect, the present application provides a chip, the chip including a processor and a communication interface, the communication interface being coupled to the processor, the processor being configured to execute a program or instructions to implement the method for batch access of addresses of programmable logic controllers according to the first aspect.
In a sixth aspect, the present application provides a computer program product comprising a computer program which when executed by a processor implements a method of batch access of programmable logic controller addresses as described in the first aspect above.
Additional aspects and advantages of the application will be set forth in part in the description which follows, and in part will be obvious from the description, or may be learned by practice of the application.
Drawings
The foregoing and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings, wherein:
FIG. 1 is a flow chart of a method for batch access of programmable logic controller addresses provided in an embodiment of the present application;
FIG. 2 is a schematic diagram of an application scenario of a method for accessing addresses of programmable logic controllers in batch according to an embodiment of the present application;
FIG. 3 is a schematic diagram of a device for accessing addresses of programmable logic controllers in a batch manner according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Technical solutions in the embodiments of the present application will be clearly described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments in the present application are within the scope of the protection of the present application.
The terms first, second and the like in the description and in the claims, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the data so used may be interchanged, as appropriate, such that embodiments of the present application may be implemented in sequences other than those illustrated or described herein, and that the objects identified by "first," "second," etc. are generally of a type and not limited to the number of objects, e.g., the first object may be one or more. Furthermore, in the description and claims, "and/or" means at least one of the connected objects, and the character "/", generally means that the associated object is an "or" relationship.
In the related art, the IEC61131-3 programming language standard specifies a specification for directly accessing a PLC address. The standard is as follows for the standard syntax form of the Direct Variable:
`%`(`I`|`Q`|`M`)(`X`|`B`|`W`|`D`|`L`)?Unsigned_Int(`.`Unsigned_Int)*。
wherein, the first part "%" in the regular expression is a character prefix; i, Q or M of the second part is used to indicate the type of address area; character "? "means that the third part is an optional part, i.e. the third part may be omitted; x, B, W, D and L of the third part are used to indicate the size of the address area; the fourth part is used for indicating a specific address; the character "×" indicates that the content in parentheses before the character may appear 0 times, 1 time or more, i.e., may not appear or appear 1 time or more.
According to the above regular expression, the following ways are legal:
% I0.0,% IX0,% IB5,% IW10,% ID20,% IL1,% ID20.1.1,% Q0.0,% QX0,% QB5,% MW10,% MD20,% ML1,% MD20.1.1, and the like.
The type of address area supports 3 types externally. Wherein I represents an input variable region; q represents an output variable region; m represents a memory area. The memory area refers to a memory area other than the input variable area and the output variable area.
The size of the address area supports 5 kinds. Wherein X represents a single bit (bit) bit (omitting the third part being equivalent to the third part being X), the data type being Boolean (BOOL); b represents BYTEs (8 bits), and the data type is BYTE; w represents a WORD (16 bits), and the data type is WORD; d represents a double word (32 bits), and the data type is DWORD; l represents a long word (64 bits) and the data type is LWORD.
The regular expression only comprises one un-registered_int, and the indicated address is a single-stage address; the indicated address is a multi-level address if the regular expression is "unagned_int". The unsigned_int refers to an Unsigned integer.
In the multi-level address, the left field unblocked_int is higher than the right field unblocked_int. The leftmost field, unlinked_int, represents the highest level of hierarchy, which decreases in turn until rightmost. The specific meaning of the multi-level address can be expanded in language by the implementer. According to the above standard, in the practical use of the PLC, it is practical to find a certain bit of one byte.
Accordingly, the addressing scheme supports 2 types: simple addressing and hierarchical addressing.
For example,% IW10 represents the 10 th byte position of the I-zone, which is addressed in a simple way. For another example,% QB7.5 is a hierarchical physical or logical address that is addressed in a hierarchical manner. % QB7.5 is expressed as the position of bit 5 of the 7 th byte of the Q field offset.
At present, basically all PLC programming software follows the standard grammar form to realize access to PLC addresses, and the meaning of the specific pointed address can be expanded by an implementer. In the mode, the user does not need to memorize variable names, so that programming has high convenience. This way the addresses can be accessed and operated directly as long as the specific meaning of the PLC address is clear.
The fourth part of the standard syntax form provides an unsigned constant, such as 100 or 10.1. The direct use of constants does not enable bulk access to PLC addresses. For the scenario that the PLC addresses need to be accessed in batches, variable pointing addresses are generally adopted, and then the purpose of directly operating one batch of addresses is achieved by changing the addresses pointed by the variable.
For example, for 16 output channels, a variable may be used to point to the address of each output channel, and then the output values of the addresses of the 16 output channels may be set in batch by cycling 16 times.
Typically, values at addresses are manipulated using variable-pointing addresses, and semantic implementation of pointer variables may be employed. However, the semantic implementation of the pointer variable is relatively complex, the pointer variable is difficult to use, potential safety hazards exist, and the safety is poor.
The method for accessing the address of the programmable logic controller, the device for accessing the address of the programmable logic controller, the electronic device and the readable storage medium provided by the embodiment of the application are described in detail below with reference to the accompanying drawings through specific embodiments and application scenes thereof.
The access method of the programmable logic controller address can be applied to the terminal, and can be executed by hardware or software in the terminal.
The terminal includes, but is not limited to, a portable communication device such as a mobile phone or tablet having a touch sensitive surface (e.g., a touch screen display and/or a touch pad). It should also be appreciated that in some embodiments, the terminal may not be a portable communication device, but rather a desktop computer having a touch-sensitive surface (e.g., a touch screen display and/or a touch pad).
In the following various embodiments, a terminal including a display and a touch sensitive surface is described. However, it should be understood that the terminal may include one or more other physical user interface devices such as a physical keyboard, mouse, and joystick.
The execution body of the method for accessing the programmable logic controller address provided in the embodiment of the present application may be an electronic device or a functional module or a functional entity in the electronic device, such as a PLC controller or an industrial server, capable of implementing the method for accessing the programmable logic controller address in batch, and the method for accessing the programmable logic controller address provided in the embodiment of the present application is described below by taking the electronic device as an execution body as an example.
As shown in fig. 1, the method for accessing addresses of the programmable logic controller in batches includes: step 110 and step 120.
Step 110, obtaining an address expression in a target PLC statement; the address expression is used for representing the target PLC address; an address expression is an expression that contains array subscripts that directly represent variables; the target PLC address includes a plurality of PLC addresses.
In practical implementation, the embodiment of the application expands on the basis of the standard grammar form of the direct expression variable, and the expanded grammar form is as follows:
`%`(`I`|`Q`|`M`)(`X`|`B`|`W`|`D`|`L`)?[Expression(`,`Expression)*]。
wherein the first, second, and third portions of the regular expression, and the character "? The meaning of the "and the character". X "is the same as the standard grammar form, and the fourth part is changed into a grammar for accessing the PLC address by adopting the array subscript.
The fourth part of the extended syntax form of the direct representation variable is an array. Wherein the elements within "[ ]" are subscripts to the array (referred to as "array subscripts"). The array subscript may be a constant, a variable, or any operational expression whose evaluation result is an unsigned integer. The fourth section, "" is a set of dimension spacers, which have the same meaning in regular expressions as ".", in the standard syntax form described above. The dimensions of the array correspond to each of the stages of the multi-stage address, respectively.
It is understood that the array subscript may be a subscript of a multidimensional array, and the subscript of each dimension in the array subscript corresponds to the dimension of the multidimensional array one by one.
It will be appreciated that hierarchical addressing may be implemented where the array subscripts are those of a multi-dimensional array; in case the array subscript is a one-dimensional array subscript, simple addressing can be achieved.
Through the expansion, the purposes of accessing addresses of the designated positions of the operation variables based on the semantics of the array can be realized.
In the PLC field, compared with pointer variables, the semantic realization of the array is very simple, and the requirement of using the array on programmers is very low, so that the programmers familiar with the grammar form of the direct expression variables can easily master the grammar form of the extended direct expression variables.
The target PLC statement is a statement in a section of PLC source code. In compiling the target PLC sentence, it is determined whether or not there is a syntax expression in the target PLC sentence that conforms to the syntax form of the above-described extended direct representation variable by syntax analysis. Where present, the grammar expression in the target PLC statement can be extracted.
The grammar expression conforming to the above-described extended grammar form of the direct representation variable is an address expression. The address expression is used to represent a regular expression of the PLC address.
It will be appreciated that address expressions in the form of grammatical representations of the extended direct representation variables described above, including array indices, are complied with. An address expression conforming to the above-described extended syntax form of directly representing variables represents a batch of PLC addresses by using array subscripts. The set of PLC addresses is the target address to be accessed. The collection of PLC addresses includes a plurality of PLC addresses.
Step 120, accessing the target PLC address based on the array subscript.
In actual execution, after extracting the address expression, determining the target PLC address represented by the group subscript in the address expression based on the grammar form of the extended direct representation variable; after the target PLC address is determined, direct access and operation to the target PLC address may be performed.
According to the batch access method for the programmable logic controller address, compared with the mode of accessing the address of the appointed position based on the semantics of the pointer variable, the batch access method for the programmable logic controller address is simpler and more convenient, the access to the PLC address is safer, and the convenience and the safety of the batch access of the PLC address can be improved.
In some embodiments, accessing the target PLC address based on the array index includes: and determining the value of the array subscript based on the assignment statement of the variable under the condition that the array subscript contains the variable.
In actual implementations, the array subscript in the address expression described above may contain one or more constants to represent a collection of PLC addresses. Alternatively, the array subscript in the address expression may also contain at least one variable to represent a collection of PLC addresses.
The array subscript containing at least one variable may include the following forms: the subscript of any one dimension in the array subscript is a variable, and the subscript of any one dimension in the array subscript is an operation expression containing at least one variable, etc.
In the case where the array subscript is a one-dimensional array subscript, there is only one dimension of the subscript, which may be a variable or an operational expression containing at least one variable. For example, the array subscript of one-dimensional array [ a ] is variable a; alternatively, the array subscript of the one-dimensional array [ a+1] is the operational expression (a+1) containing the variable a.
In the case where the array subscript is a subscript of a multi-dimensional array, the subscript of any one dimension of the array subscript is a variable and the subscript of any one dimension of the array subscript is an operational expression containing at least one variable. For example, the subscript of the first dimension in the array subscript of the two-dimensional array [0, b ] is constant 0, and the subscript of the second dimension is variable b; alternatively, the subscript of the first dimension in the array subscript of the three-dimensional array [ a+b+3,2, c ] is the operational expression a+b+3 comprising the variable a and the variable b, the subscript of the second dimension is the constant 2, and the subscript of the third dimension is the variable c.
In the case where the array index in the address expression contains a variable, one value of the variable may correspond to the value of one array index. Based on the assignment statement of the variable, all values of the variable can be obtained; after all values of the variables are obtained, the values of the array subscripts can be determined.
And determining the target PLC address based on the value of the array subscript.
In actual execution, the values of the array subscripts are in one-to-one correspondence with the PLC addresses. Based on the value of the array subscript, the PLC address indicated by the value can be obtained, so that the target PLC address can be determined.
The target PLC address is accessed.
In an actual implementation, after determining the target PLC address, the target PLC address may be directly accessed and may be manipulated based on the manner in which the direct representation variable is accessed.
According to the batch access method for the programmable logic controller address, the address of the position is appointed by the variable based on the semantic access of the array, the value of the index of the array is determined based on the assignment statement of the variable under the condition that the index of the array contains the variable, the target PLC address is determined based on the value of the index of the array, and the target PLC address is accessed, so that convenience and safety of batch access of the PLC address can be improved.
In some embodiments, where the array index contains a variable, determining the value of the array index based on the assignment statement for the variable includes: and under the condition that the index of any one dimension in the array index is a variable, determining the value of the variable based on the assignment statement of the variable.
In actual execution, for any dimension index in the array index, when the dimension index is a variable, the assignment statement of the variable can be determined according to the semantic analysis result of each PLC statement in the code block to which the target PLC statement belongs in the compiling process. After determining the assignment statement of the variable, the value of the variable may be determined according to the assignment statement of the variable.
For example, the assignment statement at variable a is "a: =0to7; in the case of "the variable a may be determined to have 8 values such as 0to 7.
And determining the value of the array subscript based on the value of the variable.
In an actual implementation, after determining the value of a variable, the value of a subscript that contains one dimension of the variable may be determined. After determining the values of the index of all dimensions of the array index, all values of the array index may be determined.
According to the batch access method for the programmable logic controller address, the value of the variable is determined through the assignment statement based on the variable, and the value of the array subscript is determined based on the value of the variable, so that the address of the appointed position of the variable can be accessed based on the semantics of the array, and the convenience and the safety of the batch access of the PLC address can be improved.
In some embodiments, the assignment statement is a statement for assigning a plurality of values; alternatively, the assignment statement includes a statement for assigning an initial value and a statement for performing a self operation.
In actual execution, the assignment statement of each variable may be a single statement or may include multiple statements.
In the case where the target PLC address includes a plurality of PLC addresses, the assignment statement of the above-mentioned variable may be a single statement for assigning a plurality of values. For example, the assignment statement "a: =0to7; "is a single statement for assigning multiple values. For another example, the assignment statement "b: =15, 16,17; "also a single statement for assigning a plurality of values, 3 values such as 15,16, and 17 can be assigned to the variable b by the assignment statement.
In the case where the target PLC address includes a plurality of PLC addresses, the assignment statement of the variable may include a plurality of statements. The plurality of sentences may include sentences for assigning initial values and sentences for performing self-operations. In the case of performing the self-operation based on the initial value, the number of initial values is generally one. For example, an assignment statement may include the statement "a: =15; "sum statement" a: =a-1; ", statement" a: =15; "is a statement for assigning an initial value to variable a, statement" a: =a-1; "is a sentence for performing a self-subtraction operation of the variable a. For another example, the assignment statement may include the statement "b: =1; the "sum statement" b =b+3; ", statement" b: =1; "is a statement for giving an initial value to the variable b," b: =b+3 "is a statement for performing a self-addition operation of the variable b.
All values of the variable can be obtained based on the statement for giving the initial value and the statement for performing the self-operation, and the values of the variable are limited by the data type of the variable.
In some embodiments, where the assignment statement for a variable includes a statement for assigning an initial value and a statement for performing a self-operation, the value of the variable may be determined based on the loop condition in the loop statement and the assignment statement for the variable to avoid accessing an invalid PLC address and accessing an error. The loop sentence is a loop sentence in a code block to which the target PLC sentence belongs.
For example, the loop condition is "a >10", combined with the assignment statement "a: =15; "and" a: =a-1; by way of example, variable a may be assigned 5 values of 15, 14, 13, 12, 11, etc. For another example, the loop condition is "b <32", combined with the assignment statement "b: =1; "and" b =b+3; by way of example, variable b may be given 11 values of 1, 4, 7, …, 31, etc.
According to the batch access method for the programmable logic controller address, the variable is assigned through the statement for assigning a plurality of values, or the variable is assigned through the statement for assigning an initial value and the statement for performing self-operation, so that the variable can be assigned more flexibly.
In some embodiments, where the array index contains a variable, determining the value of the array index based on the assignment statement for the variable includes: and under the condition that the index of any one dimension in the array index is an operation expression, acquiring an operation result of the operation expression based on the assignment statement of each variable contained in the operation expression.
In actual execution, for any dimension index in the array index, when the dimension index is an operation expression containing variables, the value assignment statement of each variable contained in the operation expression can be determined according to the semantic analysis result of each PLC statement in the code block to which the target PLC statement belongs in the compiling process. After determining the assignment statement of each variable, the value of the variable can be determined according to the assignment statement of the variable. For the specific process of determining the value of the variable, reference may be made to the foregoing embodiments, and details are not repeated here.
After the values of all the variables contained in the operation expression are determined, the operation described by the operation expression can be performed based on the difference of the values of the variables, so that all operation results of the operation expression are obtained.
For example, the operation expression is "a-b", and after determining that the values of the variable a are 2, 4, and 6 and the values of the variable b are 0 and 1, the operation results are 1, 2, 3, 4, 5, and 6. For another example, the operation expression is "c/2", and in the case where the values of the variable c are determined to be 2, 4, 6, and 8, the operation results may be 1, 2, 3, and 4.
And determining the value of the array subscript based on the operation result.
In an actual implementation, after determining the operation result of the operation expression, the value of the index containing one dimension of the operation expression may be determined. After determining the values of the index of all dimensions of the array index, all values of the array index may be determined.
According to the batch access method for the programmable logic controller address, the operation result of the operation expression is obtained based on the assignment statement of each variable contained in the operation expression, and the value of the index of the array is determined based on the operation result of the operation expression, so that the address of the appointed position of the variable can be accessed based on the semantics of the array, and the convenience and the safety of the batch access of the PLC address can be improved.
In some embodiments, the assignment statement for at least one variable is a statement for assigning a plurality of values; or the assignment statement of at least one variable includes a statement for assigning an initial value and a statement for performing a self-operation.
In actual execution, the assignment statement of at least one variable included in the above-described operation expression may be a statement for assigning a plurality of values, or may include a statement for assigning an initial value and a statement for performing a self-operation. The assignment statement of any one of the other variables included in the above-described operation expression may be a statement for assigning an initial value or a statement for assigning a plurality of values, in addition to the variable; alternatively, a sentence for giving an initial value and a sentence for performing a self-operation are included.
According to the batch access method for the programmable logic controller address, the variables contained in the operation expression are assigned through the statement for assigning a plurality of values, or the variables contained in the operation expression are assigned through the statement for assigning an initial value and the statement for performing self-operation, so that the variables can be assigned more flexibly.
In order to facilitate understanding of the foregoing embodiments of the present application, a batch access method for addresses of programmable logic controllers provided in the foregoing embodiments of the present application is described below by way of an example.
Fig. 2 shows a scenario in which the lamps of 16 channels are controlled by a PLC. The direct representation variable forms of the PLC addresses of the 16 channels shown in fig. 2 are respectively%qb0 to%qb15, and the corresponding physical addresses are respectively 0x4000a000 to 0x4000a00F (expressed in 16 scale). The control target was to fully illuminate the 16 lamps.
The target PLC statement is used for lighting a target lamp; the address of the target lamp is the target PLC address.
It will be appreciated that for the scenario shown in fig. 2, the 16 lamps are target lamps, and the target PLC address is the address of the 16 lamps.
According to a standard grammar form in the related art, a PLC sentence for realizing the target Structured Text (ST) form is as follows:
“%QB0:=1;
%QB1:=1;
%QB15:=1;”。
according to the syntax form of the extended direct representation variable provided in the foregoing embodiment of the present application, the PLC sentence in ST form may be, but is not limited to, the following four cases.
In actual implementation, the first case corresponds to the case where the array subscript is constant. And changing each row corresponding to the PLC statement into an access mode of an array, wherein the index of the array is a corresponding constant. The code block includes the following target PLC statements:
“%QB[0]:=1;
%QB[1]:=1;
%QB[15]:=1”。
by sequentially executing each of the target PLC sentences, the address of each of the 16 lamps can be sequentially accessed, thereby sequentially lighting the 16 lamps, and realizing lighting all 16 lamps.
Subscripts of any one dimension in the array subscripts are used as first variables; the first variable is a loop control variable. Accessing the target PLC address based on the array subscript, comprising: and executing the target PLC statement, accessing the target PLC address through the cycle of the first variable, and lighting the target lamp.
In actual execution, the second case corresponds to the case where the array subscript is variable. The code block includes the following target PLC statements:
“FOR index:=0to15 BY 1DO
%QB[index]:=1;
END_FOR;”。
in this case, "% QB [ index ]:1; "can be a target PLC statement, the address expression is"% QB [ index ] ", and the array subscript is the variable index. The array subscript is the subscript of a one-dimensional array [ index ], and the subscript of the one-dimensional array is the first variable index. The first variable index is a loop control variable, which is loop controlled by the FOR.
Executing the target PLC statement, performing a loop of the first variable index, accessing all 16 lamp addresses through the loop of the first variable index, and lighting all 16 lamps through the grammar form of the% QB index loop to achieve the same effect.
It can be understood that, especially in the case that the target PLC address is a continuous memory, the array semantic cycle is adopted to perform batch PLC address access, the method is simple and clear, a large number of PLC sentences can be omitted, and the access to the PLC address is simpler, more convenient and safer.
The array subscripts comprise a first array subscript and a second array subscript; the subscript of the target dimension in the first array subscript is an operation expression comprising a second variable and a third variable; the subscript of the target dimension in the second plurality of subscripts is an operation expression comprising a second variable and a fourth variable; the second variable is a loop control variable. Accessing the target PLC address based on the array subscript, comprising: executing a target PLC sentence, accessing a first address in a target PLC address based on a second variable and a third variable through the circulation of the second variable, lighting a first part in the target lamp, accessing a second address in the target PLC address based on the second variable and the third variable, and lighting a second part in the target lamp; the target lamp is composed of a first portion and a second portion.
The third case corresponds to the case where the array subscript is an operational expression containing a variable. The code block includes the following PLC statements:
“index:=-1;
odd:=1;
oven:=2;
WHILE index<6DO
%QB[index+odd]:=1;
%QB[index+oven]:=1;
index:=index+2;
END_WHILE;”。
in this case, "% QB [ index+odd ]; "and"% QB [ index+over ]; "all can be target PLC statement, the corresponding address expressions are"% QB [ index+odd ] "and"% QB [ index+odd ] ", the array subscripts are the operation expression" index+odd "containing the variables index and odd, and the operation expression" index+odd "containing the variables index and odd, respectively. The assignment statement of the variable odd and the variable even are respectively statement "odd: =1 used for assigning initial values; sum: =2; ". The assignment statement of the variable index comprises a statement "index: = -1 for assigning an initial value; "and the statement for performing self-operation" index: =index+2; ".
The array subscripts comprise a first array subscript index+odd and a second array subscript index+over. The index of the first array index+odd and the index of the second array index+odd are the index of the one-dimensional array [ index+odd ] and the index of the one-dimensional array [ index+odd ] respectively. The first array index+odd is an operation expression constituted by the second variable index and the third variable odd, which represents adding the value of the second variable index and the value of the third variable odd. The second-group index+over is an operational expression constituted by the second variable index and the fourth variable over, which indicates that the value of the second variable index and the value of the fourth variable over are added. The second variable is a loop control variable, controlled by the WHILE loop.
Executing the target PLC statement, performing a loop of a second variable index, accessing addresses of 8 odd lamps in the 16 lamps through a syntax form of a% QB [ index+odd ] loop, turning on the 8 odd lamps, accessing addresses of 8 even lamps in the 16 lamps through a syntax form of a% QB [ index+odd ] loop, and turning on the 8 even lamps, thereby turning on all 16 lamps.
It will be appreciated that the 16 lamps described above may be divided into two parts: the 8 odd numbered lamps and the 8 even numbered lamps. The 8 odd numbered lamps are first portions of the target lamps, and the 8 even numbered lamps are second portions of the target lamps.
In practical implementations, the fourth case corresponds to the case where the array subscript is the subscript of a two-dimensional array. The code block includes the following PLC statements:
“FOR index:=0to15 BY 1DO
%Q[0,index]:=TRUE;
END_FOR;”。
in this case, instead of% Q0.0,% Q0, 0 is used to control the bits of bits 0-15 by cyclically varying the number of the second stage (i.e., the subscript of the second dimension).
It will be appreciated that the method of PLC access for multilevel addressing beyond two levels can be analogized to the fourth case.
By comparing the four situations with the related technologies, it can be known that when the target PLC address comprises a plurality of PLC addresses, especially a huge number of PLC addresses, the method is simpler and clearer by adopting the circulation of array semantics to access the batch of PLC addresses, a great number of PLC sentences can be omitted, and the access to the PLC addresses is simpler, more convenient and safer.
According to the batch access method for the programmable logic controller address, the execution body can be a batch access device for the programmable logic controller address. In the embodiment of the present application, a batch access device for a programmable logic controller address executes a batch access method for a programmable logic controller address as an example, and the batch access device for a programmable logic controller address provided in the embodiment of the present application is described.
The embodiment of the application also provides a batch access device for the addresses of the programmable logic controllers.
As shown in fig. 3, the batch access device for programmable logic controller addresses includes: an acquisition module 310 and an access module 320.
An obtaining module 310, configured to obtain an address expression in the target PLC sentence; the address expression is used for representing the target PLC address; an address expression is an expression that contains array subscripts that directly represent variables; the target PLC address includes a plurality of PLC addresses;
and an access module 320, configured to access the target PLC address based on the array index.
According to the batch access device for the programmable logic controller address, compared with the mode of accessing the address of the appointed position based on the semantics of the pointer variable, the batch access device for the programmable logic controller address is simpler and more convenient to realize, safer in accessing the PLC address and capable of improving the convenience and the safety of the batch access of the PLC address.
In some embodiments, the access module 320 may include:
the first determining unit is used for determining the value of the array subscript based on the assignment statement of the variable under the condition that the array subscript contains the variable;
the second determining unit is used for determining a target PLC address based on the value of the array subscript;
and the access unit is used for accessing the target PLC address.
In some embodiments, the first determining unit may be specifically configured to:
under the condition that the index of any one dimension in the array index is a variable, determining the value of the variable based on the assignment statement of the variable;
and determining the value of the array subscript based on the value of the variable.
In some embodiments, the assignment statement is a statement for assigning a plurality of values; alternatively, the assignment statement includes a statement for assigning an initial value and a statement for performing a self operation.
In some embodiments, the first determining unit may be specifically configured to:
under the condition that the index of any one dimension in the array index is an operation expression, acquiring an operation result of the operation expression based on assignment statements of variables contained in the operation expression;
and determining the value of the array subscript based on the operation result.
In some embodiments, the assignment statement for at least one variable is a statement for assigning a plurality of values; or the assignment statement of at least one variable includes a statement for assigning an initial value and a statement for performing a self-operation.
The batch access device of the programmable logic controller address in the embodiment of the application may be an electronic device, or may be a component in the electronic device, for example, an integrated circuit or a chip. The electronic device may be a terminal, or may be other devices than a terminal. By way of example, the electronic device may be a mobile phone, tablet computer, notebook computer, palm computer, vehicle-mounted electronic device, mobile internet appliance (Mobile Internet Device, MID), augmented reality (augmented reality, AR)/Virtual Reality (VR) device, robot, wearable device, ultra-mobile personal computer, UMPC, netbook or personal digital assistant (personal digital assistant, PDA), etc., but may also be a server, network attached storage (Network Attached Storage, NAS), personal computer (personal computer, PC), television (TV), teller machine or self-service machine, etc., and the embodiments of the present application are not limited in particular.
The batch access device for programmable logic controller addresses in the embodiments of the present application may be a device with an operating system. The operating system may be an Android operating system, an iOS operating system, or other possible operating systems, which are not specifically limited in the embodiments of the present application.
The batch access device for addresses of programmable logic controllers provided in the embodiments of the present application can implement each process implemented by the embodiments of the methods of fig. 1 to 2, and in order to avoid repetition, a description is omitted here.
In some embodiments, as shown in fig. 4, the embodiment of the present application further provides an electronic device 400, including a processor 401, a memory 402, and a computer program stored in the memory 402 and capable of running on the processor 401, where the program when executed by the processor 401 implements the processes of the embodiment of the batch access method of the programmable logic controller address, and the same technical effects can be achieved, and for avoiding repetition, a description is omitted herein.
The electronic device in the embodiment of the application includes the mobile electronic device and the non-mobile electronic device described above.
The embodiments of the present application further provide a non-transitory computer readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements each process of the above embodiment of the batch access method for programmable logic controller addresses, and can achieve the same technical effects, so that repetition is avoided, and details are not repeated here.
Wherein the processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes computer readable storage medium such as computer readable memory ROM, random access memory RAM, magnetic or optical disk, etc.
The embodiment of the application also provides a computer program product, which comprises a computer program, wherein the computer program realizes the batch access method of the programmable logic controller address when being executed by a processor.
Wherein the processor is a processor in the electronic device described in the above embodiment. The readable storage medium includes computer readable storage medium such as computer readable memory ROM, random access memory RAM, magnetic or optical disk, etc.
The embodiment of the application further provides a chip, the chip includes a processor and a communication interface, the communication interface is coupled with the processor, the processor is used for running a program or an instruction, implementing each process of the embodiment of the batch access method of the programmable logic controller address, and achieving the same technical effect, so that repetition is avoided, and no redundant description is provided here.
It should be understood that the chips referred to in the embodiments of the present application may also be referred to as system-on-chip chips, chip systems, or system-on-chip chips, etc.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element. Furthermore, it should be noted that the scope of the methods and apparatus in the embodiments of the present application is not limited to performing the functions in the order shown or discussed, but may also include performing the functions in a substantially simultaneous manner or in an opposite order depending on the functions involved, e.g., the described methods may be performed in an order different from that described, and various steps may also be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
From the above description of the embodiments, it will be clear to those skilled in the art that the above-described embodiment method may be implemented by means of software plus a necessary general hardware platform, but of course may also be implemented by means of hardware, but in many cases the former is a preferred embodiment. Based on such understanding, the technical solutions of the present application may be embodied essentially or in a part contributing to the prior art in the form of a computer software product stored in a storage medium (such as ROM/RAM, magnetic disk, optical disk), comprising several instructions for causing a terminal (which may be a mobile phone, a computer, a server, or a network device, etc.) to perform the methods described in the embodiments of the present application.
The embodiments of the present application have been described above with reference to the accompanying drawings, but the present application is not limited to the above-described embodiments, which are merely illustrative and not restrictive, and many forms may be made by those of ordinary skill in the art without departing from the spirit of the present application and the scope of the claims, which are also within the protection of the present application.
In the description of the present specification, reference to the terms "one embodiment," "some embodiments," "illustrative embodiments," "examples," "specific examples," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present application. In this specification, schematic representations of the above terms do not necessarily refer to the same embodiments or examples. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples.
While embodiments of the present application have been shown and described, it will be understood by those of ordinary skill in the art that: many changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the application, the scope of which is defined by the claims and their equivalents.

Claims (12)

1. A method for batch access of addresses of a programmable logic controller, comprising:
acquiring an address expression in a target PLC statement; the address expression is used for representing a target PLC address; the address expression is an expression containing an array subscript and directly representing a variable; the target PLC address comprises a plurality of PLC addresses;
and accessing the target PLC address based on the array subscript.
2. The method of claim 1, wherein accessing the target PLC address based on the array index, comprises:
determining the value of the array subscript based on the assignment statement of the variable under the condition that the array subscript contains the variable;
determining the target PLC address based on the value of the array subscript;
and accessing the target PLC address.
3. The method for batch access of addresses of programmable logic controllers according to claim 2, wherein, in the case that the array subscript contains a variable, determining the value of the array subscript based on the assignment statement of the variable comprises:
determining the value of the variable based on the assignment statement of the variable under the condition that the index of any dimension in the array index is the variable;
And determining the value of the array subscript based on the value of the variable.
4. The method for batch access of addresses of programmable logic controllers according to claim 2, wherein, in the case that the array subscript contains a variable, determining the value of the array subscript based on the assignment statement of the variable comprises:
under the condition that the index of any one dimension in the array index is an operation expression, acquiring an operation result of the operation expression based on an assignment statement of each variable contained in the operation expression;
and determining the value of the array subscript based on the operation result.
5. A method for batch access of addresses of a programmable logic controller according to claim 3, wherein the assignment statement is a statement for assigning a plurality of values; alternatively, the assignment statement includes a statement for assigning an initial value and a statement for performing a self operation.
6. The method of claim 4, wherein the assignment statement of at least one of the variables is a statement for assigning a plurality of values; or the assignment statement of at least one of the variables includes a statement for assigning an initial value and a statement for performing a self-operation.
7. The batch access method of programmable logic controller addresses according to any one of claims 2 to 6, wherein the target PLC sentence is used to illuminate a target light; the address of the target lamp is the target PLC address; the subscript of any one dimension in the array subscript is a first variable; the first variable is a circulation control variable;
the accessing the target PLC address based on the array subscript includes:
and executing the target PLC statement, accessing the target PLC address through the circulation of the first variable, and turning on the target lamp.
8. The batch access method of programmable logic controller addresses according to any one of claims 2 to 6, wherein the target PLC sentence is used to illuminate a target light; the address of the target lamp is the target PLC address; the array subscripts comprise a first array subscript and a second array subscript; the subscript of the target dimension in the first array subscript is an operation expression comprising a second variable and a third variable; the subscript of the target dimension in the second plurality of subscripts is an operation expression comprising the second variable and a fourth variable; the second variable is a circulation control variable;
The accessing the target PLC address based on the array subscript includes:
executing the target PLC statement, accessing a first address in the target PLC address based on the second variable and the third variable through the loop of the second variable, illuminating a first part in the target lamp, and accessing a second address in the target PLC address based on the second variable and the third variable, illuminating a second part in the target lamp; the target lamp is composed of the first portion and the second portion.
9. A batch access device for programmable logic controller addresses, comprising:
the acquisition module is used for acquiring the address expression in the target PLC statement; the address expression is used for representing a target PLC address; the address expression is an expression containing an array subscript and directly representing a variable; the target PLC address comprises a plurality of PLC addresses;
and the access module is used for accessing the target PLC address based on the array subscript.
10. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements a method for batch access of programmable logic controller addresses as claimed in any one of claims 1 to 8 when executing the program.
11. A non-transitory computer readable storage medium having stored thereon a computer program, which when executed by a processor implements a method of bulk access of programmable logic controller addresses according to any of claims 1-8.
12. A computer program product comprising a computer program which, when executed by a processor, implements a method of batch access of programmable logic controller addresses as claimed in any one of claims 1 to 8.
CN202311867637.6A 2023-12-29 2023-12-29 Batch access method and device for programmable logic controller addresses Pending CN117827693A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311867637.6A CN117827693A (en) 2023-12-29 2023-12-29 Batch access method and device for programmable logic controller addresses

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311867637.6A CN117827693A (en) 2023-12-29 2023-12-29 Batch access method and device for programmable logic controller addresses

Publications (1)

Publication Number Publication Date
CN117827693A true CN117827693A (en) 2024-04-05

Family

ID=90511096

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311867637.6A Pending CN117827693A (en) 2023-12-29 2023-12-29 Batch access method and device for programmable logic controller addresses

Country Status (1)

Country Link
CN (1) CN117827693A (en)

Similar Documents

Publication Publication Date Title
US10255650B2 (en) Graphics processing using dynamic resources
US20200225921A1 (en) Lookup table optimization for programming languages that target synchronous digital circuits
US10216501B2 (en) Generating code in statically typed programming languages for dynamically typed array-based language
US9594668B1 (en) Debugger display of vector register contents after compiler optimizations for vector instructions
CN110245468A (en) A kind of Compilation Method, device, equipment and system
Hyde The art of assembly language
VanSickle Programming microcontrollers in C
US6874005B2 (en) Subexpression selection of expression represented in contiguous tokenized polish representation
KR20010086328A (en) Method, system, program, and data structure for transforming an instruction in a first bit architecture to an instruction in a second bit architecture
US8990500B2 (en) Storing the most significant and the least significant bytes of characters at non-contiguous addresses
CN110362404B (en) SQL-based resource allocation method and device and electronic equipment
Svendsen et al. Transfinite step-indexing: Decoupling concrete and logical steps
Gottschling et al. Generic support of algorithmic and structural recursion for scientific computing
Decyk et al. Introduction to object-oriented concepts using Fortran90
CN117827693A (en) Batch access method and device for programmable logic controller addresses
Blanchet et al. Computer architecture
CN111008056B (en) BIOS setting interface language configuration method and device
JP2021144730A (en) Instruction executing method, apparatus, electronic device, computer-readable storage medium, and program
JPH0731629B2 (en) Address generator
Knoben Software caching for tree-based algorithms on accelerator cards
Milutinovic et al. Polynomial and rational functions
Milicchio et al. High-performance data structures for de novo assembly of genomes: cache oblivious generic programming
CN117806607A (en) PLC program compiling method and device based on array mapping memory address
Strobl et al. Euclides–a javascript to postscript translator
Kann Implementing a one address cpu in logisim

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination