CN108303948B - A kind of execution method and apparatus of the compiled PLC based on motion controller - Google Patents

A kind of execution method and apparatus of the compiled PLC based on motion controller Download PDF

Info

Publication number
CN108303948B
CN108303948B CN201810170399.6A CN201810170399A CN108303948B CN 108303948 B CN108303948 B CN 108303948B CN 201810170399 A CN201810170399 A CN 201810170399A CN 108303948 B CN108303948 B CN 108303948B
Authority
CN
China
Prior art keywords
operator
stack
pointer
operand
directed toward
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
Application number
CN201810170399.6A
Other languages
Chinese (zh)
Other versions
CN108303948A (en
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.)
Shenzhen Leadshine Control Technology Co Ltd
Original Assignee
Shenzhen Leadshine Control 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 Shenzhen Leadshine Control Technology Co Ltd filed Critical Shenzhen Leadshine Control Technology Co Ltd
Priority to CN201810170399.6A priority Critical patent/CN108303948B/en
Publication of CN108303948A publication Critical patent/CN108303948A/en
Application granted granted Critical
Publication of CN108303948B publication Critical patent/CN108303948B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/05Programmable logic controllers, e.g. simulating logic interconnections of signals according to ladder diagrams or function charts
    • G05B19/056Programming the PLC
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B2219/00Program-control systems
    • G05B2219/10Plc systems
    • G05B2219/13Plc programming
    • G05B2219/13004Programming the plc

Landscapes

  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Automation & Control Theory (AREA)
  • Programmable Controllers (AREA)

Abstract

The execution method and apparatus of the present invention provides a kind of compiled PLC based on motion controller, the method comprise the steps that initialization operator stack and operand stack, the setting positioning label in the operator first address of the operator stack;Judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and the case where the stack header element of its operator stack is the positioning label;If so, returning to the stack header element of the operand, execution terminates.The method passes through setting positioning label, and the algorithm of the compiled PLC based on motion controller is executed with positioning label according to the pointer for operator stack and operand stack, motion control function is realized by PLC programmed algorithm, improve the flexibility of compiled PLC algorithm, improve the speed of service, and then execution efficiency being improved, and method logic provided by the present invention is simple, controlling is strong.

Description

