Summary of the invention
Order send mode existence for digital control system in prior art is difficult to avoid weak points such as " starvation of data ", the technical problem to be solved in the present invention is to provide a kind of handling property that can adapt to the digital control system motion controller, avoids the implementation method of the command multi-transmitting mechanism that is used for digital control system of generation " starvation of data " in the motion controller Interpolation Process.
For solving the problems of the technologies described above, the technical solution used in the present invention is:
The implementation method that the present invention is used for the command multi-transmitting mechanism of digital control system comprises the following steps:
When digital control system starts, carry out initialization operation, need to determine the order number of transmission;
Task controller in digital control system repeatedly sends command information according to the order number in the individual task control cycle, two shared communication buffer districts by digital control system pass to the motion controller in digital control system; Two shared communication buffer districts are respectively as command buffer and state buffer;
Motion controller receives many command informations within the single motion control cycle, be stored in the motion control formation.
Repeatedly sending the command information process in the individual task control cycle is:
Work procedure to input makes an explanation, the command forms that the system of obtaining can identify;
The processing sequence of steering order and processing logic are processed the order that part needs to process immediately by the mentioned order form;
With the demanded storage after processing in the task formation, updating task formation correlation parameter simultaneously;
Whether the status information that judges a upper order is returned;
If the status information of a upper order is returned, empty and wait for counting;
Take out an order from task queue, write the interim order array;
Judge whether to continue write order;
If do not continue write order, send to motion controller and write the termination order;
Task controller writes the content in the interim order array in the order array of command buffer;
Update command number empties the interim order array;
The task control of this cycle finishes, and enters the next task control cycle.
If the continuation write order is back to and takes out a commands steps from task queue.
If the status information of a upper order is not returned, wait for that counting is cumulative;
Judgement waits for whether counting surpasses the counting boundary value that system arranges;
If do not surpass this counting boundary value, return to the status information that judges a upper order and whether return to step.
If surpass this counting boundary value, system produces the information that reports an error;
The task control of this cycle finishes, and enters the next task control cycle.
Motion controller receives many command informations within the single motion control cycle, be stored in the motion control formation, and its process is:
Judge that motion controller whether can reading order;
If can reading order, the order in the order array of distribution command buffer zone be in command queue;
Status information in the update mode buffer zone;
Carry out the machining control function in motion controller.
If motion controller can not reading order, directly carry out the machining control function;
The motion control of this cycle finishes, and enters the next motion control cycle.
The present invention has following beneficial effect and advantage:
1. efficient is high.Use the inventive method " prediction " or " pre-service " hop count of the minimum that guarantees that the digital control system operation is level and smooth can be set before program operation beginning, reduce the digital control system processing front stand-by period of operation, improved to a certain extent the execution efficient of digital control system.
2. speed is fast.Use the order transmission speed that the inventive method can improve digital control system, solved " starvation of data " problem in digital control system high-speed cruising process.
3. highly versatile.The inventive method is not changed traditional digital control system task control formation and send function and the related command structure type of ordering in the motion control formation, has extremely strong versatility.
4. dirigibility is good.The inventive method provides the parameter configuration function, and the user can send at most the ultimate values of order number by the CONFIG.SYS modified application cycle, task control cycle and the motion control cycle of combining with digital control system, obtains optimum efficiency.
Embodiment
The present invention is used for the implementation method of the command multi-transmitting mechanism of digital control system, in conjunction with shared communication buffer district's write access mutual exclusion principle, on the basis of analyzing numerically controlled system task control cycle and motion control cyclophysis, when proposition can guarantee that two shared communication buffer districts are poor, the command multi-transmitting mechanism of poll mutual exclusion write access, realize the quick transmission of magnanimity order data.
The inventive method comprises the following steps:
When digital control system starts, carry out initialization operation, need to determine the order number of transmission;
Task controller in digital control system repeatedly sends command information according to the order number in the individual task control cycle, two shared communication buffer districts by digital control system pass to the motion controller in digital control system; Two shared communication buffer districts are respectively as command buffer and state buffer;
Motion controller receives many command informations within the single motion control cycle, be stored in the motion control formation.
Below in conjunction with accompanying drawing, the present invention is described in further detail.
Referring to Fig. 1, adopt man-machine interface, task controller, motion controller and Programmable Logic Controller, motion controller and Programmable Logic Controller are loaded on the real-time kernel space of system, man-machine interface, task controller partly load on the user's space of system.Shared communication buffer district by system between task controller and motion controller communicates by letter mutually, transferring command parameter and state parameter etc., as shown in Figure 2.Man-machine interface, task controller, motion controller and Programmable Logic Controller are all periodically to be scheduled, and are arranged respectively, as shown in Figure 3 the dispatching cycle of oneself.Motion controller priority is the highest, and Programmable Logic Controller priority is taken second place, and is all both soft real time task; Task controller priority is less than Programmable Logic Controller, and its cycle is greater than motion controller and Programmable Logic Controller cycle sum; The priority of man-machine interface is minimum, and its cycle, ageing requirement was not strong greater than other three module sums.
The user inputs work procedure by man-machine interface, and work procedure carries out interpretation of programs and condition managing in task controller, then the command information that generates is passed to motion controller and carries out machining control.The command information transmission utilizes the shared communication buffer district of system, adopts command multi-transmitting mechanism, in the cycle, sends many command informations in individual task, thereby realizes the quick transmission of mass data, avoids producing " starvation of data ".
The user is by motion control cycle, Programmable Logic Controller cycle, task control cycle and the man-machine interface cycle of configuration file configuration-system.When system's operation starts, call configuration file, complete simultaneously the initialization that the inventive method monocycle sends at most order number MAX_COMMAND_NUM.Be specially:
MAX_COMMAND_NUM=N
max*(T
task/T
motion)
(1)
N wherein
maxThe maximum number of instructions that average each period of motion of expression can carry out, T
MotionThe expression motion control cycle, T
TaskThe expression task control cycle.
Obviously have: N
max=(vel*T
Motion)/L
ave
(2)
Wherein vel is the processing speed of feed of work procedure, L
aveAverage length for work procedure.
By (1), (2) as can be known, the monocycle sends and orders number to be:
MAX_COMMAND_NUM=(vel*T
task)/L
ave
(3)
Consider the execution speed of interpreter in task controller, and the factors such as performance of existing digital control system, following and according to system performance, maximum ultimate values that send the order number of monocycle being set is CAP_COMMAND_NUM, and it is write configuration file.The final expression formula of MAX_COMMAND_NUM is:
MAX_COMMAND_NUM=min{CAP_COMMAND_NUM,(vel*T
task)/L
ave} (4)
As shown in Figure 4, in the inventive method, the task controller execution comprises the following steps:
Repeatedly sending the command information process in the individual task control cycle is:
Work procedure to input makes an explanation, the command forms that the system of obtaining can identify;
The processing sequence of steering order and processing logic are processed the order that part needs to process immediately by the mentioned order form;
With the demanded storage after processing in the task formation, updating task formation correlation parameter simultaneously;
Whether the status information that judges a upper order is returned;
If the status information of a upper order is returned, empty and wait for counting;
Take out an order from task queue, write the interim order array;
Judge whether to continue write order;
If do not continue write order, send to motion controller and write the termination order;
Task controller writes the content in the interim order array in the order array of command buffer;
Update command number empties the interim order array;
The task control of this cycle finishes, and enters the next task control cycle;
If the continuation write order is back to and takes out a commands steps from task queue;
If the status information of a upper order is not returned, wait for that counting is cumulative;
Judgement waits for whether counting surpasses the counting boundary value that system arranges;
If do not surpass this counting boundary value, return to the status information that judges a upper order and whether return to step;
If surpass this counting boundary value, system produces the information that reports an error;
The task control of this cycle finishes, and enters the next task control cycle.
Whether the status information that judges a upper order has been returned is number to realize according to the feedback command in status information, if this feedback command number is identical with a upper command number that sends order, assert that the status information of a upper order returns, otherwise the status information of regarding as an order is not returned to;
Judging whether to continue write order is whether the command number that judgement is write reaches maximum order number MAX_COMMAND_NUM that send of monocycle, perhaps whether runs into some specific orders, needs to finish this duty cycle write order and moves;
When this order is write the interim order array and refers to that each duty cycle begins, begin to upgrade writing from first element of interim order array, when writing second command, write second element position of interim order array, and the rest may be inferred;
Update command number refers to that command number adds 1; In the process of individual task control cycle circulation write order, command number is constant; During write order, command number adds 1 in the next task cycle;
Wait for that counting is a kind of sign of using in the process of poll waiting status information feedback, every polling status information once waits for that count value adds 1; When this waited for the counting boundary value that count value arranges greater than system, judging that this poll is waited for finished, and enters the next task control cycle;
As shown in Figure 5, in the inventive method, motion controller within the single motion control cycle, receives many command informations, is stored in the motion control formation, and its process is:
Judge that motion controller whether can reading order;
If can reading order, the order in the order array of distribution command buffer zone be in command queue;
Status information in the update mode buffer zone;
Carry out the machining control function in motion controller;
If motion controller can not reading order, directly carry out the machining control function;
The motion control of this cycle finishes, and enters the next motion control cycle.
Whether can reading order be to judge whether the command number in command buffer is consistent with the feedback of status signal in state buffer.If inconsistent (command number is than feedback of status signal large 1) illustrates that task controller has sent a newer command, can reading order; If consistent, illustrate that task controller does not have the command information in the update command buffer zone, can not reading order;
The status information of update system refers to the feedback of status signal in the update mode buffer zone, the command number that makes this feedback of status command number equal to receive;
The machining control function of carrying out in motion controller mainly comprises the functions such as trajectory planning and axle control.
In conjunction with Fig. 4, Fig. 5 as can be known, the inventive method has realized the exclusive readwrite access function in two shared communication buffer districts, two blocks of main order buffer zones in shared communication buffer district and state buffer, exclusive readwrite access function are mainly realized by the command number in command buffer and the feedback of status signal in state buffer.Its state machine as shown in Figure 6, the state machine switch process is:
Under read states, if the feedback of status signal in state buffer is 0, and the command number in command buffer is 0, enters the write order state;
Under the write order state, if the feedback of status signal in state buffer is 0, and the command number in command buffer is 1, enters read command/the write state of state;
In read command/write under the state of state, if the feedback of status signal in state buffer is 1, and the command number in command buffer is 1, and this command routing success is described, enters read states next time.
Described read states refers to and can the feedback of status signal in state buffer be read, and this action is non-exclusive action, and task controller and motion controller can be carried out;
Described write order refers to the command information in task controller update command buffer zone, and this action is only carried out by task controller.Its occurrence condition is that last command routing process is complete, and namely the feedback of status signal in state buffer equals the command number in command buffer;
Described read command/the state of writing refers to the command information in motion controller reading order buffer zone, simultaneously the feedback of status signal in the update mode buffer zone.Its occurrence condition is that task controller is completed the transmission of the order in command buffer, and motion controller does not operate this newer command;
In conjunction with Fig. 4, Fig. 5 as can be known, task controller is different with the motion controller performance period, is both all that mode by poll realizes to the access in two shared communication buffer districts.The priority of motion controller is high, can not be seized, and shares the communication buffer district and can only be upgraded by the motion control thread within each motion control cycle, therefore the shared communication buffer of two of access district 1 time when the motion control cycle begins; The priority of task controller is lower than motion controller, and its cycle may interrupt and seize by passive movement control cycle, and shared communication buffer district does not monopolize within each task control cycle.Share the communication buffer district even that is to say that task controller does not upgrade, it is also variable should sharing communication buffer district information in duty cycle, therefore in duty cycle repeatedly poll share the content in communication buffer district, wrap count is by waiting for that the counting boundary value controls.
The present embodiment is applied to the inventive method in the order distribution processor of Open CNC System Software control section of blue sky hardware platform, and its operation result has obtained checking on Milling Motion in Three-axes NC.
Hardware platform adopts standard industry level IPC integrated circuit board, and 5X86-133MHz CPU consists of the 4+1 axis controller as system controller by one ten thousand FPGA devices able to programme, and the FPGA device provides other auxiliary circuits such as digital control system I/O simultaneously.
The important technological parameters of test environment is as follows:
Drive: pacify river motor ∑ II Series AC servo;
Digital control system: CPU 5X86-133MHz, RAM-32M, FLASH-32M, I/O-32/24, scrambler input-4, D/A output-4, demonstration-10.4 " Color Liquid Crystal Display;
The speed of mainshaft=24000r/min;
Feed rate F=9000mm/min;
Acceleration and deceleration mode: linear acceleration and deceleration;
The motion control cycle: 2ms;
The programmable logic controller (PLC) cycle: 2ms;
Duty cycle: 10ms;
The man-machine interface cycle: 100ms;
Monocycle sends at most the ultimate value of order number: 20
The present embodiment test procedure:
G01 G91 F9000
X0.01 Y0.01 Z0.01
X0.01 Y0.01 Z0.01
(totally 70000 sections)
M02
When test procedure brings into operation, start manual time-keeping.Before adopting the inventive method, test all moves with the processing work program and completed about needs 700 seconds, and program speed in service is low, and frequent fluctuation.After adopting the inventive method, test all moves with the processing work program and completed about needs 39 seconds, and program operation speed is high, and velocity perturbation is arranged.
In this embodiment operational process, the monocycle sends at most the order number and gets its ultimate value 20, so still can occur the less situation of order to be processed in the motion control formation in process.The inventive method in actual applications can be according to the processing power of digital control system etc., sets suitably that in configuration file, the monocycle sends at most the ultimate values of order number.
Operation contrast by embodiment can obtain as drawing a conclusion:
1. the inventive method execution efficient is high.Use the inventive method " prediction " or " pre-service " hop count of the minimum that guarantees that the digital control system operation is level and smooth can be set before program operation beginning, reduce system's front stand-by period of processing operation, improved to a certain extent the execution efficient of digital control system.
2. the inventive method execution speed is fast.Use the order transmission speed that the inventive method can improve digital control system, solved " starvation of data " problem in digital control system high-speed cruising process.
3. the inventive method dirigibility is good.The inventive method provides the parameter configuration function, and the user can change monocycle in command multi-transmitting mechanism by CONFIG.SYS and send at most the ultimate values of order number, task control cycle and the motion control cycle of combining with digital control system, obtains optimum efficiency.