A kind of data interoperation method that is used for bus-type numerical control system
Technical field
The present invention relates to the digital control system field, specifically a kind of data interoperation method that is used for bus-type numerical control system.
Background technology
Bus-type numerical control system is had relatively high expectations to real-time, synchronism, reliability and security, and the subject matter of data interaction was data interoperation problem between unmatched two functional parts of the cycle of how handling between its motion controller and fieldbus drove.How how motion controller reaches is handled feedback data that fieldbus drives and fieldbus and drives interpolation data how to use motion controller to send and become the key that influences its performance quality.
The method of data interoperation mainly contained following several between motion controller and fieldbus drove at present:
1. do not change the motion controller structure, fieldbus drives the exchanges data between only responsible motion controller and the address card, and interpolation is calculated and all realized in motion controller;
2. change motion controller structure moves on to realization in the fieldbus driving with interpolation function;
3. do not change the structure that motion controller and fieldbus drive, adopt queue row or annular data buffer etc. that data are carried out buffer memory.
Strict coupling of the cycle that preceding two kinds of methods require motion controller and fieldbus to drive.Yet on the one hand owing to be subjected to the hardware condition restriction, the cycle of motion controller is usually at Millisecond, and because the requirement of digital control system machining precision, the cycle that fieldbus drives is generally the microsecond level; On the other hand, even the cycle that the cycle of motion controller and fieldbus drive is set to same numerical value, because the system clock timing exists error, the two still is difficult to mate fully.Though the method that adopts queue row or annular data buffer etc. that data are carried out buffer memory can solve the cycle mismatch problem, need take very big memory headroom, influences the performance of digital control system.
Summary of the invention
At above shortcomings part in the prior art, the technical problem to be solved in the present invention provide a kind of can satisfy motion controller and fieldbus drive between the cycle mismatch problem, and the little data interoperation method that is used for bus-type numerical control system that takes up room.
For achieving the above object, the present invention is by the following technical solutions:
The data interoperation method that the present invention is used for bus-type numerical control system may further comprise the steps:
Fieldbus driver application shared buffer, and carry out initialization;
Digital control system motion controller thread carries out load operation;
Digital control system motion controller thread is shared the shared buffer that the fieldbus driver is applied for;
At the shared buffer of above-mentioned application, by realizing the data interoperation of digital control system with the read-write operation of fieldbus driver.
The shared buffer of fieldbus driver application is divided into transmission buffer zone and send buffer, and each buffer zone is provided with two data fields;
Each the data field size that sends buffer zone is the motion controller size of phase transmission interpolation data weekly, and each data field size of send buffer is the fieldbus driver size of phase feedback data weekly;
Send buffer zone and send buffer and be provided with end to end each one on pointer, send buffer zone and send buffer and be provided with empty team of team full scale and know each one.
The motion controller read operation is meant that motion controller reads the Servo System of CNC Machine Tool feedback information from send buffer head pointer data field pointed, and execution in step is as follows:
Judge whether send buffer is empty;
If send buffer is not empty, then motion controller takes out feedback data from send buffer head pointer data field pointed;
Send buffer queue full sign is changed to FALSE;
The send buffer head pointer is carried out and is added 1 operation;
The send buffer head pointer is added the result of 1 operation to 2 deliverys;
Whether the head pointer behind the tail pointer of judging send buffer and the delivery equates;
If the tail pointer of send buffer equates with head pointer behind the delivery, then send buffer queue empty sign is changed to TRUE;
This read operation finishes.
If the head pointer behind the tail pointer of send buffer and the delivery is unequal, then this read operation finishes.
If send buffer is empty, then this read operation finishes.
The motion controller write operation is meant that motion controller writes order interpolation to sending buffer zone tail pointer data field pointed, and execution in step is as follows:
Judge and send whether buffer zone queue full sign is TRUE;
If queue full is designated TRUE, then sends the execution of buffer zone tail pointer and subtract 1 operation;
Subtract the result of 1 operation to 2 deliverys with sending the buffer zone tail pointer;
Order interpolation is write transmission buffer zone tail pointer data field pointed;
Send the execution of buffer zone tail pointer and add 1 operation;
Add the result of 1 operation to 2 deliverys with sending the buffer zone tail pointer;
Put transmission buffer zone queue empty and be designated FALSE;
Whether the tail pointer that judge to send behind buffer zone head pointer and the delivery equates;
Equate with tail pointer behind the delivery if send the buffer zone head pointer, then will send the buffer zone queue full and identify and be changed to TRUE;
This write operation finishes.
If the tail pointer that sends behind buffer zone head pointer and the delivery is unequal, then this write operation finishes.
If the queue full sign is not TRUE, then order interpolation is write and send buffer zone tail pointer data field pointed; The transmission buffer zone tail pointer that continues is carried out and is added 1 operation steps.
Fieldbus drives read operation and is meant that fieldbus drives from sending buffer zone head pointer data field pointed and reads order interpolation that execution in step is as follows:
Judge whether send buffer zone is empty;
If send buffer zone is not empty, then reads order interpolation from send buffer zone head pointer data field pointed;
Put transmission buffer zone queue full and be designated FALSE;
Send the execution of buffer zone head pointer and add 1 operation;
Add the result of 1 operation to 2 deliverys with sending the buffer zone head pointer;
Whether the head pointer behind the tail pointer that judge to send buffer zone and the delivery equates;
If the tail pointer of transmission buffer zone equates with the head pointer behind the delivery, then will send buffer zone queue empty sign and be changed to TRUE;
This read operation finishes.
If it is unequal to send the tail pointer and the head pointer behind the delivery of buffer zone, then this read operation finishes.
If send buffer zone is empty, then finishes this read operation.
Fieldbus drives write operation and is meant that fieldbus drives in send buffer tail pointer data field pointed and writes numerically-controlled machine servo condition feedback information that its step is as follows:
Judge whether send buffer queue full sign is TRUE;
If the send buffer queue full is designated TRUE, then the send buffer tail pointer is carried out and is subtracted 1 operation;
The execution of send buffer tail pointer is subtracted the result of 1 operation to 2 deliverys;
Numerically-controlled machine servo operation state feedback information is write send buffer tail pointer data field pointed;
The send buffer tail pointer is carried out and is added 1 operation;
The execution of send buffer tail pointer is added the result of 1 operation to 2 deliverys;
Put send buffer queue empty sign and be changed to FALSE;
Judge whether the tail pointer behind send buffer head pointer and the delivery equates;
If the send buffer head pointer equates with tail pointer behind the delivery, then puts the send buffer queue full and be designated TRUE;
This write operation finishes.
If the tail pointer behind send buffer head pointer and the delivery is unequal, then this write operation finishes.
If send buffer queue full sign is not TRUE, then numerically-controlled machine servo operation state feedback information is write send buffer tail pointer data field pointed; The send buffer tail pointer that continues is carried out and is added 1 operation steps.
The present invention has the following advantages:
1. can solve cycle mismatch problem between the driving of motion controller and fieldbus.The inventive method is designed to the interface buffer between motion controller and the fieldbus driving to transmit the twice of size of data, interior at one time motion controller and fieldbus drive can only the buffer empty of access transport size of data between, and own buffer zone of visiting locked.This part buffer zone is temporarily open to the other side, so do not need to consider the other side's performance period, whether reads and writes problem such as finish.
2. it is little to take up room.The inventive method occupation space is the twice of transmission size of data, and to compare occupation space much smaller with the scheme that buffer circle etc. solves the cycle mismatch problem by the expansion buffer size.
3. effectively avoid reading and writing dirty data.The inventive method is designed to send buffer zone and send buffer with the data buffer, and is respectively equipped with two data fields in sending buffer zone and send buffer.Data field that motion controller will send buffer zone at every turn just allows bus driver to visit this data field after upgrading and finishing.Bus driver with data field of send buffer upgrade finish after, motion controller just can read the data in this data field.So two-layer program does not read while write the situation that sends same data field in buffer zone or the send buffer about not existing, can avoid reading and writing the problem of dirty data effectively.
4. versatility is good.The inventive method does not rely on data type and the data content that is transmitted, and can be applied in polytype bus-type numerical control system.
Description of drawings
Fig. 1 is the overall construction drawing of the inventive method;
Fig. 2 is the inventive method motion controller read operation process flow diagram;
Fig. 3 is the inventive method fortune control controller write operation process flow diagram;
Fig. 4 drives the read operation process flow diagram for the inventive method fieldbus;
Fig. 5 drives the write operation process flow diagram for the inventive method fieldbus.
Embodiment
Below in conjunction with accompanying drawing the bright method of we is elaborated.
The overall construction drawing of realization the inventive method as shown in Figure 1.Motion controller is a digital control system order interpolation transmitting terminal, drives to fieldbus and sends interpolation data; The fieldbus driving is the command transfer passage between digital control system motion controller and the Servo System of CNC Machine Tool, be responsible for the order of motion controller is sent to Servo System of CNC Machine Tool, and the Servo System of CNC Machine Tool running status is fed back to motion controller; Servo System of CNC Machine Tool is carried out order interpolation and is driven the axis servomotor motion, drives to fieldbus and sends current running status feedback information.
The data interoperation method that the present invention is used for bus-type numerical control system may further comprise the steps:
Fieldbus driver application shared buffer, and carry out initialization, this shared buffer is divided into transmission buffer zone and send buffer, and sending in buffer zone and the send buffer respectively has two data fields; Digital control system motion controller thread carries out load operation; Digital control system motion controller thread is shared the shared buffer that the fieldbus driver is applied for; In between the buffer empty of above-mentioned application, by realizing the data interoperation of digital control system with the read-write operation of fieldbus driver.
Motion controller writes the shared data buffer zone with order interpolation, and fieldbus drives and read order interpolation from the shared data buffer zone, and this shared data buffer zone is called the transmission buffer zone; Fieldbus drives Servo System of CNC Machine Tool running status feedback information is write the shared data buffer zone, motion controller reads Servo System of CNC Machine Tool running status feedback information from the shared data buffer zone, this shared data buffer zone is called send buffer.
In data transmission procedure, motion controller writes order interpolation according to oneself control cycle and sends in the buffer zone tail pointer data field pointed, and reads numerically-controlled machine running status feedback information from send buffer head pointer data field pointed.Similarly, the fieldbus driver reads order interpolation and sends to Servo System of CNC Machine Tool from send buffer zone head pointer data field pointed, and the running status feedback information of Servo System of CNC Machine Tool is write in the send buffer tail pointer data field pointed.
Described motion controller read operation is meant that motion controller reads the Servo System of CNC Machine Tool feedback information from send buffer head pointer data field pointed.Its concrete execution in step is as shown in Figure 2:
The motion controller read operation is meant that motion controller reads the Servo System of CNC Machine Tool feedback information from send buffer head pointer data field pointed, and execution in step is as follows:
Judge whether send buffer is empty;
If send buffer is not empty, then motion controller takes out feedback data from send buffer head pointer data field pointed;
Send buffer queue full sign is changed to FALSE;
The send buffer head pointer is carried out and is added 1 operation;
The send buffer head pointer is added the result of 1 operation to 2 deliverys;
Whether the head pointer behind the tail pointer of judging send buffer and the delivery equates;
If the pointer end to end of send buffer equates, then send buffer queue empty sign is changed to TRUE;
This read operation finishes;
If the pointer end to end of send buffer is unequal, then this read operation finishes;
If send buffer is empty, then this read operation finishes.
Described motion controller write operation is meant that motion controller writes order interpolation to sending buffer zone tail pointer data field pointed.Its concrete execution in step is as shown in Figure 3:
The motion controller write operation is meant that motion controller writes order interpolation to sending buffer zone tail pointer data field pointed, and execution in step is as follows:
Judge and send whether buffer zone queue full sign is TRUE;
If queue full is designated TRUE, then sends the execution of buffer zone tail pointer and subtract 1 operation;
Subtract the result of 1 operation to 2 deliverys with sending the buffer zone tail pointer;
Order interpolation is write transmission buffer zone tail pointer data field pointed;
Send the execution of buffer zone tail pointer and add 1 operation;
Add the result of 1 operation to 2 deliverys with sending the buffer zone tail pointer;
Put transmission buffer zone queue empty and be designated FALSE;
Whether tail pointer equates after judge sending buffer zone head pointer and delivery;
Pointer is equal end to end if send buffer zone, then will send buffer zone queue full sign and be changed to TRUE;
This write operation finishes;
Pointer is unequal end to end if send buffer zone, and then this write operation finishes;
If the queue full sign is not TRUE, then order interpolation is write and send buffer zone tail pointer data field pointed; The transmission buffer zone tail pointer that continues is carried out and is added 1 operation steps.
When the formation of transmission buffer zone was full in the current motion control cycle, fieldbus drove and locks for its transmission buffer data district of reading.Motion controller can only be operated and send the data field that does not lock in the buffer zone formation this moment, so write operation covers a motion control order interpolation that the cycle deposits in.After fieldbus driving read operation is complete, be the related transmission buffer data district's release of current read operation.Above-mentioned action is called the read operation lock mechanism that fieldbus drives, and this mechanism has guaranteed that fieldbus drives and read correct order interpolation, avoided reading dirty data.
Described fieldbus drives read operation and is meant that fieldbus drives from sending buffer zone head pointer data field pointed and reads order interpolation, its concrete execution in step as shown in Figure 4:
Judge whether send buffer zone is empty;
If send buffer zone is not empty, then reads order interpolation from send buffer zone head pointer data field pointed;
Put transmission buffer zone queue full and be designated FALSE;
Send the execution of buffer zone head pointer and add 1 operation;
Add the result of 1 operation to 2 deliverys with sending the buffer zone head pointer;
Whether the head pointer behind the tail pointer that judge to send buffer zone and the delivery equates;
Equate if send the pointer end to end of buffer zone, then will send buffer zone queue empty sign and be changed to TRUE;
This read operation finishes;
If it is unequal to send the tail pointer and the head pointer behind the delivery of buffer zone, then this read operation finishes;
If send buffer zone is empty, and then this read operation finishes.
Described fieldbus drives write operation and is meant that fieldbus drives in send buffer tail pointer data field pointed and writes numerically-controlled machine servo condition feedback information.
When the send buffer formation was full in the current fieldbus drive controlling cycle, motion controller locked for its send buffer data field of reading.Fieldbus drove and can only operate the data field that does not lock in the send buffer formation this moment, so write operation covers the numerically-controlled machine servo operation state feedback information that a fieldbus drive controlling cycle is deposited in.After the motion controller read operation is complete, be the related send buffer data field release of current read operation.Above-mentioned action is called the read operation lock mechanism of motion controller, and this mechanism has guaranteed that motion controller reads correct numerically-controlled machine servo operation state feedback information, avoids reading dirty data.Its concrete execution in step is as shown in Figure 5:
Judge whether send buffer queue full sign is TRUE;
If the send buffer queue full is designated TRUE, then the send buffer tail pointer is carried out and is subtracted 1 operation;
The execution of send buffer tail pointer is subtracted the result of 1 operation to 2 deliverys;
Numerically-controlled machine servo operation state feedback information is write send buffer tail pointer data field pointed;
The send buffer tail pointer is carried out and is added 1 operation;
The execution of send buffer tail pointer is added the result of 1 operation to 2 deliverys;
Put send buffer queue empty sign and be changed to FALSE;
Judge whether the tail pointer behind send buffer head pointer and the delivery equates;
If send buffer pointer end to end equates, then put the send buffer queue full and be designated TRUE;
This write operation finishes;
If the tail pointer behind send buffer head pointer and the delivery is unequal, then this write operation finishes;
If send buffer queue full sign is not TRUE, then numerically-controlled machine servo operation state feedback information is write send buffer tail pointer data field pointed; The send buffer tail pointer that continues is carried out and is added 1 operation steps.
In order to test actual motion effect of the present invention and performance, on SSB-III bus digital control system, use the present invention and the operation of actual drive servomotor.The practical operation situation of servomotor is steady, does not have shock conditions, and real time data observation does not exist loss of data and reading and writing data error situation.
Test environment of the present invention: SSB-III(Synchronous-Serial-Bus, synchronous serial bus) numerical control bus; The CNC system hardware platform is CPU5X86-133MHz, RAM-32M, FLASH-32M; Operating system is linux-2.4.22(RTAI); Execution result test mode: motor actual rotation situation, the real time print observation of motion interpolation data and servo feedback data.