A kind of execution method and apparatus of the compiled PLC based on motion controller
Technical field
The present invention relates to logic controller technical fields, more specifically to a kind of compiling based on motion controller The execution method and apparatus of type PLC.
Background technique
PLC (programmable logic controller (PLC)) is broadly divided into two major classes, i.e. explanation type PLC and compiled PLC two major classes at present Type.
Explanation type PLC is to download to ladder diagram source program in slave computer in a particular format, in the process that program executes In, trapezoid figure program is explained one by one, finally obtains corresponding output data.The characteristics of this method, is easy for transplanting, spirit Active strong, the disadvantage is that occupying, more resource, the speed of service are slow, and the runnability of PLC depends on the calculating speed of hardware;It is compiled PLC is trapezoid figure program to be converted into hexadecimal code in upper PC machine, and code is directly downloaded in slave computer, In The slave computer execution stage directly executes hexadecimal code.The advantages of this method is that the speed of service is fast, and execution efficiency is high, section Hardware resource is saved, the disadvantage is that transplantability is poor, the slave computer of different CPU needs different compiling systems.Motion controller is main It is good in motion control, and it is weaker to logic control, and use is also inconvenient.
Existing PLC has the following aspects defect: the flexibility of compiled PLC is poor, and transplanting is inconvenient;And explanation type PLC execution efficiency is low, and the speed of service is slow;PLC is good at processing logic control, but less, movement is supported for motion control function Control performance is poor, while using complex.
Summary of the invention
In view of this, the present invention provides the execution method and apparatus of compiled PLC based on motion controller a kind of to solve Certainly the deficiencies in the prior art.
To achieve the above object, the present invention provides the execution method of compiled PLC based on motion controller a kind of, packet It includes:
Operator stack and operand stack are initialized, the setting positioning label in the operator first address of the operator stack;
Judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and its operator stack The case where stack header element is the positioning label;
If so, returning to the stack header element of the operand, execution terminates.
Preferably, described " to judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and its institute After the case where stack header element for stating operator stack is the positioning label ", further includes:
If it is not, then judging whether the pointer direction is operand;
If the pointer direction is the operand, pushes operand described, move back the operator, and return It is described " to judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and the stack of its operator stack The case where header element is the positioning label ";
If what the pointer was directed toward is not the operand, determine that the pointer is oriented to the operator;
The priority for the operator that the stack head operator and pointer for comparing the operator stack are directed toward;
If the priority of the stack head operator of the operator stack is less than the priority for the operator that the pointer is directed toward, Execution terminates.
Preferably, described " operator that the stack head operator and pointer of the operator stack are directed toward it is preferential After grade ", further includes:
If the priority of the stack head operator of the operator stack is greater than the operator precedence that the pointer is directed toward, count The operator of the operator stack is calculated, operation result is generated;
The operation result is stored in the operand, the pointer is moved back, and " judges whether to refer to described in return Needle is directed toward the end of the logical expression of the operator stack, and the stack header element of its operator stack is the positioning label The case where ".
Preferably, described " calculating the operator of the operator stack, generate operation result " includes:
Confirm the performance variable number of the operator;
The behaviour corresponding with the performance variable number in the operand stack is obtained according to the performance variable number It counts;
The operator of the operator stack is calculated, and generates the operation result.
Preferably, described " operator that the stack head operator and pointer of the operator stack are directed toward it is preferential After grade ", further includes:
If the priority of the stack head operator of the operator stack is equal to the operator precedence that the pointer is directed toward, sentence The both ends for the operator of breaking whether there is bracket character;
If there are bracket characters at the both ends of the operator, described to move back the operator and the pointer, and return " judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and the first member of stack of its operator stack The case where element is the positioning label ".
It is preferably, described that " initialization operator stack and operand stack, set in the operator first address of the operator stack Set positioning label " before, further includes:
It determines controller type, and generates LD instruction set and IL instruction set according to the controller type;
Complied executing file is generated according to the LD instruction set and the IL instruction set, in order to be based on the Complied executing File carries out the initialization and operation of the operator stack and the operand stack.
Preferably, described " generating Complied executing file according to the LD instruction set and the IL instruction set " includes:
New IL instruction set is generated according to the LD instruction set and the IL instruction set, and is obtained according to the new instruction set To program listing and variable list;
Morphology and syntactic analysis are carried out respectively to the classification of the IL instruction set, by the morphology and grammer of each IL instruction set Generative grammar tree;
According to the syntax tree and the variable list synthesis program file table, and to the journey in described program listed files Preface part carries out CRC check, generates Complied executing file.
In addition, to solve the above problems, the present invention also provides a kind of compiled PLC's based on motion controller executes dress It sets, including locating module, judgment module and return module;
The locating module, for initializing operator stack and operand stack, on the first ground of the operator of the operator stack Setting positioning label in location;
The judgment module, the end of the logical expression for judging whether to occur that pointer is directed toward the operator stack, And the stack header element of its operator stack be the positioning label the case where;
The return module, for if so, returning to the stack header element of the operand, execution to terminate.
In addition, to solve the above problems, the present invention also provides a kind of user terminal, including memory and processor, it is described Memory is used to store the execution program of the compiled PLC based on motion controller, and the processor operation is described based on movement The execution program of the compiled PLC of controller is so that the user terminal executes the compiling as described above based on motion controller The execution method of type PLC.
In addition, to solve the above problems, the present invention also provides a kind of computer readable storage medium, it is described computer-readable The execution program of the compiled PLC based on motion controller, the compiling based on motion controller are stored on storage medium The execution program of type PLC realizes the execution side of the compiled PLC as described above based on motion controller when being executed by processor Method.
The execution method and apparatus of compiled PLC based on motion controller provided by the invention a kind of.Wherein, the side Method execute based on fortune with positioning label by setting positioning label, and according to the pointer for operator stack and operand stack The algorithm of the compiled PLC of movement controller realizes motion control function by PLC programmed algorithm, improve compiled PLC and calculate The flexibility of method improves the speed of service, and then improves execution efficiency, and method logic provided by the present invention is simple, controlling By force.
Detailed description of the invention
Fig. 1 is the hardware fortune being related to the present invention is based on the execution embodiment of the method scheme of the compiled PLC of motion controller The structural schematic diagram of row environment;
Fig. 2 is that the present invention is based on the flow diagrams of the execution method first embodiment of the compiled PLC of motion controller;
Fig. 3 is that the present invention is based on the flow diagrams of the execution method second embodiment of the compiled PLC of motion controller;
Fig. 4 is that the present invention is based on the flow diagrams of the execution method 3rd embodiment of the compiled PLC of motion controller;
Fig. 5 is that the present invention is based on the thin of the step S90 of the execution method 3rd embodiment of the compiled PLC of motion controller The flow diagram of change;
Fig. 6 is that the present invention is based on the flow diagrams of the execution method fourth embodiment of the compiled PLC of motion controller;
Fig. 7 is that the present invention is based on the flow diagrams of the 5th embodiment of execution method of the compiled PLC of motion controller;
Fig. 8 is that the present invention is based on the step S140's of the 5th embodiment of execution method of the compiled PLC of motion controller The flow diagram of refinement;
Fig. 9 is that the present invention is based on the flow diagrams of the execution method sixth embodiment of the compiled PLC of motion controller;
Figure 10 is that the present invention is based on the PLC and BASIC of the execution method sixth embodiment of the compiled PLC of motion controller Between data interaction module connection schematic diagram;
Figure 11 is that the present invention is based on the PLC and BASIC of the execution method sixth embodiment of the compiled PLC of motion controller Between data interaction schematic diagram;
Figure 12 is to return to zero function letter the present invention is based on the execution method sixth embodiment of the compiled PLC of motion controller Cease interaction flow schematic diagram;
Figure 13 is that the present invention is based on the functional block diagrams of the executive device of the compiled PLC of motion controller.
The embodiments will be further described with reference to the accompanying drawings for the realization, the function and the advantages of the object of the present invention.
Specific embodiment
The embodiment of the present invention is described below in detail, in which the same or similar labels are throughly indicated same or like Element or element with the same or similar functions.
In addition, term " first ", " second " are used for descriptive purposes only and cannot be understood as indicating or suggesting relative importance Or implicitly indicate the quantity of indicated technical characteristic.Define " first " as a result, the feature of " second " can be expressed or Implicitly include one or more of the features.In the description of the present invention, the meaning of " plurality " is two or more, Unless otherwise specifically defined.
In the present invention unless specifically defined or limited otherwise, term " installation ", " connected ", " connection ", " fixation " etc. Term shall be understood in a broad sense, for example, it may be being fixedly connected, may be a detachable connection, or integral;It can be mechanical connect It connects, is also possible to be electrically connected;It can be directly connected, can also can be in two elements indirectly connected through an intermediary The interaction relationship of the connection in portion or two elements.It for the ordinary skill in the art, can be according to specific feelings Condition understands the concrete meaning of above-mentioned term in the present invention.
It should be appreciated that the specific embodiments described herein are merely illustrative of the present invention, it is not intended to limit the present invention.
As shown in Figure 1, being the structural schematic diagram of the hardware running environment for the terminal that the embodiment of the present invention is related to.
The terminal of that embodiment of the invention can be PC, be also possible to smart phone, tablet computer, portable computer etc. with aobvious Show the packaged type terminal device of function.
The terminal may include: processor 1001, such as CPU, network interface 1004, user interface 1003, memory 1005, communication bus 1002.Wherein, communication bus 1002 is for realizing the connection communication between these components.User interface 1003 may include display screen, input unit such as keyboard, remote controler, and optional user interface 1003 can also include having for standard Line interface, wireless interface.Network interface 1004 optionally may include that (such as WI-FI connects standard wireline interface and wireless interface Mouthful).Memory 1005 can be high speed RAM memory, be also possible to stable memory, such as magnetic disk storage.Memory 1005 optionally can also be the storage device independently of aforementioned processor 1001.
It will be understood by those skilled in the art that the restriction of the not structure paired terminal of terminal shown in Fig. 1, may include ratio More or fewer components are illustrated, certain components or different component layouts are perhaps combined.
As shown in Figure 1, as may include operating system, number in a kind of memory 1005 of computer readable storage medium According to the execution program of interface control program, network attachment procedure and the compiled PLC based on motion controller.
The execution method and apparatus of a kind of compiled PLC based on motion controller provided by the invention, wherein the side Method realizes motion control function by PLC programmed algorithm, improves the flexibility of compiled PLC algorithm, improves the speed of service, into And execution efficiency being improved, and method logic provided by the present invention is simple, controlling is strong.
Embodiment 1:
Referring to Fig. 2, first embodiment of the invention provides the execution method of compiled PLC based on motion controller a kind of, Include:
Step S10 initializes operator stack and operand stack, and it is fixed to be arranged in the operator first address of the operator stack Position label;
It is above-mentioned, it is to be understood that stack (stack) also known as storehouse, it is a kind of linear list that operation is limited.Its limitation is It is inserted into and is deleted operation in the one end for being only allowed in table.This one end is referred to as stack top, relatively, the other end is called stack bottom. It also referred to as pushes on to stack insertion new element, stacking or pop down, it is that new element is put into the upper surface of stack top element, is allowed into For new stack top element;It also referred to as pops or pops off from a stack deletion element, it is that stack top element is deleted, and keeps its adjacent Element become new stack top element.Wherein, it should be noted that the input/output argument of all operators is all stored in behaviour It counts in stack.
It is above-mentioned, it is to be understood that operator can be directed to more than one operand project for executing program code operation To carry out operation.Such as: 2+3, operand is 2 and 3, and operator is then "+".
It is above-mentioned, it is to be understood that operand is the entity that operator acts on, and is a composition portion in expression formula Point, it defines the amount that digital operation is carried out in instruction.Expression formula is the combination of operand AND operator.Operand is pointed out to instruct The source of data required for the operation of execution.Operand is a field of assembly language directive.Such as: Mov AX 5678H behaviour Count (AX 5678H).Operand itself can be put in this field of operand, operation address can also be put, behaviour can also be put Make the calculation method of address.A usual instruction includes operator and operand.Such as: operator is specified in compare instruction Computer compares operation, and operand then specifies the two values being compared.Operand is the participant of instruction execution, also Be various operations object it is associated therewith be operation code, so-called operation code is to illustrate which kind of computer will execute, such as transmit, Operation, displacement such as jump at the operation, it is indispensable component part in instruction.
Above-mentioned, it is in the present embodiment finger URL " $ " that positioning label, which is the identifier for playing positioning action,.
It is above-mentioned, in the present embodiment, operator stack (OperatorStack), operand stack (OperatorDataStack) Initialization, while into operator be pressed into " $ " as motion control position, at this time pointer DSPointer direction logical expression The first address of formula, initialization operation are to operator stack and operand stack application memory headroom and some variable initializer shows, pressure Entering " $ " is a beginning flag as stack.
It is above-mentioned, it is to be understood that in computer science, pointer (Pointer) is an object in programming language, Using address, its value is pointing directly at (points to), and there are the values of another place in computer memory.Due to passing through address Required variable cell can be found, it may be said that be directed toward the variable cell in address.Therefore, address visualization is known as " pointer ". Mean the internal storage location that can be found by it using it as address.Some address in pointer reference memory, by being referred to as The movement of anti-reference pointer can take out the value stored in that address.
Step S20 judges whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and its described fortune The case where stack header element of operator stack is the positioning label;
It is above-mentioned, it is to be understood that include logical expression in operator stack, wherein logical expression, as uses logic The significant formula that operator connects relational expression or amount of logic.The value of logical expression is a logical value, That is " true " or " false ".C language compiling system indicates "true" when providing logic operation result, with number 1, with digital 0 table Show "false", but when whether judge an amount is "true", indicates "false" with 0, indicate "true" with non-zero.It should be noted that stack is first Element generally uses " $ " to accord with as origin identification, and encountering this identifier again after data take in stack indicates to terminate.
Step S30, if so, returning to the stack header element of the operand, execution terminates.
It is above-mentioned, it include logical expression in operator stack.Judge whether current operating conditions following situation: 1, pointer occur Be directed toward end, 2, stack header element be positioning label " $ ", meet when simultaneously, then reach Rule of judgment, the return first member of operand stack Element.
The execution method of compiled PLC based on motion controller provided in this embodiment a kind of passes through setting positioning mark Label, and executed with positioning label based on the compiled of motion controller according to the pointer for operator stack and operand stack The algorithm of PLC realizes motion control function by PLC programmed algorithm, improves the flexibility of compiled PLC algorithm, improve The speed of service, and then execution efficiency is improved, and method logic provided by the present invention is simple, controlling is strong.
Embodiment 2:
Referring to Fig. 3, second embodiment of the invention provides the execution method of compiled PLC based on motion controller a kind of, Based on above-mentioned first embodiment, the step S20 " judges whether to occur the logical expression that pointer is directed toward the operator stack End, and the stack header element of its operator stack be the positioning label the case where " after, further includes:
Step S40, if it is not, then judging whether the pointer direction is operand;
It is above-mentioned, if not occurring the end that pointer is directed toward the logical expression of the operator stack, and its described operator The case where stack header element of stack is the positioning label then judges pointer direction whether judge pointer direction is behaviour It counts.
Step S50 pushes operand described if pointer direction is the operand, moves back the operation Symbol, and " judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and its described operation described in return The case where stack header element for according with stack is the positioning label ";
Step S60 determines that the pointer is oriented to the operation if pointer direction is not the operand Symbol;
Step S70, the priority for the operator that the stack head operator and pointer of the operator stack are directed toward;
If what pointer was directed toward is not to be directed toward operator, and then be compared the operation of operator stack stack head for operand The priority of operator pointed by symbol and DSPointer pointer.
Step S80, if the priority of the stack head operator of the operator stack is less than the operator that the pointer is directed toward Priority, then executing terminates.
If the priority of the stack head operator of operator stack is compared with the priority for the operator that pointer is directed toward, stack head fortune Operator is less than pointer and is directed toward operator, then executing directly terminates.
Embodiment 3:
Referring to Fig. 4 and Fig. 5, third embodiment of the invention provides the execution of compiled PLC based on motion controller a kind of Method is based on above-mentioned second embodiment, and the step S70 " be directed toward by the stack head operator and pointer of the operator stack After the priority of the operator ", further includes:
Step S90, if the operator that the priority of the stack head operator of the operator stack is greater than pointer direction is excellent First grade then calculates the operator of the operator stack, generates operation result.
It is above-mentioned, the operator precedence of pointer direction is greater than if there is the priority of the stack head operator of operator stack, As in calculating process, operator that pointer is directed toward is since priority will be prior to the stack head operator of operator stack, then basis Priority calculates the operator of operator stack, and generates operation result.
The operation result is stored in the operand, the pointer is moved back by step S100, and " judgement described in return Whether end that pointer be directed toward the logical expression of the operator stack is occurred, and the stack header element of its operator stack is institute The case where stating positioning label ".
It is above-mentioned, after calculating, by result push operation number, and pointer is moved back and is rejudged and whether is occurred Pointer is directed toward the end of the logical expression of the operator stack, and the stack header element of its operator stack is positioning mark The case where label.
" the calculating the operator of the operator stack, generate operation result " includes:
Step S91 confirms the performance variable number of the operator;
Step S92 is obtained corresponding with the performance variable number in the operand stack according to the performance variable number The operand;
Step S93 calculates the operator of the operator stack, and generates the operation result.
It is above-mentioned, judge the operator of operator stack head, confirms the performance variable number of the operator, as confirm as several members Operator, such as unary operator, five n ary operations symbol.After the performance variable number of confirmation operator, according to the data, behaviour is obtained The operand corresponding with the performance variable number counted in stack;For example, calculate operator stack head operator, if It is unary operator, then takes out an operand from operand stack and then take out two from operand stack if binary operator A operand, etc. and so on, and then carry out operation and obtain operation result after operation.
Embodiment 4:
Referring to Fig. 6, fourth embodiment of the invention provides the execution method of compiled PLC based on motion controller a kind of, Based on above-mentioned 3rd embodiment, the step S70 " fortune that the stack head operator and pointer of the operator stack are directed toward After the priority of operator ", further includes:
Step S110, if the operator that the priority of the stack head operator of the operator stack is equal to pointer direction is excellent First grade then judges the both ends of the operator with the presence or absence of bracket character;
It is above-mentioned, the precedence of operator of pointer direction is equal to if there is the priority of the stack head operator of operator stack The case where grade, then carries out the judgement that operator both ends whether there is with bracket character.Bracket character is one kind of operator, is being transported Play the role of interrupting in operator and calculate.
Step S120, it is described to move back the operator and the finger if there are bracket characters at the both ends of the operator Needle, and return and " judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and its described operator stack Stack header element be the positioning label the case where ".
The case where there are brackets if there is operator both ends, then operator pops off processing, and pointer is moved back, and is returned The end for the logical expression for judging whether to occur that pointer is directed toward the operator stack back into row, and the stack of its operator stack The case where header element is the positioning label.Both ends bracket identifies the priority that operator calculates, such as when addition subtraction multiplication and division operation Waiting insertion of brackets indicates that priority improves.
Embodiment 5:
Referring to Fig. 7 and Fig. 8, fifth embodiment of the invention provides the execution of compiled PLC based on motion controller a kind of Method is based on above-mentioned first embodiment, step S10 " initialization operator stack and the operand stack, in the operator stack Before setting positioning label in operator first address ", further includes:
Step S130 determines controller type, and generates LD instruction set and IL instruction set according to the controller type;
It is above-mentioned, it is to be understood that controller refer to according to predetermined order change main circuit or control circuit wiring and Resistance value enables device to control starting, speed regulation, braking and reversely main of motor in change circuit.By program counter, refer to Register, command decoder, clock generator and operation controller composition are enabled, it is publication order " policy-making body ", i.e., complete At the operation for coordinating and commanding entire computer system.It should be noted that controller type refers to that producer can be according to difference Application and object open portion function and instruction, i.e., the function that different controller models is supported be not quite similar.
It is above-mentioned, the analysis to controller type is carried out, so that it is determined that the type of controller, and then it is directed to different controllers Type generates different LD and IL instruction set.
Step S140 generates Complied executing file according to the LD instruction set and the IL instruction set, in order to be based on institute State initialization and operation that Complied executing file carries out the operator stack and the operand stack.
It is above-mentioned, by LD instruction set and IL instruction set, to generate Complied executing file, can carry out further for The operation of operator.
The step S140 " generating Complied executing file according to the LD instruction set and the IL instruction set " includes:
Step S141 generates new IL instruction set according to the LD instruction set and the IL instruction set, and according to described new Instruction set obtain program listing and variable list;
Step S142 carries out morphology and syntactic analysis to the classification of the IL instruction set respectively, by each IL instruction set Morphology and grammer generative grammar tree;
It is above-mentioned, when carrying out generating Complied executing file, the analysis of PLC program file need to be carried out, and according to LD instruction and IL instruction generates new IL instruction set.New IL instruction set is analyzed, program listing is formed and variable list two divides greatly Branch.Wherein, variable list includes subprogram local variable, interrupt routine local variable and global variable program listing branch;It is right Program listing carries out classification analysis, forms three kinds of main program, subprogram and interrupt routine lists, and respectively for three kinds of programs into Row instruction analysis;Carry out morphology and syntactic analysis respectively for the classification of IL instruction catalogue, by the grammer of all IL instruction set and Morphology pools together to form syntax tree.It should be noted that a series of grammer number, that is, syntax rules composition set.
Step S143, according to the syntax tree and the variable list synthesis program file table, and to described program file Program file in list carries out CRC check, generates Complied executing file.
It is above-mentioned, syntax tree and variable list are converted together and generate program file table, including LD, IL file, global variable File, project file, PLC allocation list, detection argument table etc.;Some program files of generation are finally subjected to CRC check, and It is packaged and generates a compressed Complied executing file.
Embodiment 6:
In order to better understand the present invention, provided by the invention a kind of based on the compiled of motion controller referring to Fig. 9 The execution method of PLC includes the following:
1, controller class type analysis is carried out first, and different LD and IL instruction set is generated for different controller types;
2, PLC program file analysis is then carried out, completely new IL is generated according to LD instruction and IL instruction and is instructed;
3, set analysis is instructed according to new IL, forms program listing and variable list Liang great branch, program listing branch turns Step (4), variable list include subprogram local variable, interrupt routine local variable and global variable again;
4, program listing carries out classification analysis again, forms three kinds of main program, subprogram and interrupt routine lists, and respectively Instruction analysis is carried out for three kinds of programs;
5, morphology and syntactic analysis are carried out respectively for the classification of IL instruction catalogue, by the grammer and word of all IL instruction set Method, which is pooled to, is formed together syntax tree;
6, the variable list generated in syntax tree and step (3) is converted together and generates program file table, including LD, IL text Part, global variable file, project file, PLC allocation list, detection argument table etc.;
7, some program files of generation are finally subjected to CRC check, and are packaged and generate a compressed Complied executing File, in order to carry out the initialization and operation of the operator stack and the operand stack based on the Complied executing file.
8, initialization is substantially carried out operator stack (OperatorStack), operand stack (OperatorDataStack) Initialization, while it being pressed into " $ " into operator, DSPointer is directed toward the first address of logical expression;
If 9, DSPointer is directed toward the end of logical expression, and logical expression stack header element is also " $ ", i.e., Indicating to calculate terminates, and returns to operand stack header element, otherwise goes to step 10;
10, judge DSPointer direction is operand or operator, if operator then turns to step 11, if Operand then pushes operand, and operator moves back, and goes to step 9;
11, the priority of operator pointed by the operator of comparison operator stack stack head and DSPointer, if the two Priority is identical, turns to step 12, then turns to step 13 if it is being greater than, and then turns to step 14 if it is being less than;
If 12, the right and left is bracket, operator stack is popped off, and DSPointer is moved back, and turns to step 9;
13, the operator for calculating operator stack head then takes out an operation if unary operator from operand stack Number then takes out two operands, by result push operation number, this luck after operation if binary operator from operand stack Terminate, DSPointer is moved back, and goes to step 9;
14, executing terminates.
A kind of execution method of the compiled PLC based on motion controller provided by for a better understanding of the present invention, With reference to Figure 10-12, the PLC kernel and the data interactive mode of BASIC kernel in the present invention are as follows:
In order to give full play to the powerful motion control function of controller and the logical operation function of performance and PLC, holding Row part retains PLC kernel and BASIC kernel simultaneously, and based on PLC kernel, supplemented by BASIC kernel, PLC mainly executes logic Calculation function, and BASIC kernel can be called to realize motion control function.
1, data interaction is realized by shared drive mode between PLC and BASIC.
1.1 PLC send data to BASIC:
PLC sends information to BASIC and carries out data using the data area F, and range is G0~G255 such as G0.0, interaction parameter It is placed on the specified region V storing data, which can be using fixed memory region for storing interaction parameter;
1.2 BASIC send data to PLC:
BASIC sends information to PLC and carries out data using the data area F, and range is F0~F255 such as F0.0, interaction parameter It is placed on the specified region V storing data, which can be using fixed memory region for storing interaction parameter.
2, in order to better describe the data interactive mode between PLC and BASIC, below by realize return to zero function for into Row description.
It is related to the relevant instruction of motion control and realizes that PLC is only responsible for transmission data and life in part using the part BASIC It enables, illustrates the data exchange process between PLC and BASIC by taking PLC calls axis to return to zero as an example below.
G:PLC sends message to BASIC;
F:BASIC sends message to PLC;
D_DATA: parameter stores shared region;
With reference to the interaction flow for returning to zero function in Figure 12, process is as follows:
When 2.1 PLC kernels go to axis and return to zero instruction, first to the acquisition of shared data memory field return to zero parameter such as axis number, Return to zero mode, return to zero at a slow speed speed, return to zero the correlations such as rapid pace, Acceleration and deceleration time and return to zero parameter;
2.2, which send G0.0X axis to BASIC kernel, starts to return to zero instruction;
2.3 BASIC kernels receive return to zero instruction after start that motor function BOB(beginning of block) is called to return to zero operation, while to PLC hair It send F0.0 instruction feedback axis to have begun entrance and returns to zero state;
2.4 sending F0.1 to PLC when BASIC kernel returns to zero completion or returns to zero mistake feeds back to zero completion status, Zero error code is sent back to shared section key simultaneously.
In addition, referring to Fig.1 3, the executive device of the present invention also provides a kind of compiled PLC based on motion controller, packet Include locating module 10, judgment module 20 and return module 30;
The locating module 10, it is first in the operator of the operator stack for initializing operator stack and operand stack Setting positioning label in address;
The judgment module 20, the end of the logical expression for judging whether to occur that pointer is directed toward the operator stack Tail, and the stack header element of its operator stack be the positioning label the case where;
The return module 30, for if so, returning to the stack header element of the operand, execution to terminate.
In addition, the present invention also provides a kind of user terminal, including memory and processor, the memory is for storing base In the execution program of the compiled PLC of motion controller, the processor runs the compiled PLC based on motion controller Execution program so that the user terminal executes the execution method of the compiled PLC as described above based on motion controller.
In addition, being stored on the computer readable storage medium the present invention also provides a kind of computer readable storage medium There are the execution program of the compiled PLC based on motion controller, the execution program of the compiled PLC based on motion controller The execution method of the compiled PLC as described above based on motion controller is realized when being executed by processor.
It should be noted that, in this document, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that the process, method, article or the system that include a series of elements not only include those elements, and And further include other elements that are not explicitly listed, or further include for this process, method, article or system institute it is intrinsic Element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that including being somebody's turn to do There is also other identical elements in the process, method of element, article or system.
The serial number of the above embodiments of the invention is only for description, does not represent the advantages or disadvantages of the embodiments.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can be realized by means of software and necessary general hardware platform, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical solution of the present invention substantially in other words does the prior art The part contributed out can be embodied in the form of software products, which is stored in one as described above In storage medium (such as ROM/RAM, magnetic disk, CD), including some instructions are used so that terminal device (it can be mobile phone, Computer, server or network equipment etc.) execute method described in each embodiment of the present invention.
The above is only a preferred embodiment of the present invention, is not intended to limit the scope of the invention, all to utilize this hair Equivalent structure or equivalent flow shift made by bright specification and accompanying drawing content is applied directly or indirectly in other relevant skills Art field, is included within the scope of the present invention.

