CN108303948A - 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
CN108303948A
CN108303948A CN201810170399.6A CN201810170399A CN108303948A CN 108303948 A CN108303948 A CN 108303948A CN 201810170399 A CN201810170399 A CN 201810170399A CN 108303948 A CN108303948 A CN 108303948A
Authority
CN
China
Prior art keywords
stack
operator
pointer
operand
motion controller
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.)
Granted
Application number
CN201810170399.6A
Other languages
Chinese (zh)
Other versions
CN108303948B (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, wherein the method 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 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 positions label by setting, 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 algorithms, improve the flexibility of compiled PLC algorithms, improve the speed of service, and then execution efficiency is 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 technology
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, 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 at and is 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 efficiencys are 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.
Invention content
In view of this, the present invention provides a kind of execution method and apparatus of the compiled PLC based on motion controller to solve Certainly the deficiencies in the prior art.
To achieve the above object, the present invention provides a kind of execution method of the compiled PLC based on motion controller, 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 include:
If it is not, then judging whether the pointer direction is operand;
If the pointer direction is the operand, pushes operand described, move the operator afterwards, 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, judge that the pointer is oriented to the operator;
Compare the priority of the stack head operators of the operator stack and the operator of pointer direction;
If the priority of the stack head operators 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 operators and pointer of the operator stack are directed toward it is preferential After grade ", further include:
If the priority of the stack head operators of the operator stack is more 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, will be moved after the pointer, 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 operators and pointer of the operator stack are directed toward it is preferential After grade ", further include:
If the priority of the stack head operators 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, the operator and the pointer are moved after described, 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 include:
It determines controller type, and LD instruction set and IL instruction set is generated 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 positions label by setting, and with positioning label execute based on fortune 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 algorithms, 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.
Description of the drawings
Fig. 1 is that the present invention is based on the hardware fortune that the execution embodiment of the method scheme of the compiled PLC of motion controller is related to 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 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 that the present invention is based on the back to zero function of the execution method sixth embodiment of the compiled PLC of motion controller letters Cease interaction flow schematic diagram;
Figure 13 is that the present invention is based on the high-level schematic 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 implementation mode
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 description purposes only, it is not understood to indicate or imply 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 this feature.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;Can be that machinery connects It connects, can also be electrical connection;It can be directly connected, can also can be indirectly connected through an intermediary in two elements 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.
Terminal of the embodiment of the present invention can be PC, can also be smart mobile phone, tablet computer, pocket computer etc. have it is 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 may include optionally that (such as WI-FI connects standard wireline interface and wireless interface Mouthful).Memory 1005 can be high-speed RAM memory, can also be stable memory, such as magnetic disk storage.Memory The 1005 optional storage devices that can also be 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 components arrangement are either 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 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 algorithms, improves the flexibility of compiled PLC algorithms, improves the speed of service, into And execution efficiency is improved, and method logic provided by the present invention is simple, controlling is strong.
Embodiment 1:
With reference to Fig. 2, first embodiment of the invention provides a kind of execution method of the compiled PLC based on motion controller, Including:
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. To stack be inserted into new element also referred to as push on, 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 It counts (AX 5678H).Operand itself can be put in operand this field, operation address can also be put, behaviour can also be put Make the computational methods 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 redirect at the operations, it is indispensable component part in instruction.
Above-mentioned, positioning label is the identifier for playing positioning action, is in the present embodiment finger URL " $ ".
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 It is a beginning flag as stack to enter " $ ".
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 action 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 operator stack includes logical expression, 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, "true" is indicated with non-zero.It should be noted that stack is first Element generally uses " $ " to be accorded with as origin identification, encounters this identifier again after data take in stack and indicates to terminate.
Step S30, if so, returning to the stack header element of the operand, execution terminates.
Above-mentioned, operator stack includes logical expression.Judge whether current operating conditions following situation occur:1, pointer 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 a kind of compiled PLC based on motion controller provided in this embodiment, by the way that positioning mark is arranged Label, and executed based on the compiled of motion controller with positioning label according to the pointer for operator stack and operand stack The algorithm of PLC realizes motion control function by PLC programmed algorithms, improves the flexibility of compiled PLC algorithms, 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:
With reference to Fig. 3, second embodiment of the invention provides a kind of execution method of the compiled PLC based on motion controller, 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 include:
Step S40, if it is not, then judging whether the pointer direction is operand;
It is above-mentioned, if do not occur 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 the operation afterwards 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 judges that the pointer is oriented to the operation if pointer direction is not the operand Symbol;
Step S70, the priority of the operator of stack head operators and the pointer direction of the operator stack;
If what pointer was directed toward is not that operand is to be directed toward operator, and then be compared the operation of operator stack stack head The priority of operator pointed by symbol and DSPointer pointers.
Step S80, if the priority of the stack head operators of the operator stack is less than the operator that the pointer is directed toward Priority then executes and terminates.
If the priority of the stack head operators 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 executes and directly terminate.
Embodiment 3:
With reference to Fig. 4 and Fig. 5, third embodiment of the invention provides a kind of execution of the compiled PLC based on motion controller Method is based on above-mentioned second embodiment, and the step S70 " be directed toward by the stack head operators and pointer of the operator stack After the priority of the operator ", further include:
Step S90, if the operator that the priority of the stack head operators of the operator stack is more 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 more than if there is the priority of the stack head operators of operator stack, As in calculating process, operator that pointer is directed toward is since priority will be prior to the stack head operators of operator stack, then basis Priority calculates the operator of operator stack, and generates operation result.
The operation result is stored in the operand, will be moved after the pointer, and " judged described in return by step S100 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 it will move and rejudged after pointer and whether 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 marked for the positioning 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 for confirming operator, according to the data, behaviour is obtained The operand corresponding with the performance variable number counted in stack;For example, calculate the operator of operator stack head, 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:
With reference to Fig. 6, fourth embodiment of the invention provides a kind of execution method of the compiled PLC based on motion controller, Based on above-mentioned 3rd embodiment, the step S70 " fortune that the stack head operators and pointer of the operator stack are directed toward After the priority of operator ", further include:
Step S110, if the operator that the priority of the stack head operators of the operator stack is equal to pointer direction is excellent First grade then judges that the both ends of the operator whether there is 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 operators 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 moves the operator and the finger if there are bracket characters at the both ends of the operator after described 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 pop off processing, will be moved after pointer, and 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.The priority that both ends bracket mark operator calculates, such as when addition subtraction multiplication and division operation It waits insertion of brackets and indicates that priority improves.
Embodiment 5:
With reference to Fig. 7 and Fig. 8, fifth embodiment of the invention provides a kind of execution of the compiled PLC based on motion controller 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 include:
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 Change resistance value in circuit and enables device to control startup, speed governing, braking and reversely main of motor.By program counter, refer to Register, command decoder, clock generator and operation and control device 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 refer to producer can be according to difference Application scenario 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, in order to be based on according to the LD instruction set and the IL instruction set 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, you 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 respectively to the classification of the IL instruction set, 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 instructions and IL instructions generate new IL instruction sets.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 be directed to respectively three kinds of programs into Row instruction analysis;Carry out morphology and syntactic analysis respectively for the classification of IL instruction catalogues, by the grammer of all IL instruction set and Morphology pools together to form syntax tree.It should be noted that a series of set of grammer number, that is, syntax rules composition.
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 lists, 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 with reference to Fig. 9 The execution method of PLC includes as follows:
1, controller class type analysis is carried out first, and different LD and IL instruction set is generated for different controller types;
2 and then PLC program file analysis is carried out, generating completely new IL according to LD instructions and IL instructions instructs;
3, set analysis is instructed according to new IL, forms program listing and variable list Liang great branches, 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 catalogues, by the grammer and word of all IL instruction set Method pools together to form 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 lists, 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., It indicates to calculate and terminate, return to operand stack header element, otherwise go to step 10;
10, judge DSPointer directions is operand or operator, if operator then turns to step 11, if Operand then pushes operand, and is moved after operator, goes to step 9;
11, the priority of the operator and the operator pointed by DSPointer of comparison operator stack stack head, if the two Priority is identical, turns to step 12, if it is more than then turning to step 13, if it is less than then turning to step 14;
If 12, the right and left is bracket, operator stack pops off, and is moved after DSPointer, 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, moved after DSPointer, goes to step 9;
14, it executes and terminates.
The execution method of the compiled PLC based on motion controller provided for a better understanding of the present invention a kind of, With reference to figure 10-12, the PLC kernels and the data interactive mode of BASIC kernels in the present invention are as follows:
In order to give full play to controller powerful motion control function and performance and PLC logical operation function, holding Row part retains PLC kernels and BASIC kernels simultaneously, and based on PLC kernels, supplemented by BASIC kernels, PLC mainly executes logic Calculation function, and BASIC kernels can be called to realize motion control function.
1, data interaction is realized by shared drive mode between PLC and BASIC.
1.1 PLC are to BASIC transmission datas:
PLC sends information to BASIC and carries out data, ranging from G0~G255 such as G0.0, interaction parameter using the data areas F The specified regions V storage data are placed on, which may be used fixed memory region for storing interaction parameter;
1.2 BASIC are to PLC transmission datas:
BASIC sends information to PLC and carries out data, ranging from F0~F255 such as F0.0, interaction parameter using the data areas F The specified regions V storage data are placed on, which may be used fixed memory region for storing interaction parameter.
2, in order to preferably describe the data interactive mode between PLC and BASIC, below for realizing back to zero function 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 parts BASIC It enables, illustrates the data exchange process between PLC and BASIC by taking PLC calls axis back 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 of the back to zero function in figure 12, flow is as follows:
When 2.1 PLC kernels go to the instruction of axis back to zero, first to shared data memory field obtain back to zero parameter such as axis number, Back to zero pattern, the back to zero related back to zero parameter such as speed, back to zero rapid pace, Acceleration and deceleration time at a slow speed;
2.2 send G0.0X axis to BASIC kernels starts back to zero instruction;
2.3 BASIC kernels start to call the operation of motor function BOB(beginning of block) back to zero after receiving back to zero instruction, while being sent out to PLC F0.0 instruction feedback axis is sent to have begun to enter back to zero state;
2.4 send F0.1 when the completion of BASIC kernel back to zeros or back to zero mistake to PLC feeds back to zero completion status, Simultaneously zero error code is sent back to shared section key.
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 It includes locating module 10, judgment module 20 and returns to 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 operation 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, the present invention also provides a kind of computer readable storage medium, stored on the 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 herein, the terms "include", "comprise" or its any other variant are intended to non-row His property includes, so that process, method, article or system including a series of elements include not only 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 this There is also other identical elements in the process of element, method, article or system.
The embodiments of the present invention are for illustration only, can not represent the quality of embodiment.
Through the above description of the embodiments, those skilled in the art can be understood that above-described embodiment side Method can add the mode of required general hardware platform to realize by software, naturally it is also possible to by hardware, but in many cases The former is more preferably embodiment.Based on this understanding, technical scheme of the present invention substantially in other words does the prior art Going out the part of contribution can be expressed in the form of software products, which is stored in one as described above In storage medium (such as ROM/RAM, magnetic disc, CD), including some instructions use so that a station terminal equipment (can be mobile phone, Computer, server or network equipment etc.) execute method described in each embodiment of the present invention.
It these are only the preferred embodiment of the present invention, be not intended to limit the scope of the invention, it is every 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 (10)

1. a kind of execution method of the compiled PLC based on motion controller, which is characterized in that including:
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.
2. the execution method of the compiled PLC based on motion controller as described in claim 1, which is characterized in that described " to judge 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 After the case where stating positioning label ", further include:
If it is not, then judging whether the pointer direction is operand;
If the pointer direction is the operand, push operand described, moves the operator afterwards, and described in 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 ";
If what the pointer was directed toward is not the operand, judge that the pointer is oriented to the operator;
Compare the priority of the stack head operators of the operator stack and the operator of pointer direction;
If the priority of the stack head operators of the operator stack is less than the priority for the operator that the pointer is directed toward, execute Terminate.
3. the execution method of the compiled PLC based on motion controller as claimed in claim 2, which is characterized in that described " to compare After the priority for the operator that the stack head operators and pointer of the operator stack are directed toward ", further include:
If the priority of the stack head operators of the operator stack is more 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, will be moved after the pointer, and " judges whether that pointer occur refers to described in return To the end of the logical expression of the operator stack, and the feelings that the stack header element of its operator stack is the positioning label Condition ".
4. the execution method of the compiled PLC based on motion controller as claimed in claim 3, 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.
5. the execution method of the compiled PLC based on motion controller as claimed in claim 2, which is characterized in that described " to compare After the priority for the operator that the stack head operators and pointer of the operator stack are directed toward ", further include:
If the priority of the stack head operators of the operator stack is equal to the operator precedence that the pointer is directed toward, institute is judged The both ends for stating operator whether there is bracket character;
If there are bracket characters at the both ends of the operator, the operator and the pointer are moved after described, and return and " judge 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 ".
6. 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 include:
It determines controller type, and LD instruction set and IL instruction set is generated 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.
7. the execution method of the compiled PLC based on motion controller as claimed in claim 6, 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 respectively to the classification of the IL instruction set, the morphology of each IL instruction set and grammer are generated Syntax tree;
According to the syntax tree and the variable list synthesis program file table, and to the program text in described program listed files Part carries out CRC check, generates Complied executing file.
8. a kind of executive device of the compiled PLC based on motion controller, which is characterized in that including locating module, judge mould Block and return 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.
9. 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 execution journey of the processor operation compiled PLC based on motion controller Sequence is so that the user terminal executes the compiled PLC based on motion controller as described in any one of claim 1-7 and holds Row method.
10. 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 based on motion controller as described in any one of claim 1-7 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 true CN108303948A (en) 2018-07-20
CN108303948B 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)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254776A (en) * 2018-09-29 2019-01-22 深圳市雷赛控制技术有限公司 Multilingual code compiling method and compiler
CN110852053A (en) * 2019-10-18 2020-02-28 平安医疗健康管理股份有限公司 Report generation method and device based on suffix stack technology
CN113341864A (en) * 2021-06-07 2021-09-03 重庆高新技术产业研究院有限责任公司 PLC-based control similarity reversible logic system and analysis method thereof

