Background technology
At present, in industrial motion control field, mainly there are two kinds of control modes:One kind is by motion control card come real
It is existing;One kind is realized by PLC (Programmable Logic Controller, programmable logic controller (PLC)).
In by way of being realized motion control card, pass through PCI (Peripheral Component
Interconnect, peripheral component interconnection) control card is inserted in PC (Personal Computer, PC) by slot
Main frame on;Developed using programming languages such as high-level programming language C++, C#, VB, VB.NET, LabVIEW;Make in programming
The control card api interface function provided with motion control card manufacturer, to realize the use to control card resource;Motion control cartoon
The mode for crossing transmission pulse controls servo or step actuator to control servomotor or stepper motor, by reading input letter
Number, control output signal realize the control to input-output equipment such as relay, sensor, cylinders.Motion control card is main
Advantage be the powerful functions of integrated PC, such as CAD (Computer Aided Design, CAD) function,
Machine vision function, software advanced programming etc..Due to the power of PC, therefore the motion controller therewith constituted
Function is most strong, but its job stability, reliability are poor.
In by way of being realized PLC, logic control is carried out by PLC switch amounts, can also realize that motion control is (straight
Line tracking is controlled), computing, the function such as data processing.Therefore, have the advantages that reliable operation, programming are simple.But, due to it
Man-machine interface is generally done using touch-screen, this results in visualization interface and greatly limited.In actual application, its
Maximum the problem of, which can not exactly be realized, leads figure function;It is difficult to be combined with other applications such as machine vision.
Therefore, if two ways can be combined, it is possible to while taking into account stability and visualization.But, industry
PC and PLC are the equipment of two different entities, are communicated between the two by Modbus Transmission Control Protocol.Due to Modbus TCP
Agreement is communicated in the way of question-response formula, and communication needs the regular hour, when there is many orders, and call duration time is folded
It is added together and quite obvious delay occurs.And it is action interim card that this delay, which is reflected in motion control, this substantially can not
Meet and require.
The content of the invention
It is an object of the invention to provide a kind of industrial kinetic control system based on API and method to reduce communication data
Redundancy, has reached raising communication speed.
In order to achieve the above object, the technical scheme of use is the present invention:A kind of industrial motion control system based on API
System, including industrial individual PC control subsystems and PLC control subsystems, the industrial PC subsystem include control module with
API library, the PLC control subsystems include PLC motion controllers and multiple servo-drivers, wherein:
The control module, for generating the feedback data of motion control instruction and processing from PLC control subsystems;
The API library, for caching the motion control instruction from the control module and by multiple motion control instructions
The PLC control subsystems are disposably sent to, and the feedback data of the PLC control subsystems is disposably read into institute
State industrial PC subsystem;
The PLC motion controllers, for controlling the multiple servo-driver according to the multiple motion control instruction
And generate feedback data;
The multiple servo-driver, under the control of the PLC motion controllers, controlling corresponding motor fortune
It is dynamic.
Preferably, by the Modbus of extension between the industrial PC subsystem and the PLC control subsystems
Transmission Control Protocol communicates, and the Modbus Transmission Control Protocol of the extension includes batch reading function code and batch writes function code.
Preferably, the PLC motion controllers include multiple data storage cells, for storing the PLC controls subsystem
The feedback data of system;The feedback data of the PLC control subsystems includes what the multiple servo-driver controlled motor was moved
Implementing result data and motor status data;
The multiple servo-driver is additionally operable to the implementing result data and the motor status data being back to institute
State multiple data storage cells.
Preferably, the API library includes dynamic link library, processing unit, the location of instruction, wherein:
The dynamic link library, for providing api interface function for the control module, so that the control module passes through
Call the api interface function that multiple motion control instructions are stored into the location of instruction successively;
The processing unit, the multiple motion control instruction for the location of instruction to be stored is same disposable
Send to the PLC control subsystems, and disposably read the implementing result data and the motor status data;
The location of instruction, for keeping in the multiple motion control instruction.
Preferably, the processing unit is additionally operable to:
It is space-time in the location of instruction, the motor status data is disposably read into the industrial PC
Subsystem.
Correspondingly, the present invention also provides a kind of industrial motion control method based on API, comprises the following steps:
Step S1:Generation motion control instruction simultaneously disposably sends multiple motion control instructions to PLC control subsystems;
Step S2:PLC motion controllers control multiple servo-drivers according to the multiple motion control instruction;
Step S3:The multiple servo-driver controls corresponding motor movement;
Step S4:The feedback data of the PLC control subsystems is disposably read into the industrial PC subsystem.
Preferably, by the Modbus of extension between the industrial PC subsystem and the PLC control subsystems
Transmission Control Protocol communicates, and the Modbus Transmission Control Protocol of the extension includes batch reading function code and batch writes function code.
Preferably, the feedback data of the PLC control subsystems is moved including the multiple servo-driver controlled motor
Implementing result data and motor status data;
In the step S4, the PLC control subsystems are by the implementing result data and the motor status data
Send simultaneously to the industrial PC subsystem.
Preferably, the step S1 includes:
Step S11:The control module generation motion control instruction of industrial PC subsystem;
Step S12:Call the api interface function of API library that multiple motion control instructions are stored into instruction successively to deposit
Storage unit;
Step S13:The multiple motion control instruction that the location of instruction is stored disposably is sent to described
PLC control subsystems.
Preferably, the industrial motion control method based on API also includes:
It is space-time in the location of instruction, the motor status data is disposably read into the industrial PC
Subsystem.
The present invention has the following advantages:Industrial kinetic control system based on API and method that the present invention is provided, Industrial PC control
Subsystem disposably sends multiple motion control instructions by API library to PLC control subsystems;PLC control subsystems according to
The plurality of motion control instruction controlled motor axle is completed after corresponding motion, and property reads PLC to industrial PC subsystem again
The feedback data of control subsystem.Thus, both visualization function can be provided by industrial PC subsystem, can utilized again
PLC stability realizes the control to motor shaft;Meanwhile, industrial PC subsystem can be to PLC control subsystems one
Secondary property sends multiple motion control instructions, and the disposable feedback data for reading PLC control subsystems simultaneously, thus, subtracts significantly
Lack communication data redundancy, reached raising communication speed, meet the purpose of system requirements.
Embodiment
Below in conjunction with the accompanying drawing in the embodiment of the present invention, the technical scheme in the embodiment of the present invention is carried out clear, complete
Site preparation is described, it is clear that described embodiment is only a part of embodiment of the invention, rather than whole embodiments.It is based on
Embodiment in the present invention, it is every other that those of ordinary skill in the art are obtained under the premise of creative work is not made
Embodiment, belongs to the scope of protection of the invention.
It is the schematic diagram for the industrial kinetic control system based on API that one embodiment of the invention is provided shown in Fig. 1.Such as Fig. 1
Shown, the industrial kinetic control system of the invention based on API includes industrial PC subsystem 10 and PLC control subsystems
20.The industrial PC subsystem 10 includes control module 110 and API library 120, and the PLC control subsystems 20 include PLC
Motion controller 210 and multiple servo-drivers 220.
In an embodiment of the present invention, lead between the industrial PC subsystem 10 and the PLC control subsystems 20
The Modbus Transmission Control Protocol communication of extension is crossed, the Modbus Transmission Control Protocol of the extension includes batch reading function code and batch writes work(
Can code.Function code 0x61 is read by the batch, host computer can disposably read discrete registers data;Work(is write by this in batches
Energy code 0x62, host computer can be by the multiple discrete registers of data write once.
The control module 110, for generating the feedback coefficient of motion control instruction and processing from PLC control subsystems
According to.Specifically, in an embodiment of the present invention, motion control instruction refers to the instruction that controlled motor axle is rotated, for example, starting electricity
Arbor instruction, halt instruction, assisted instruction and deceleration instruction etc..Need to control some motor shaft in some way in system
During motion, corresponding multiple motion control instructions will be disposably sent to PLC simultaneously by control module 110 and control son
System, rather than control instruction is sent over one by one.
The API library 120, for caching the motion control instruction from the control module 110 and controlling multiple motions
System instruction is disposably sent to the PLC control subsystems 20, and by the feedback data of the PLC control subsystems 20 once
Property reads the industrial PC subsystem 10.Specifically, API library 120 is that control module 110 provides data buffering, is responsible for
The instruction of control module 110 is sent to PLC control subsystems, then implementing result is fed back to operation layer.110 need of control module
The interface function for calling API library 120 to provide, can be achieved with the startup, stopping, acceleration-deceleration of axle, obtain the various states etc. of axle.
The PLC motion controllers 210, for controlling the multiple servo-drive according to the multiple motion control instruction
Device 220 simultaneously generates feedback data.The multiple servo-driver 220, under the control of the PLC motion controllers 210,
Control corresponding motor movement.Specifically, PLC motion controllers 210 pass through EtherCAT (EtherControl
Automation Technology, Ethernet auto-control technology) bus is connected with multiple servo-drivers 220, constitutes
PLC control subsystems 20.PLC motion controllers 210 are according to control needs, beforehand through ladder diagram, ST (Structured
Text, structure text) etc. PLC programming languages finish functional module corresponding to different motion control instruction.According to Industrial PC control
The motion control instruction that subsystem 10 is sent, PLC motion controllers 210 transfer corresponding functional module, pass through EtherCAT
The corresponding servo-driver 220 of bus marco, so as to realize the motion control to corresponding motor axle.
Further, in an embodiment of the present invention, the PLC motion controllers 210 include multiple data storage cells,
Feedback data for storing the PLC control subsystems 20;The feedback data of the PLC control subsystems 20 includes described many
The implementing result data and motor status data of the individual controlled motor of servo-driver 220 motion;The multiple servo-driver 220
It is additionally operable to the implementing result data and the motor status data being back to the multiple data storage cell.Specifically,
Servo-driver is after the motion of controlled motor axle, it is necessary to return according to an implementing result, this implementing result is stored in PLC
In the data storage cell of motion controller;Meanwhile, motor is also by itself status data (for example, motor rotating speed now, position
The data such as put) updated in real time by servo-driver into data storage cell.Thus, it is possible to facilitate industrial PC subsystem
Read.Wherein, multiple data storage cells are multiple discrete registers, and what the servo-driver for being stored with respectively different fed back holds
The motor status data of row result data and each motor.
Further, as shown in Fig. 2 in an embodiment of the present invention, the API library 120 include dynamic link library 122,
The location of instruction 124, processing unit 126.The dynamic link library 122 is used to provide api interface for the control module 110
Function, so that the control module 110 is stored multiple motion control instructions by calling the api interface function successively
The location of instruction 124;The processing unit 126, for the multiple fortune for storing the location of instruction 124
Dynamic control instruction is disposably sent to the PLC control subsystems 20, and disposably reads the implementing result data and institute
State motor status data;The location of instruction 124, for keeping in the multiple motion control instruction.
Specifically, as described above, by expanding between the industrial PC subsystem 10 and the PLC control subsystems 20
The Modbus Transmission Control Protocol communication of exhibition.Therefore, control module 110 needs to send multiple motion controls to PLC control subsystems 20
During instruction, the multiple motion control instruction can be sequentially successively read by calling the api interface function
To the location of instruction 124;Processing unit 126 is polled to the above-mentioned location of instruction 124, works as the location of instruction
124 be not space-time (when having motion control instruction), and processing unit 126 reads the location of instruction 124, and function is write by batch
Multiple orders are issued to PLC control subsystems by code simultaneously;When PLC control subsystems are responded, processing unit will not only read and hold
Row result data, and by motor status data, also reading comes up together, i.e., read function code by PLC control subsystems by batch
Multiple discrete registers in the data that store once update the internal memory of industrial PC subsystem.Thus, greatly reduce
Communication data redundancy, has reached raising communication speed, meets the purpose of system requirements.
Further, in an embodiment of the present invention, the processing unit 126 is additionally operable in the location of instruction
124 be space-time, and the motor status data are disposably read into the industrial PC subsystem 10.Specifically, instruction is worked as
Memory cell 124 is space-time (when not having motion control instruction), and PLC is controlled son by processing unit 126 by 0x61 function codes
The feedback data of system disposably reads industrial PC subsystem deposit internal memory.So, when industrial PC subsystem is needed
When wanting, it can be read directly from internal memory, substantially increase efficiency.
Advantageously, the industrial kinetic control system based on API that the present embodiment is provided, industrial PC subsystem passes through institute
State API library and disposably send multiple motion control instructions to the PLC control subsystems;PLC control subsystems are according to the plurality of
Motion control instruction controlled motor axle is completed after corresponding motion, and industrial PC subsystem disposably reads PLC control subsystems
The feedback data of system.Thus, both visualization function can be provided by industrial PC subsystem, the steady of PLC can be utilized again
Qualitative control that can be to realize to motor shaft;Meanwhile, pass through extension between industrial PC subsystem and PLC control subsystems
Modbus Transmission Control Protocol communicates, and industrial PC subsystem can write function code simultaneously by multiple motion control instructions by batch
PLC control subsystems disposably are sent to, the feedback data that function code disposably reads PLC control subsystems is write by batch,
It is possible thereby to greatly reduce communication data redundancy, raising communication speed has been reached, the purpose of system requirements is met.
It should be noted that multiple motion control instructions and feedback data can disposably be sent in the embodiment of the present invention
And reading, it can also be divided into according to application scenarios and be transmitted and read repeatedly, then this is not limited.
It is the flow chart for the industrial motion control method based on API that one embodiment of the invention is provided shown in Fig. 3.Such as Fig. 3
It is shown, it is somebody's turn to do the industrial motion control method based on API and comprises the following steps:
Step S1:Generation motion control instruction simultaneously disposably sends multiple motion control instructions to PLC control subsystems;
Specifically, in an embodiment of the present invention, motion control instruction refers to the instruction that controlled motor axle is rotated, for example,
Start motor shaft instruction, halt instruction, assisted instruction and deceleration instruction etc..Need to control some motor shaft in system with certain
Mode when moving, corresponding multiple motion control instructions will be disposably sent to PLC simultaneously by control module and controlled
Subsystem, rather than control instruction is sent over one by one.
Step S2:PLC motion controllers control multiple servo-drivers according to the multiple motion control instruction;
Step S3:The multiple servo-driver controls corresponding motor movement;
Specifically, PLC motion controllers are connected by EtherCAT buses with multiple servo-drivers.PLC motion controls
Device processed is finished according to control needs beforehand through PLC programming languages such as ladder diagram, ST (Structured Text, structure text)
Corresponding to the functional module of different motion control instruction.The motion control instruction sent according to industrial PC subsystem, PLC fortune
Movement controller transfers corresponding functional module, by the corresponding servo-driver of EtherCAT bus marcos, so as to realize to phase
Answer the motion control of motor shaft
Step S4:The feedback data of the PLC control subsystems is disposably read into the industrial PC subsystem.
Further, in an embodiment of the present invention, the feedback data of PLC control subsystems is driven including the multiple servo
The implementing result data and motor status data of dynamic device controlled motor motion;In the step S4, the PLC control subsystems
The implementing result data and the motor status data are sent to the industrial PC subsystem simultaneously.It is the multiple to watch
Take multiple data storages that the implementing result data and the motor status data are back to PLC motion controllers by driver
Unit.Specifically, servo-driver controlled motor axle motion after, it is necessary to return according to an implementing result, this performs knot
Fruit is stored in the data storage cell of PLC motion controllers;Meanwhile, motor is also by the status data of itself (for example, motor
The data such as rotating speed, position now) updated in real time by servo-driver into data storage cell.Thus, it is possible to facilitate work
Industry PC control subsystems are read.Wherein, multiple data storage cells are multiple discrete registers, and be stored with different servos respectively
The implementing result data of driver feedback and the motor status data of each motor.
In an embodiment of the present invention, lead between the industrial PC subsystem 10 and the PLC control subsystems 20
The Modbus Transmission Control Protocol communication of extension is crossed, the Modbus Transmission Control Protocol of the extension includes batch reading function code and batch writes work(
Can code.Function code 0x61 is read by batch, host computer can disposably read discrete registers data by new function code;Separately
Outer One function be batch write 0x62, i.e. host computer can be by the multiple discrete registers of the function code write once.
Further, as shown in figure 4, above-mentioned steps S1 comprises the following steps:
Step S11:The control module generation motion control instruction of industrial PC subsystem;
Step S12:
Call the api interface function of API library that multiple motion control instructions are stored into the location of instruction successively;
Step S13:The multiple motion control instruction that the location of instruction is stored disposably is sent to described
PLC control subsystems.
Specifically, as described above, passing through extension between the industrial PC subsystem and the PLC control subsystems
Modbus Transmission Control Protocol communicates.Therefore, can when control module is needed to PLC control subsystems transmission multiple motion control instructions
So that by calling the api interface function, by the multiple motion control instruction, sequentially the instruction is arrived in storage successively
Memory cell;Processing unit is polled to the location of instruction, when the location of instruction (does not have motion control to refer to for space-time
When making), processing unit reads the location of instruction, writes function code multiple orders by batch while being issued to PLC control
System;When PLC control subsystems are responded, processing unit will not only read implementing result data, and by motor status data
Also read to come up together, i.e., the data one that function code will be stored in multiple discrete registers of PLC control subsystems are read by batch
The secondary internal memory updated to industrial PC subsystem.Thus, communication data redundancy is greatly reduced, raising communication speed has been reached
Degree, meets the purpose of system requirements.
Further, in the present embodiment, the industrial motion control method based on API also includes:
It is space-time in the location of instruction, the motor status data is disposably read into the industrial PC
Subsystem.
Specifically, when the location of instruction is space-time (when not having motion control instruction), processing unit passes through 0x61 work(
The feedback data of PLC control subsystems, is disposably read industrial PC subsystem deposit internal memory by energy code.So, work is worked as
When industry PC control subsystems need, it can be read directly from internal memory, substantially increase efficiency.
Advantageously, the industrial motion control method based on API that the present embodiment is provided, industrial PC subsystem passes through institute
State API library and disposably send multiple motion control instructions to the PLC control subsystems;PLC control subsystems are according to the plurality of
Motion control instruction controlled motor axle is completed after corresponding motion, and industrial PC subsystem disposably reads PLC control subsystems
The feedback data of system.Thus, both visualization function can be provided by industrial PC subsystem, the steady of PLC can be utilized again
Qualitative control that can be to realize to motor shaft;Meanwhile, pass through extension between industrial PC subsystem and PLC control subsystems
Modbus Transmission Control Protocol communicates, and industrial PC subsystem can write function code simultaneously by multiple motion control instructions by batch
PLC control subsystems disposably are sent to, the feedback data that function code disposably reads PLC control subsystems is write by batch,
It is possible thereby to greatly reduce communication data redundancy, raising communication speed has been reached, the purpose of system requirements is met.
Above disclosed is only a kind of preferred embodiment of the invention, can not limit the power of the present invention with this certainly
Sharp scope, one of ordinary skill in the art will appreciate that all or part of flow of above-described embodiment is realized, and according to present invention power
Profit requires made equivalent variations, still falls within and invents covered scope.