Claims (9)

1. a kind of execution method of the compiled PLC based on motion controller characterized by comprising
Operator stack and operand stack are initialized, the setting positioning label in the operator first address of the operator stack;
Judge whether the end for the logical expression for occurring that pointer is directed toward the operator stack, and the stack of its operator stack is first The case where element is the positioning label;
If so, returning to the stack header element of the operand, execution terminates;
If it is not, then judging whether the pointer direction is operand;
If pointer direction is operand, push operand described, move back operator, and " judgement is described in returning The no end for pointer occur and being directed toward the logical expression of the operator stack, and the stack header element of its operator stack is described The case where positioning label ";
If what the pointer was directed toward is not the operand, determine that the pointer is oriented to operator;
The priority for the operator that the stack head operator and pointer for comparing the operator stack are directed toward;
If the priority of the stack head operator of the operator stack is less than the priority for the operator that the pointer is directed toward, execute Terminate.
2. the execution method of the compiled PLC based on motion controller as described in claim 1, which is characterized in that described " to compare After the priority for the operator that the stack head operator and pointer of the operator stack are directed toward ", further includes:
If the priority of the stack head operator of the operator stack is greater than the operator precedence that the pointer is directed toward, institute is calculated The operator of operator stack is stated, operation result is generated;
The operation result is stored in the operand, the pointer is moved back, and " judges whether that pointer occur refers to described in return To the end of the logical expression of the operator stack, and the stack header element of its operator stack is the feelings of the positioning label Condition ".
3. the execution method of the compiled PLC based on motion controller as claimed in claim 2, which is characterized in that described " to calculate The operator of the operator stack generates operation result " include:
Confirm the performance variable number of the operator;
The operand corresponding with the performance variable number in the operand stack is obtained according to the performance variable number;
The operator of the operator stack is calculated, and generates the operation result.
4. the execution method of the compiled PLC based on motion controller as described in claim 1, which is characterized in that described " to compare After the priority for the operator that the stack head operator and pointer of the operator stack are directed toward ", further includes:
If the priority of the stack head operator of the operator stack is equal to the operator precedence that the pointer is directed toward, institute is judged The both ends of operator are stated with the presence or absence of bracket character;
If the both ends of the operator move back the operator and the pointer there are bracket character, and return and " judge whether There is the end that pointer is directed toward the logical expression of the operator stack, and the stack header element of its operator stack is described fixed The case where position label ".
5. the execution method of the compiled PLC based on motion controller as described in claim 1, which is characterized in that described " initial Change operator stack and operand stack, the setting positioning label in the operator first address of the operator stack " before, further includes:
It determines controller type, and generates LD instruction set and IL instruction set according to the controller type;
Complied executing file is generated according to the LD instruction set and the IL instruction set, in order to be based on the Complied executing file Carry out the initialization and operation of the operator stack and the operand stack.
6. the execution method of the compiled PLC based on motion controller as claimed in claim 5, which is characterized in that described " according to The LD instruction set and the IL instruction set generate Complied executing file " include:
New IL instruction set is generated according to the LD instruction set and the IL instruction set, and journey is obtained according to the new instruction set Sequence table and variable list;
Morphology and syntactic analysis are carried out to the classification of the IL instruction set respectively, the morphology of each IL instruction set and grammer are generated Syntax tree;
According to the syntax tree and the variable list synthesis program listed files, and to the program in described program listed files File carries out CRC check, generates Complied executing file.
7. a kind of executive device of the compiled PLC based on motion controller, which is characterized in that including locating module, judge mould Block, return module and comparison module;
The locating module, for initializing operator stack and operand stack, in the operator first address of the operator stack Setting positioning label;
The judgment module, the end of the logical expression for judging whether to occur that pointer is directed toward the operator stack, and its The case where stack header element of the operator stack is the positioning label;
The return module, for if so, returning to the stack header element of the operand, execution to terminate;
The judgment module is also used to if it is not, then judging whether the pointer direction is operand;If the pointer direction is Operand then pushes operand described, moves back operator, and again judgment module with judge whether to occur pointer be directed toward described in The end of the logical expression of operator stack, and the stack header element of its operator stack be the positioning label the case where;If What the pointer was directed toward is not the operand, then determines that the pointer is oriented to operator;
The comparison module, for the operator stack stack head operator and pointer be directed toward the operator it is preferential Grade;
The return module, if the priority for being also used to the stack head operator of the operator stack is less than the fortune that the pointer is directed toward The priority of operator, then executing terminates.
8. a kind of user terminal, which is characterized in that including memory and processor, the memory is for storing based on movement control The execution program of the compiled PLC of device processed, the processor run the execution journey of the compiled PLC based on motion controller Sequence is so that the user terminal executes holding for the compiled PLC as described in any one of claim 1-6 based on motion controller Row method.
9. a kind of computer readable storage medium, which is characterized in that be stored on the computer readable storage medium based on fortune The execution program of the compiled PLC of movement controller, the execution program of the compiled PLC based on motion controller is by processor The execution method of the compiled PLC as described in any one of claim 1-6 based on motion controller is realized when execution.
CN201810170399.6A 2018-04-16 2018-04-16 A kind of execution method and apparatus of the compiled PLC based on motion controller Active CN108303948B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201810170399.6A CN108303948B (en) 2018-04-16 2018-04-16 A kind of execution method and apparatus of the compiled PLC based on motion controller

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201810170399.6A CN108303948B (en) 2018-04-16 2018-04-16 A kind of execution method and apparatus of the compiled PLC based on motion controller

