CN103761071B - A kind of PLC instruction encoding and identifying system - Google Patents
A kind of PLC instruction encoding and identifying system Download PDFInfo
- Publication number
- CN103761071B CN103761071B CN201410008304.2A CN201410008304A CN103761071B CN 103761071 B CN103761071 B CN 103761071B CN 201410008304 A CN201410008304 A CN 201410008304A CN 103761071 B CN103761071 B CN 103761071B
- Authority
- CN
- China
- Prior art keywords
- instruction
- value
- represent
- soft element
- array
- 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.)
- Active
Links
Landscapes
- Programmable Controllers (AREA)
Abstract
The invention discloses the instruction coding method of PLC a kind of and its recognition methods, the instruction of the coding method is divided into pure single-step instruction, single-step instruction and multi-step instructions three major types;The processing unit of instruction is 4 16 ary codes, 1st is used to represent instruction type, latter 3 of pure single-step instruction are used to represent pure single-step instruction code clerk, latter 3 of single-step instruction are used to represent the corresponding soft element numbering of command operating, and latter 3 of multi-step instructions are used for the element numerals for the array of function pointer that expression needs are jumped to;The recognition methods includes type identification and the operation instructed to a step-length, wherein operation includes the redirecting of function, the operation of soft element and the realization of pure single-step instruction.The coding method and recognition methods coding are simplified, identification method accuracy and be easy to extension.
Description
Technical field
The present invention relates to the instruction encoding of PLC a kind of and identifying system.
Background technology
The hardware configuration of programmable controller is built upon on modern computer hardware configuration, therefore PLC technology
The working method of device and it is computer seemingly, i.e., be operated by performing the program code that weaves in advance.But programmable control
The actual control object of device processed is Protean again, must carry out programmable controller user program by user before runtime
Write, and downloaded to by downloading wire in the internal storage in programmable controller.At present, programmable controller is to user
The executive mode of program has two kinds:Complied executing mode and explanation executive mode.Explain the use that executive mode only writes user
The instruction catalogue of family Program Generating programmable controller is downloaded in programmable controller, by core special inside programmable controller
Soft-hearted part takes charge of the explanation execution.The kernel software is operated except carrying out initialization operation, self diagnosis, I/O scan refreshing etc.
Outside, most important is exactly that can explain the instruction catalogue performed after user program conversion.Programmable controller kernel software can be solved
All instructions in user program instruction catalogue are released, and the good function code of predefined is performed according to corresponding instruction.When can compile
When range controller is run, kernel software scan round user program instruction catalogue at a terrific speed is realized user-defined various
Calculate and operate.
The content of the invention
Goal of the invention:The purpose of the present invention is in view of the shortcomings of the prior art and provides a kind of PLC instruction encoding and knowledge
Other system, not only encodes simplification, and the complete information of instruction is included in most short code length, saves memory headroom, improves
Programmable controller operational efficiency;And identification method accuracy, set forth herein code identification mode be able to ensure that can
Programmable controller can accurately be run and every instruction identification will not malfunction;Extension is also easy in addition, can be by multiple
Array of function pointer is redirected, or sets up two dimension or more array of function pointer, and includes in coding corresponding subscript information
To realize the extension of instruction, this extension instructed to programmable controller is provided a great convenience with upgrading functionally.
Technical scheme:In order to realize goal of the invention, the invention discloses the instruction encoding of PLC a kind of and identifying system, bag
Include coding module, read module and identification module;Coding module is used to encode instruction, and instruction is divided into pure single step and referred to
Make, single-step instruction and multi-step instructions three major types;The processing unit of instruction is 4 16 ary codes, and the 1st is used to represent instruction class
Type, latter 3 of pure single-step instruction are used to represent pure single-step instruction code clerk, and latter 3 of single-step instruction are used to represent command operating
Corresponding soft element numbering, latter 3 of multi-step instructions are used for the element numerals for the array of function pointer that expression needs are jumped to;Read
Modulus block is used for the reading to instruction;Identification module is used to parse the instruction that read module is read, and is sentenced according to the 1st of instruction the
Break and instruction type, corresponding command operating is carried out according to different instruction type and the value of low 3.
Preferably, in order that coded command is more directly perceived and more complete, soft element bag in the single-step instruction
Include status register, input relay, output relay, timer, auxiliary relay, counter and special auxiliary relay
Device.
Preferably, the efficiency in order to further improve coding, the multi-step instructions include two-step instruction, other multisteps and referred to
Make, the output order of timer and counter and application instruction.
Preferably, preservation and release in order to adapt to using the uncertain step-length instructed and be easy to its step-length number, institute
State and be stored in using the step-length of instruction in corresponding step-length array.
Preferably, the efficiency in order to further improve coding, the analysis instruction method of the identification module is including following
Step:
(1)The 1st in step instruction is taken out, is that pure single-step instruction value then enters step according to the value of the 1st(2)If,
Then enter step for single-step instruction value(3)If multi-step instructions value then enters step(4);
(2)According to step(1)In instruct latter 3 of a step, related command operating is performed according to its value;
(3)According to step(1)In instruct latter 3 of a step, the phase that represents of the 1st place value is carried out to the soft element that its value is represented
It should operate;
(4)If two-step is instructed, step(1)In a step instruction after 3 representative function array of pointers respective element mark
Number, then into the respective function in array of pointers, latter 3 of second step instruction then represent soft element numbering,
If other multi-step instructions, then carry out some steps and search respective function, latter 3 of final step instruction then represent soft
Element number;
If the output order of timer and counter, then according to step(1)In a step instruction after 3 place values judge soft member
Part is numbered, then comprising timing value or counting value information in step afterwards;
If application instruction, according to step(1)In step instruction after 3 place values obtain preserved in its step-length array corresponding
Step-length number, performs the instruction of following corresponding step-length number.
Beneficial effect:The present invention compared with prior art, there is following advantage:
1st, coding is simplified, and the complete information of instruction is included in most short code length, saves memory headroom, improving can
Program sequence controller operational efficiency.
2nd, identification method is accurate, and code identification mode is able to ensure that programmable controller can accurately be run and often
Bar instruction identification will not malfunction.
3rd, it is easy to extension, coded system provides sufficient extending space for programmable controller instruction.For needing
The instruction module to be extended, can redirecting by multiple array of function pointer, or set up two dimension or more array of function pointer,
And realize the extension of instruction comprising corresponding subscript information in coding, this extension instructed to programmable controller with functionally
Upgrading provide a great convenience.
Brief description of the drawings
Fig. 1 is the identification process figure of instruction encoding of the present invention.
Embodiment
The present invention is further described with reference to embodiment.
PLC instruction encodings of the present invention are divided into pure single-step instruction, single-step instruction and multi-step instructions three major types.The PLC refers to
Order coding is with step(4 heuristicimal codes)For unit, the instruction of a step-length is split as R+ppp pattern.Wherein R is highest order
16 ary codes, represent scope 0x0~0xF, for representing instruction type, that is, array of function pointer element numerals;Ppp is
Relatively low 3 16 ary codes in instruction step, its implication meaning in different type instruction is different.
Wherein single-step instruction is used to represent the corresponding soft element numbering of command operating, so soft element is divided into Status register
Device, input relay, output relay, timer, auxiliary relay, counter and special auxiliary relay, such as the institute of table 1
Show, wherein S is that status register, X are that input relay, Y are that output relay, T are that timer, M are that auxiliary relay, C are
Counter, M are special auxiliary relay, and numbering 000 to FFF corresponds to a position soft element respectively.
Table 1
Soft element title | Numbering |
S0~S1023 | 0~3FF |
X0~X377(Octal system) | 400~4FF |
Y0~Y377(Octal system) | 500~5FF |
T0~T511 | 600~7FF |
M0~M1535 | 800~DFF |
C0~C255 | E00~EFF |
M8000~M8255 | F00~FFF |
As shown in figure 1, after instruction encoding is read, highest order R in step instruction, R number are extracted first
It is worth meaning as shown in table 2.
Table 2
If it is the single-step instruction numbered with soft element that R is corresponding when being equal to 0 to 9, it is low three 16 that single-step instruction is encoded
Ary codes ppp just represents the corresponding soft element numbering of command operating.For example, being encoded to 0x0401 instruction, R=0 corresponds to LD
Instruction fetch;The state of the corresponding numberings, i.e. reading X001 for being input relay X001 of ppp=0x401.Program will jump to letter
Number LD (void) operations, and complete corresponding operating.
If R be equal to F when the instruction be pure single-step instruction, i.e., without soft element number operation, such as END instruction END, time
Road block is with instructing ANB, negating instruction INV etc., and now as shown in table 3, remaining numerical value then can be used for the numerical value meaning of low three
The extension of pure single-step instruction.
Table 3
Pure low three bit value of single-step instruction | Instruction type |
0xff0 | END is instructed |
0xff1 | ANB is instructed |
0xff2 | ORB is instructed |
0xff3 | MPS is instructed |
0xff4 | MRD is instructed |
0xff5 | MPP is instructed |
0xff6 | INV is instructed |
0xff7 | NOP instruction |
0xff8 | RET instruction |
If R is equal to A, then it represents that step instruction is two-step instruction, then needs to be redirected twice, call redirect letter first
Number, then redirecting function and being found according to ppp value in its array of function pointer needs in the subfunction that jumps to, into the
In the instruction of two steps, the ppp of second step instruction then represents the target soft element of command operating, and R has no practical significance, for example, compiling
The two-step instruction that code is A0088401 is to take rising edge of a pulse LDP to operate to input relay X001.
It is other multi-step instructions if R is equal to B, and processing mode is similar with two-step instruction, by the group of R+ppp in the first step
Close to complete to instruct twice and redirect, and second step and later program step then include the target soft element or operand of command operating
Deng with instructing relevant information, realized by calling the function that redirects of other multi-step instructions.
If R is equal to C, then it represents that step instruction is that timer and counter OUT are instructed, and its ppp represents timer or counting
The numbering of device.Program will jump to timer and counter OUT functions first, then by judging that ppp value determines the operation
It is, for timer, 16 digit counters or the operation of 32 digit counters, to finally complete operation.
If R is equal to D, then it represents that step instruction is application instruction.Because application instruction step-length will be depending on specific instruction, institute
To also need to know total step-length of the instruction after above- mentioned information is obtained, the present invention realizes step-length by setting up a constant array
Storage, each element value is exactly that application corresponding with its following table numbering instructs step length in array.Obtaining application instruction
After numbering array index, its element value is exactly application instruction step-length, so it may determine that next the coding of which step is
Belong to the instruction, these contain the information such as source operand, destination operand, the constant needed for instruction in encoding.
The above method all remains with certain extending space in three types instruction so that coding is easy to extension;And it is right
In the requirement of special instruction, can redirecting by multiple array of function pointer, or set up two dimension or more array of function pointer,
And realize the extension of instruction comprising corresponding subscript information in coding, this extension instructed to programmable controller with functionally
Upgrading provide a great convenience;Meanwhile, whole coding method and recognition methods coding is simplified, in most short code length
Complete information comprising instruction, saves memory headroom, improves programmable controller operational efficiency.
Claims (3)
1. a kind of PLC instruction encoding and identifying system, it is characterised in that including coding module, read module and identification
Module;
Coding module is used to encode instruction, and instruction is divided into pure single-step instruction, single-step instruction and multi-step instructions three major types;
The processing unit of instruction is 4 16 ary codes, and the 1st is used to represent instruction type, rear 3 use of pure single-step instruction
In representing pure single-step instruction code clerk, latter 3 of single-step instruction are used to represent the corresponding soft element numbering of command operating, multistep
Latter 3 of instruction are used for the element numerals for representing the array of function pointer that needs are jumped to;
Read module is used for the reading to instruction;
Identification module is used to parse the instruction that read module is read, and instruction type is judged according to the 1st of instruction the, according to
Different instruction type and the value of latter 3 carry out corresponding command operating;In the step instruction read by read module
1st, i.e., highest order R decision instruction types, if it is the single-step instruction numbered with soft element that R is corresponding when being equal to 0 to 9;If R
The instruction is pure single-step instruction during equal to F;If R is equal to A, then it represents that step instruction is two-step instruction;It is it if R is equal to B
His multi-step instructions;If R is equal to C, then it represents that step instruction is timer and the output order of counter;If R is equal to D, then it represents that
Step instruction is application instruction, wherein above-mentioned multi-step instructions include two-step instruction, other multi-step instructions, timer and counting
The output order of device and application instruction.
2. the instruction encoding and identifying system of a kind of PLC as described in claim 1, it is characterised in that the coding module
The soft element of middle single-step instruction includes status register, input relay, output relay, timer, auxiliary relay, counting
Device and special auxiliary relay.
3. the instruction encoding and identifying system of a kind of PLC as described in claim 1, it is characterised in that the identification module
Analysis instruction method comprise the following steps:
(1)The 1st in step instruction is taken out, is that pure single-step instruction value then enters step according to the value of the 1st(2)If,
Single-step instruction value then enters step(3)If multi-step instructions value then enters step(4);
(2)According to step(1)In instruct latter 3 of a step, related command operating is performed according to its value;
(3)According to step(1)In a step instruct latter 3, to its value represent soft element carry out the 1st place value represent it is corresponding
Operation;
(4)If two-step is instructed, step(1)In a step instruction after 3 representative function array of pointers respective element label,
The respective function then entered in array of pointers, latter 3 of second step instruction then represent soft element numbering, if other multisteps refer to
Order, then carry out some steps and search respective function, latter 3 of final step instruction then represent soft element numbering;If timer and
The output order of counter, then according to step(1)In step instruction after 3 place values judge soft element numbering, in step afterwards then
Include timing value or counting value information;If application instruction, according to step(1)In a step instruction after 3 place values obtain its step-length
The corresponding step-length number preserved in array, performs the instruction of following corresponding step-length number.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410008304.2A CN103761071B (en) | 2014-01-08 | 2014-01-08 | A kind of PLC instruction encoding and identifying system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201410008304.2A CN103761071B (en) | 2014-01-08 | 2014-01-08 | A kind of PLC instruction encoding and identifying system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN103761071A CN103761071A (en) | 2014-04-30 |
CN103761071B true CN103761071B (en) | 2017-07-18 |
Family
ID=50528315
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201410008304.2A Active CN103761071B (en) | 2014-01-08 | 2014-01-08 | A kind of PLC instruction encoding and identifying system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103761071B (en) |
Families Citing this family (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107015840B (en) * | 2017-03-17 | 2020-07-28 | 南京南瑞继保电气有限公司 | Quick execution method and quick execution system of resolver |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103154883A (en) * | 2010-10-12 | 2013-06-12 | Arm有限公司 | Decoding instructions from multiple instruction sets |
CN103218349A (en) * | 2013-03-08 | 2013-07-24 | 广东工业大学 | Reading and conversion method for PLC (Programmable Logic Controller) instruction storage rule in PMW-format file |
Family Cites Families (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7957751B2 (en) * | 2006-08-02 | 2011-06-07 | Telecommunication Systems, Inc. | Personal location code |
-
2014
- 2014-01-08 CN CN201410008304.2A patent/CN103761071B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103154883A (en) * | 2010-10-12 | 2013-06-12 | Arm有限公司 | Decoding instructions from multiple instruction sets |
CN103218349A (en) * | 2013-03-08 | 2013-07-24 | 广东工业大学 | Reading and conversion method for PLC (Programmable Logic Controller) instruction storage rule in PMW-format file |
Non-Patent Citations (2)
Title |
---|
A Transformation Method between PLC Ladder Diagrams and Instruction Lists Using Recursive and Stack Algorithms;Zhisheng Zhang等;《Advanced Materials Research》;20120519;第490-495卷;1908-1912 * |
基于ARM的PLC指令编译与并行运算数据配置的设计;吴笔迅;《中国优秀硕士学位论文全文数据库 信息科技辑》;20130415(第04期);I140-317 * |
Also Published As
Publication number | Publication date |
---|---|
CN103761071A (en) | 2014-04-30 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP4283131B2 (en) | Processor and compiling method | |
CN104471529B (en) | To the method and apparatus of extended software branch target prompting | |
CN103547998A (en) | Method and apparatus for compiling regular expressions | |
CN103547999A (en) | Utilizing special purpose elements to implement a FSM | |
CN101976187B (en) | Stack tracing method and device in decompilation process and decompiler | |
CN113377441B (en) | Universal time sequence controller architecture for quantum physical experiment platform | |
CN102866982A (en) | Eight-bit complex instruction set central processor based on FPGA (Field Programmable Gata Array) | |
RU2015151114A (en) | DEVICE AND METHOD FOR ACCELERATING COMPRESSION AND UNPACKING OPERATIONS | |
CN109145534B (en) | Anti-confusion system and method for software virtual machine protection | |
CN101369235A (en) | Program converting device and compiling program | |
CN108846069B (en) | Document execution method and device based on markup language | |
CN105190334A (en) | Method and apparatus for device testing using multiple processing paths | |
CN104020982B (en) | With the efficient branch target buffer for returning to predictive ability | |
CN103761071B (en) | A kind of PLC instruction encoding and identifying system | |
US10990073B2 (en) | Program editing device, program editing method, and computer readable medium | |
CN101320324A (en) | Processor apparatus and composite condition processing method | |
CN104049947A (en) | Dynamic Rename Based Register Reconfiguration Of A Vector Register File | |
CN105677298B (en) | A kind of method and apparatus for extending immediate in computer instruction | |
CN103218349A (en) | Reading and conversion method for PLC (Programmable Logic Controller) instruction storage rule in PMW-format file | |
CN102279795A (en) | Test method and test device | |
CN101436122A (en) | Optimizing method and apparatus for implementing instruction parallel execution | |
CN102799434A (en) | Method for realizing automatic code transplantation by software protection device | |
CN104408023B (en) | Method and indicia calculator that a kind of index is calculated | |
CN102043715A (en) | Method and device for realizing single chip microprocessor simulation by site users | |
CN101601011B (en) | Method for efficiently emulating computer architecture condition code settings |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |