Detailed Description
The technical solution of the present invention is further described below with reference to the accompanying drawings, but not limited thereto, and any modification or equivalent replacement of the technical solution of the present invention without departing from the spirit and scope of the technical solution of the present invention shall be covered by the protection scope of the present invention.
The invention discloses a cross-platform communication precision motion platform control device, as shown in figure 1, the device comprises an upper computer 1, a lower computer 3, a motion control card 5 and a motion platform 7, wherein:
the upper computer 1 is connected with the lower computer 3 through a network cable 2;
the lower computer 3 is connected with the motion control card 5 through a VME bus;
the motion control card 5 is connected with a motion platform 7 through an optical fiber 6.
In the invention, the upper computer 1 consists of a personal computer, and an Intel processor is adopted to run Windows XP, Windows 7, Windows 8 or Windows 10 operating systems.
In the present invention, the type of the net thread 2 may be a type 3 thread, a type 5 thread, a super type 5 thread, a type 6 thread or a type 7 thread.
In the invention, the lower computer 3 is composed of a single-board computer, adopts a PowerPC processor, and runs an operating system of VxWorks 6.4 or above.
A control method of a precision motion platform for cross-platform communication by using the device comprises the following steps:
the method comprises the following steps: the upper computer 1 issues a control instruction to the lower computer 3 through the network cable 2 according to a specified protocol format.
In this step, the protocol format is shown in table 1.
TABLE 1
Head 0xFE
| Length (len)
| Content providing method and apparatus
| Verification
| Tail 0xEF
|
1Byte
| 4Byte
| len Bytes
| 1Byte
| 1Byte |
In table 1, the length refers to the number of bytes of the content, and the definition of the content item is shown in table 2.
TABLE 2
Message type
| Message ID
| Error code
| Session ID
| A plurality of key-value pairs
|
1Byte
| 2Byte
| 1Byte
| 2Byte
| The remaining Bytes |
In Table 2, the definition of the key-value pair is shown in Table 3, and the length is not limited.
TABLE 3
KV count
| key-value
| …
| key-value
|
2Byte
| Length self-explanation
| …
| Length self-explanation |
In Table 3, the definition of key-value is shown in Table 4.
TABLE 4
Key ID
| Value type
| Value
|
2Byte
| 1Byte
| Determining length according to type |
In table 4, the Value type may be an 8-bit char type, a 32-bit int type, a 64-bit long int type, a 32-bit float type, or a 64-bit double type, and the specific definition is shown in table 5.
TABLE 5
Value type
| Type value
| Value length
|
char
| 0x01
| 1 byte
|
int
| 0x02
| 4 bytes
|
long int
| 0x03
| 8 bytes
|
foat
| 0x04
| 4 bytes
|
double
| 0x05
| 8 bytes |
Step two: and after the lower computer 3 receives the control instruction through the network cable 2, checking the received data in a CRC (cyclic redundancy check) mode.
Step three: and after the lower computer 3 completes the verification, sending feedback information to the upper computer 1 according to the protocol format of the table 6.
TABLE 6
Head 0xFE
| Length (0x06)
| Message type
| Message ID
| Error code
| Session ID
| Verification
| Tail 0xEF
|
1Byte
| 1Byte
| 1Byte
| 2Byte
| 1Byte
| 2Byte
| 1Byte
| 1Byte |
In table 6, the message ID and the session ID are respectively identical to the message ID and the session ID in the first step, the error code is used to indicate whether the instruction of the upper computer 1 received by the lower computer 3 in the first step verifies an error, 0x00 indicates correct reception, and 0xFF indicates a reception error. If the receiving is wrong, the upper computer 1 sends a control instruction to the lower computer 3 again according to the protocol format in the step one.
Step four: and the lower computer 3 analyzes the received control instruction and performs large-small end conversion on the received value.
Step five: the lower computer 3 sends the value converted by the big end and the small end to the motion control card 5 through the VME bus 4, and the motion control card 5 sends the operation result to the motion platform 7 through the optical fiber 6 after operation.
Example (b):
suppose that the upper computer needs to send three control parameters 12000, 361300, 27 of PID (proportional-integral-derivative) to the lower computer, and then the lower computer sends the parameter values to the motion control card and the motion control card controls the motion platform. The execution flow of the process is as follows:
1. the upper computer carries out protocol coding on the instruction of sending PID control parameters according to a specified protocol format, and refines the length and the content related in the protocol by check bit information.
(1) Information of key-value pairs in the content is first determined. Since the PID parameters have three double values, there are three key-values, i.e., kv count is 0x 0003. The three key-values correspond to the proportional parameter P, the integral parameter I and the differential parameter D respectively. The three key-values are specifically defined as:
the Key-value corresponding to the control parameter P is as follows:
KeyID: key _ ID _ ctrl parma _ P (Key _ ID _ ctrl parma _ P is a macro definition, and is 0x0001, and represents the KeyID corresponding to the control parameter P);
value type: value _ Type _ Double (Value _ Type _ Double is a macro definition, 0x05, indicating that the Value is of Type Double);
value: 12000 (Value representing control parameter P).
The Key-value corresponding to the control parameter I is as follows:
KeyID: key _ ID _ ctrl _ parama _ I (Key _ ID _ ctrl parama _ I is a macro definition, and is 0x0002, and represents the KeyID corresponding to the control parameter I);
value type: value _ Type _ Double;
value 361300 (representing the Value of the control parameter I).
The Key-value corresponding to the control parameter D is as follows:
KeyID: key _ ID _ ctrl _ parama _ D (Key _ ID _ ctrl parama _ D is a macro definition, and is 0x0003, and represents the KeyID corresponding to the control parameter D);
value type: value _ Type _ Double;
value: 27 (Value representing control parameter D).
(2) And determining the information of the message type, the message ID, the error code and the session ID in the content.
Message type: MSG _ TYPE _ EXEC (MSG _ TYPE _ EXEC is a macro definition, 0x01, indicating that the message is a host computer instruction send message) message ID: 0xB001 (indicating that the message is a parameter setting message);
and (3) error code: 0x00 (sender error code of 0);
session ID: 0x00 (this information is reservation information for later use by protocol extensions).
(3) And performing CRC on each data in the content to generate a check code as a check bit in the protocol.
(4) And counting the total byte number of each data in the content to generate length information in the protocol.
2. And after the upper computer refines the protocol, the data is sent to the lower computer through a network cable.
3. And after the lower computer receives the data, performing CRC on each data of the content items to generate a CRC code.
4. And the lower computer compares the generated check code with the received check code issued by the upper computer.
(1) If the two are not consistent, the data receiving error is shown, and the lower computer returns the following information to the upper computer:
header + length + message type + message ID + error code + session ID + check + tail.
Wherein:
the head is as follows: 0 xFE;
the length is as follows: 0x 06;
the message types are: MSG _ TYPE _ EXEC _ ACK (MSG _ TYPE _ EXEC is a macro definition, and is 0x10, indicating that the message is a message that the lower computer actively reports to the upper computer);
message ID: the message ID is consistent with the received message ID sent by the upper computer;
and (3) error code: 0xFF (indicating reception error);
session ID: the session ID is consistent with the received session ID sent by the upper computer;
checking: and performing CRC (cyclic redundancy check) on the message type, the message ID, the error code and the session ID, and taking a check result as a check bit.
(2) If the check code generated by the lower computer is consistent with the received check code issued by the upper computer, the lower computer returns the following information to the upper computer:
header + length + message type + message ID + error code + session ID + check + tail.
Wherein:
the head is as follows: 0 xFE;
the length is as follows: 0x 06;
the message types are: MSG _ TYPE _ EXEC _ ACK (MSG _ TYPE _ EXEC is a macro definition, and is 0x10, indicating that the message is a message that the lower computer actively reports to the upper computer);
message ID: the message ID is consistent with the received message ID sent by the upper computer;
and (3) error code: 0x00 (indicating correct reception);
session ID: the session ID is consistent with the received session ID sent by the upper computer;
checking: and performing CRC (cyclic redundancy check) on the message type, the message ID, the error code and the session ID, and taking a check result as a check bit.
5. And the lower computer extracts the Value of the received data, analyzes the Value according to the message ID and the KeyID and analyzes the Value values corresponding to the three PID control parameters.
6. And the lower computer performs large-end and small-end conversion on the value to obtain three PID control parameters.
7. The lower computer sends the three PID control parameter values to the motion control card through the VME bus, the motion control card calculates the control quantity after receiving the three PID parameters, and sends the calculation result to the motion platform through the optical fiber.