Citations (3)

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

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1588254A (en) * 2004-07-17 2005-03-02 周建龙 New producing method for programmable observing and cotnrol equipment
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
US20180032055A1 (en) * 2015-04-09 2018-02-01 Beckhoff Automation Gmbh Translation module, processing module and control system

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张翰: "《集成运动控制功能的软PLC系统的研究与实现》", 《中国优秀硕士学位论文全文数据库 信息科技辑》 *

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109254776A (en) * 2018-09-29 2019-01-22 深圳市雷赛控制技术有限公司 Multilingual code compiling method and compiler
CN109254776B (en) * 2018-09-29 2022-02-01 深圳市雷赛控制技术有限公司 Multi-language code compiling method and compiler
CN110852053A (en) * 2019-10-18 2020-02-28 平安医疗健康管理股份有限公司 Report generation method and device based on suffix stack technology
CN113341864A (en) * 2021-06-07 2021-09-03 重庆高新技术产业研究院有限责任公司 PLC-based control similarity reversible logic system and analysis method thereof

Also Published As

Publication number Publication date
CN108303948B (en) 2019-11-15

Similar Documents

Publication Publication Date Title
CN108303948B (en) A kind of execution method and apparatus of the compiled PLC based on motion controller
US7739696B2 (en) Message translation systems and methods
CN110780897B (en) Code changing method and device
CN103902520B (en) Subject editing method and mobile terminal
CN106598581A (en) ASTERIX message parsing code generation method based on XML
CN108647032B (en) Application loading method and device, computer device and computer readable storage medium
CN112565047B (en) Method, device, equipment and medium for constructing network by using VPP in docker
CN107407922A (en) The control method and control program of programmable logic controller (PLC), programmable logic controller (PLC)
CN110989487B (en) PLC initialization method and device for industrial server and readable storage medium
CN104572034B (en) A kind of implementation method and device for cancelling and/or reforming
CN106648666A (en) User interface generating method and user interface generating system
CN110069312A (en) A kind of method and device of UI component Configuration and generation UI Component Gallery
CN106020905A (en) Microcontroller firmware developing and updating method and system
CN109947432A (en) Assembler processing method and relevant apparatus
CN112269566B (en) Script generation processing method, device, equipment and system
CN100485660C (en) Method and system for disolaying animation files
CN110941443B (en) Method and device for modifying file name in SDK (software development kit) and electronic equipment
CN106484375B (en) Instruction block loading method, soft switch equipment and system
CN108108300A (en) The resource configuration detection method and device of a kind of operating system
Yoong et al. Efficient implementation of IEC 61499 function blocks
CN108108161A (en) Support the access system and method for SDK by all kinds of means
CN116414494A (en) Service processing method, device, equipment and storage medium
CN104461938A (en) Method and device for reading data
CN114936045A (en) Automatic configuration method and system for IO (input/output) driving module of MCAL (micro channel logic) and storage medium
CN105335153A (en) Dynamic script automatic-generating method

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