Publications (2)

Publication Number Publication Date
CN108303948A CN108303948A (en) 2018-07-20
CN108303948B true CN108303948B (en) 2019-11-15

Family

ID=62849233

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201810170399.6A Active CN108303948B (en) 2018-04-16 2018-04-16 A kind of execution method and apparatus of the compiled PLC based on motion controller

Country Status (1)

Country Link
CN (1) CN108303948B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254776B (en) * 2018-09-29 2022-02-01 深圳市雷赛控制技术有限公司 Multi-language code compiling method and compiler
CN113341864A (en) * 2021-06-07 2021-09-03 重庆高新技术产业研究院有限责任公司 PLC-based control similarity reversible logic system and analysis method thereof

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100392661C (en) * 2004-07-17 2008-06-04 周建龙 New producing method for programmable observing and cotnrol equipment
CN101587445A (en) * 2009-06-19 2009-11-25 国网电力科学研究院 PLC compiling implement method
DE102015105436A1 (en) * 2015-04-09 2016-10-13 Beckhoff Automation Gmbh Translation module, processing module and control system

Also Published As

Publication number Publication date
CN108303948A (en) 2018-07-20

Similar Documents

Publication Publication Date Title
CN105760201B (en) A kind of starting method and apparatus of embedded equipment
US6134707A (en) Apparatus and method for in-system programming of integrated circuits containing programmable elements
Edwards Languages for Digital Embedded Systems
US7886234B2 (en) Systems and methods for creating embedded target images
CN102053836B (en) Implementation method of version management tool for Android application development
CN110990019B (en) Java class analysis method and device, storage medium and electronic equipment
CN103488466B (en) Method and device for executing application program
CN106126397A (en) The processing method of program crashing message and system
CN108303948B (en) A kind of execution method and apparatus of the compiled PLC based on motion controller
US20070067471A1 (en) Message translation systems and methods
JP2010517134A (en) Heterogeneous program linkage method and its middleware platform engine
CN101859245A (en) Method and device for generating user interface
CN106980597B (en) System-on-chip verification method and system
CN108647032B (en) Application loading method and device, computer device and computer readable storage medium
CN110007926B (en) Language conversion method and device
US20210365258A1 (en) Method and system for updating legacy software
CN107407922A (en) The control method and control program of programmable logic controller (PLC), programmable logic controller (PLC)
CN106020905A (en) Microcontroller firmware developing and updating method and system
CN106796521B (en) API version control independent of product release
CN109947432A (en) Assembler processing method and relevant apparatus
CN109074336A (en) For transmitting the system and method being programmed to the data in microcontroller
CN110113391B (en) Client online method and device and client operation method and device
US7114153B2 (en) Method and apparatus for continuation-passing in a virtual machine
CN110659022B (en) Method for automatically calling Python script based on Java
CN106484375B (en) Instruction block loading method, soft switch equipment and system

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
GR01 Patent grant
GR01 Patent grant