Summary of the invention
For the deficiencies in the prior art, it is a kind of for the real-time communication method between many main station systems that primary technical problem to be solved by this invention is to provide.
Another technical problem to be solved by this invention is to provide a kind of real time communication device for above-mentioned real-time communication method.
For achieving the above object, the present invention adopts following technical scheme:
For the real-time communication method between many main station systems, the real time communication between main station system is converted into the communication between slave station under main station system:
The first main station system sends data by real-time communication protocol to its institute's slave station of hanging;
Described slave station produces interrupt requests after receiving and process the real time data of described the first main station system;
Be idle condition and while having interrupt requests when the corresponding slave station communication manager of described slave station monitors slave station, the real time data in slave station write in real time data buffer;
When the slave station communication manager of the second slave station that main station system is hung, to monitor corresponding slave station be idle condition and there is no interrupt requests, the real time data in described real time data buffer write in described slave station;
Described slave station adopts real-time communication protocol that real time data is sent to the second main station system.
Wherein more preferably, described real time data buffer is the data fifo buffer that both direction is contrary, and the course of work of slave station communication manager is as follows:
Monitoring slave station is idle condition and while having interrupt requests, reads in described slave station real time data and writes the first data fifo buffer; If described slave station is idle condition and there is no interrupt requests, read the real time data in the second data fifo buffer and write in described slave station.
Wherein more preferably, described real time data buffer is Double Port Random Memory.
Wherein more preferably, described slave station communication manager reads the condition that judges whether to possess read data in described slave station before real time data: in the time that slave station data ready and the first data fifo buffer are discontented, read data in described slave station, and write described the first data fifo buffer; If when in described slave station, not ready or described the first data fifo buffer of real time data is full, continue to wait for;
Condition to judging whether to possess the data write before described slave station writes real time data: judge whether the second data fifo buffer is empty: if it is empty, continue to wait for; If not empty, read the real time data of described data fifo buffer, and described data are write in described slave station.
Wherein more preferably, described real-time communication method also comprises the conversion method of slave station operating state, and concrete steps are as follows:
Described main station system sends the request of state control command to slave station;
Described slave station processes said request, and write slave station control word, produce interrupt requests to corresponding described slave station communication manager simultaneously;
Interrupt requests described in described slave station communication manager processes, slave station status word and described slave station control word are compared to judgement: if meet the transforming relationship of slave station state, respond described request and described slave station control word is write to slave station status word, and completion status is switched; Otherwise provide error flag.
Wherein more preferably, slave station state comprises initialization, prerun, safe operation, four kinds of operating states of operation and a kind of alternative boot state; The transforming relationship of described slave station state is:
When described init state transforms to described running status, transform according to the order of initialization, prerun, safe operation, operation;
When described running status transforms to described init state, transform according to operation, safe operation, prerun, initialized order;
Described boot state is alternative state, only and between described init state mutually transforms.
For realizing a real time communication device for above-mentioned real-time communication method, be series between two main station systems, comprise two slave stations and a real time communication controller; Described real time communication controller communicates with described two slave stations respectively; Described slave station carries out real time communication with corresponding main station system;
Described real time communication controller comprises two slave station communication managers and two data fifo buffers; The control of described slave station communication manager coordinates main website to slave station running status, and control slave station data and write a data fifo buffer or the data of another data fifo buffer write described from station control; Described data fifo buffer is for the data interaction of two slave stations, and wherein the entrance of any one data fifo buffer is for a slave station data writing, and outlet is for another slave station sense data.
Wherein more preferably, each described slave station comprises communication interface, interface circuit and from station control;
The communication signal of telecommunication of described main station system is passed to interface circuit by communication interface; Described interface circuit sends to the described signal of telecommunication from station control after isolation transformation, analog-to-digital conversion are communication message; The described real-time communication protocol of identifying described main station system transmission message from station control, and according to the data of carrying in corresponding real-time communication protocol extraction storing communication message.
Wherein more preferably, two main station systems of described real time communication device series connection have different real-time communication protocols.
Wherein more preferably, described slave station and described real time communication controller communicate by high speed parallel bus.
Provided by the invention for the real-time communication method between many main station systems and equipment thereof, there is following beneficial effect: be 1) multiple independently communication between main station system, a kind of novel real-time communication method is provided; 2) can realize the two-way real-time data communication of high speed between many main websites, high accuracy, high reliability; 3) little, the easy to install and communication data flexible configuration according to the actual requirements of equipment volume.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in further detail.
Provided by the present invention for the real-time communication method between many main station systems, its basic ideas are the real time communication between Liang Ge main website to be converted into Liang Ge main website extension for the real time communication between the slave station of real time communication.Due to technical conditions restriction, conventionally between main station system, can not directly carry out hard real time communication at present.And can carry out hard real time communication by real-time communication protocol between master station and follow station.Based on this, the real time communication in the present invention between main station system is completed by the lower slave station for real time communication of hanging in main station system.As long as ensure to carry out real time communication between slave station under two main station systems, just can realize the high speed between main station system, high-precision bidirectional real-time.The real time communication device providing in the present invention is serially connected with in the independent main station system of two covers, can between two cover systems, erect the passage of a real time communication, thereby realize the real time communication between main station system.The present invention had both solved the communication issue between main station system, had guaranteed again real-time and the reliability of communication simultaneously.
Conventionally under main station system, may hang with many slave stations such as IO module, driver, and the slave station adopting in the present invention is only responsible for the real time communication between main station system, can be articulated under main website together with the slave station of above-mentioned other function.The present invention hangs the state of real time communication slave station by monitoring main website, controls between two slave stations and real time data buffer and carries out data interaction, thereby realize between two independent main station systems in real time, fast, communicate by letter flexibly.Conventional real time data buffer has multiple, such as dual port RAM (random asccess memory) and FIFO (first in first out) data buffer etc.Preferred data fifo buffer in the present invention, it is advantageous that the data storage principle of FIFO simply, reliably, can shorten to greatest extent data processing time, guarantees real-time and the reliability of communication process.Therefore the slave station of being responsible for real time communication in different independent main station systems can realize real-time data interaction by data fifo buffer.
Communication between master station and follow station adopts real-time communication protocol.Between master station and follow station applicable real-time communication protocol comprise multiple, such as EtherCAT, SERCOS III, PROFINET etc.Wherein the communication cycle of EtherCAT, two kinds of real-time ethernet technology of SERCOS III (i.e. a data interaction time) can reach below 1ms, is applicable to very much the High-speed Control application of hard real-time, high reliability.In the present invention, real-time communication method is applicable to multiple real-time communication protocol, does not do specific restriction for the real-time communication protocol adopting between main website and slave station.And multiple independent main station systems also can be selected different real-time communication protocols.
The slave station that real time communication in the present invention between main station system is hung responsible real time communication by two main station systems completes.Therefore the present invention comprises two communication processs: the one, and communicating by letter between main station system and slave station; The 2nd, the communication between slave station.Communication process between paper main station system and slave station.Main station system is hung real time communication slave station by real-time communication protocol and its and is carried out data interaction.In slave station, generally include communication interface, interface circuit and from station control etc.In the time that slave station receives the signal of telecommunication that main station system transmits, first the signal of telecommunication is passed to interface circuit by communication interface.Interface circuit after isolation transformation, analog-to-digital conversion etc. are processed, sends to the signal of telecommunication from station control by communication data.Be responsible for processing the Frame of real-time communication protocol from station control, and deposit data is entered to have dual-port data memory module, thereby it is mutual to realize real time data between main website and slave station.From station control according to the physical location order displacement of oneself frame that reads and writes data.In the time of message process slave station, from message, extract and send to the output command data of oneself and be stored in data storage area from station control, and carry out reading out data with interrupt mode notice slave station communication manager.
Communication in the present invention between slave station has been responsible for by slave station communication manager.Each slave station has the operating state of corresponding slave station communication manager monitoring from station control, coordinates from the high speed data transfer between station control and two data fifo buffers simultaneously.And between slave station by two data fifo buffers being carried out to read-write operation, just can complete the mutual of real time data.The opposite direction of two data fifo buffers, wherein the entrance of any one data fifo buffer is for a slave station data writing, and outlet is for another slave station sense data.Two slave station communication managers, by controlling corresponding slave station and two data fifo buffers carry out data interaction, can be realized the real time communication between slave station.Due to the corresponding slave station communication manager of each slave station, and workflow is identical, therefore, below taking the course of work of a slave station communication manager as example, the process of data interaction between slave station is described to (referring to Fig. 1).
The monitoring of slave station communication manager is from the state of station control.When during in idle condition, if now have interrupt requests from station control, entering the flow process that reads slave station controller data from station control; If now there is no interrupt requests, enter to the flow process of writing data from station control.
In the time of the data that read from station control, first slave station communication manager judges whether to possess the condition of read data: if when the first data fifo buffer corresponding to the data ready from station control and this slave station is discontented with, read the data from station control, and data are write in this data fifo buffer; If from station control the not ready or current data fifo buffer of data for full (the data in this data fifo buffer also do not write another main station system from station control) time, continue to wait for, until read data condition reading out data again while meeting.
When from station control data writing, first slave station communication manager judges whether the second data fifo buffer is empty: if the second data fifo buffer is for empty (being not having to this data fifo buffer data writing from station control in another main station system), continue to wait for; When this data fifo buffer when empty (from station control its data having been write to this data fifo buffer in another main station system), read the data in data fifo buffer, and data are write accordingly from station control.
Above flow process has only been described single slave station communication manager coordinates and has carried out from station control and data fifo buffer the flow process of transfer of data.The slave station communication manager that each slave station is corresponding passes through idle condition and the interrupt requests of the corresponding slave station of monitoring, controls, from station control, data fifo buffer is carried out to read-write operation, realizes the real-time data communication between slave station.
Based on above-mentioned known, the communication process between main station system by: hung real time communication slave station when a main station system by real-time communication protocol to it and sent after data, slave station receive and deal with data after can produce interrupt requests; The slave station communication manager monitoring slave station of this slave station is idle condition and while having interrupt requests, the real time data in this slave station is write in data fifo buffer; When the slave station communication manager of slave station that another main station system is hung, to monitor corresponding slave station be idle condition and there is no interrupt requests, the real time data in data fifo buffer write in this slave station; This slave station adopts real-time communication protocol to process real time data, and sends data in another main station system.In whole communication process, two slave station communication managers are by controlling the transfer of data between real time data buffer and slave station, have realized high-speed data between two slave stations mutual, and then have realized the real-time data communication between two independent main station systems.It should be noted that, in the present embodiment, real time data buffer adopts data fifo buffer, can certainly be substituted by dual port RAM, is not describing here.
In addition the also responsible control of coordinating the running status of main website to slave station of slave station communication manager in the present invention.According to the real-time communication protocol of main website configuration, slave station can comprise several operating states conventionally.When slave station is normally worked, need between these several operating states, switch back and forth.The real-time communication protocol that different main station systems configures, may be different.Taking EtherCAT real-time ethernet communication protocol as example, the handover mechanism of slave station operating state is described.According to EtherCAT communication protocol, EtherCAT slave station must be supported four kinds of operating states and a kind of alternative operating state:
(1) Init: initialization, is abbreviated as I;
Init state defined main website with from standing in the initialize communications relation of application layer.Now, main website and slave station application layer cannot direct communications, and main website carrys out initialization some configuration registers from station control by init state, configures mailbox communication channel parameters simultaneously.
(2) Pre-Operational: prerun, is abbreviated as P;
Under prerun state, main website can exchange the initialization operation relevant with application program and parameter with mailbox communication to slave station, but can not carry out process data communication.
(3) Safe-Operational: safe operation, is abbreviated as S;
Under safe operation state, slave station application program is read in input data, but does not produce output signal.
(4) Operational: operation, is abbreviated as O;
Under running status, slave station application program both can have been read in input data, also can send output data, produced output signal.
(5) Boot-Strap: boot state, is abbreviated as B;
Boot state is alternative operating state, and it is mainly used in download equipment firmware program.
Fig. 2 is the transforming relationship figure between above each state.While conversion from Init state to Operational state, must transform according to the order of " Init → Pre-Operational → Safe-Operational → Operational " conversion of cannot bypassing the immediate leadership.In the time that returning, can change in order Operational state, the conversion of also can bypassing the immediate leadership, as; Operational → Init, Operational → Pre-Operational → Init, Operational → Safe-Operational → Init.Boot-Strap state is optional state, only allows mutually to transform between init state.All states change Dou You main website initiates, and main website sends the request of state control command to slave station, and writes slave station control word.Now, can produce interrupt notification slave station communication manager from station control, slave station communication manager compares judgement for current slave station status word and control word.If meet above-mentioned state transforming relationship, the state that response is asked transforms, and the content of slave station control word is write to slave station status word, and completion status is switched.If transform unsuccessfully if do not meet transforming relationship or the state of slave station state, slave station communication manager will provide error flag.
In order to embody feasibility and the validity of above-mentioned real-time communication method, it is a kind of for realizing the real time communication device of above-mentioned real-time communication method that the present invention also provides.
As shown in Figure 3, the A of main website system and the B of main website system represent that respectively two overlap independently main station system.Under two main station systems, may hang with respectively many slave stations (not shown in FIG.) such as IO module, driver, form separately a set of complete dcs.A, B two overlap between main station system separate, and main station system can adopt different real-time communication protocols.Real time communication device of the present invention is serially connected with in the A of main website system and the B of main website system, two the slave station A and the B that comprise a real time communication controller C and be connected with real time communication controller C.Two slave station A and B are only responsible for carrying out the real time communication between main station system.Between main station system and slave station A and B, carry out real time communication by high-speed field bus or real-time industrial ethernet etc.Between slave station A and slave station B, under the coordination of real time communication controller C, communicate by high-speed parallel data/address bus.Real time communication device of the present invention, the real time communication demand between Liang Ge main website, has changed into the Real Time Communication Problems between two slave stations.Adopt multiple real time communication devices can realize three and there is above the real time communication between identical or different real-time communication protocol main station systems.
Referring to Fig. 4, two slave stations of this real time communication device include from station control, two interface circuits and two communication interfaces.Two communication interfaces are respectively interface IN and interface OUT.Wherein slave station is connected with main website or previous slave station in main station system by interface IN; Be connected with next slave station by interface OUT, if there is no other slave stations below, OUT mouth does not connect.Main website is used for the signal of telecommunication of communicating by letter by the communications cable to slave station transmission, and slave station is passed to communication interface circuit after receiving the signal of telecommunication.Communication interface circuit is communication message by the signal of telecommunication through isolation transformation, analog-to-digital conversion, then communication message is sent to from station control.Be responsible for processing the Frame of real-time communication protocol from station control, and it is mutual to use dual-port memory block to realize real time data between main website and slave station.From station control according to the physical location order displacement of oneself frame that reads and writes data.In the time of message process slave station, from message, extract and send to the output command data of oneself and be stored to internal storage region from station control, and carry out reading out data with interrupt mode notice real time communication controller C.
Real time communication controller C connects two slave stations as communication bridge.Real time communication controller C be responsible on the one hand controlling the switching of two slave station operating states and coordinate slave station and main website between real time communication, coordinate on the other hand the real-time, interactive of communication data between two slave stations.Real time communication controller C comprises two slave station communication managers and two data fifo buffers.Each slave station communication manager is connected with two data fifo buffers, and wherein the entrance of any one data fifo buffer is for one from station control data writing, and outlet is used for another from station control sense data.Slave station communication manager has two modules: slave station state management module is responsible for slave station working state administration, is responsible for coordinating the control of main station system to slave station running status; Data Transmission Controlling module, according to the communications status from station control, is controlled and from station control, data is write to a data fifo buffer or the data of another data fifo buffer are write to this from station control.
It should be noted that, two slave stations in the real time communication device in the present invention and real time communication controller both can select respectively independently control chip to realize, and also can select the one single chip integration realizations such as FPGA, CPLD, microprocessor.In addition, only need in the configuration software of main station system, simply set, can realize the flexible setting of real-time communication data amount between two main station systems.In real time communication device use procedure, can also, at the main station system state of data communication between two slave stations of monitoring in real time, judge whether to exist the garbles such as packet loss.
The present invention can adopt multiple above-mentioned real time communication devices, realizes the real time communication between three and above main station system.Below taking the real time communication between three independent main station systems as example, the concrete grammar of realizing real time communication between three and above main station system is described.As shown in Figure 5, the A of main website, B, C are respectively three separate main station systems.Below each main station system, may hang with many other slave stations, in figure, all not draw.Realize three real time communication between main station system, can select two kinds of topological structures as shown in Figure 5 and Figure 6.
If Fig. 5 is the real time communication device that adopts three the present invention to propose, three main station systems are coupled together between two, form loop system topological structure.Between three main station systems, can directly carry out between two real time communication, between Principle of Communication and above-mentioned Liang Ge main website, the principle of real time communication is identical.What Fig. 6 was different from Fig. 5 is only to have adopted two real time communication devices that the present invention proposes.As shown in Figure 6, utilize real time communication device, the A of main website, the B of main website are connected with the C of main website respectively.Between the A of main website and the C of main website, can directly carry out real time communication, between the B of main website and the C of main website, also can directly carry out real time communication.Real-time communication data between the A of main website and the B of main website need pass through the C of main website transfer, and then has indirectly realized the real time communication between the A of main website and the B of main website.For example, if the A of main website will send data to the B of main website, first send the data to the C of main website.The C of main website receives after data, then is transmitted to the B of main website.Real-time communication protocol due to what adopt between main website and corresponding slave station, and what between two slave stations of single communication module inside, adopt is high speed parallel communication agreement, above-mentioned data relay process time postpones very little, therefore can ensure the real-time of communicating by letter between the A of main website and the B of main website.The advantage of Fig. 6 is to have saved a two slave station real time communication device, and the communication priority between the applicable A of main website and the C of main website, the B of main website and the C of main website is higher, the lower application scenario of real time communication priority between the A of main website and the B of main website.The communication mode of three above many main station systems and system topology and said method are similar, can be by that analogy.
In sum, real-time communication method provided by the present invention, has realized the independently two-way real-time data communication of high speed, high accuracy, high reliability between main station system.Adopt real time communication device provided by the present invention, not only can realize the hard real time communication between two main station systems, can also realize the real time communication between three and above many main station systems, this real time communication device has little, the easy to install and amount of communication data advantage such as flexible configuration according to the actual requirements of volume simultaneously.
Have been described in detail for the real-time communication method between many main station systems and equipment thereof provided by the present invention above.For one of ordinary skill in the art, any apparent change of under the prerequisite that does not deviate from connotation of the present invention, it being done, all will form infringement of patent right of the present invention, will bear corresponding legal liabilities.