Summary of the invention
In order to solve the above-mentioned technical problem, the object of the present invention is to provide a kind of time based on high speed data acquisition system is same
One step process can truly carry out data acquisition, real-time, authenticity and high reliablity in real time.
The object of the present invention is to provide a kind of clock synchronization system based on high speed data acquisition system, can in real time truly into
The acquisition of row data, real-time, authenticity and high reliablity.
The technical scheme adopted by the invention is that: a kind of method for synchronizing time based on high speed data acquisition system, this method
It comprises the step of:
High speed data acquisition system and background server are subjected to time synchronization with ntp server;
The standard time synchronized from ntp server is covered the timestamp uploaded by PLC by high speed data acquisition system
After data, current time stamp data is uploaded to background server and carries out corresponding data processing.
Further, the high speed data acquisition system covers the standard time synchronized from ntp server by PLC
After the time stamp data of biography, current time stamp data is uploaded to background server and carries out corresponding this step of data processing
Suddenly, it specifically includes:
The time stamp data of itself is sent to high speed data acquisition system by PLC in the form of standard data format;Then, high
The standard time synchronized from ntp server is carried out the Data Format Transform of standard data format by fast data collector;
Then, after the standard time after Data Format Transform is covered the time stamp data uploaded by PLC by high speed data acquisition system, will work as
Preceding time stamp data is uploaded to background server and carries out corresponding data processing.
Further, the high speed data acquisition system covers the standard time synchronized from ntp server by PLC
After the time stamp data of biography, current time stamp data is uploaded to the step for background server carries out corresponding data processing
It is equipped with judgment step, the judgment step later specifically:
Judge that last high speed data acquisition system and background server carry out the history fortune of time synchronization with ntp server
Whether the row time has been more than setting time value, if so, high speed data acquisition system and background server is enabled to service with NTP again
Device carries out time synchronization;Conversely, then terminating.
It is of the present invention another solution is that a kind of clock synchronization system based on high speed data acquisition system, should
System includes PLC, high speed data acquisition system, background server and ntp server, the high speed data acquisition system respectively with
PLC, background server and ntp server communication connection;
The background server, for carrying out time synchronization with ntp server, to synchronize to obtain from ntp server
Standard time;
The high speed data acquisition system, for carrying out time synchronization with ntp server, thus synchronous from ntp server
The standard time is obtained, and the standard time synchronized from ntp server is covered to the time stamp data uploaded by PLC
Afterwards, current time stamp data is uploaded to background server and carries out corresponding data processing.
Further, the PLC is specifically used for sending the time stamp data of itself in the form of standard data format supreme
Fast data collector.
Further, the high speed data acquisition system includes:
Synchronization module, for carrying out time synchronization with ntp server, thus when synchronizing to obtain standard from ntp server
Between;
Digital sampling and processing, for the standard time synchronized from ntp server to be carried out normal data lattice
The Data Format Transform of formula, then, after the standard time after Data Format Transform is covered the time stamp data uploaded by PLC,
Current time stamp data is uploaded to background server and carries out corresponding data processing.
The beneficial effects of the present invention are: by using method of the invention, it is possible to quickly and easily realizing PLC, high speed number
According to the time synchronization of this three of collector and background server, and the timestamp obtained from PLC due to high speed data acquisition system
Data collector buffer area will not be added in data, directly handled, therefore, data stacking, lag the case where it is very small, substantially
It can ignore, just be able to achieve the real-time true acquisition of industrial data by using method of the invention in this way, greatly improve subsequent
The accuracy of industrial data processing result.In addition, when realizing method of the invention, without changing PLC internal timer or soft
Part program, therefore, have many advantages, such as to be easily achieved, ease-to-operate it is high.
Another beneficial effect of the present invention is: by using system of the invention, it can quickly and easily realize PLC, height
The time synchronization of this three of fast data collector and background server, and due to high speed data acquisition system obtained from PLC when
Between stamp data data collector buffer area will not be added, directly handled, therefore, data stacking, lag the case where it is very small,
Substantially it can ignore, just be able to achieve the real-time true acquisition of industrial data by using system of the invention in this way, greatly improve
The accuracy of subsequent industrial data processing result.In addition, when realizing system of the invention, without changing PLC internal timer
Or software program, therefore, have many advantages, such as to be easily achieved, ease-to-operate it is high.
Specific embodiment
The solution of the present invention suitable for industry spot PLC process of real-time data acquisition.
As shown in Figure 1, a kind of clock synchronization system based on high speed data acquisition system, including high speed data acquisition system, after
Platform server, ntp server and multiple PLC, the high speed data acquisition system respectively with multiple PLC, background server and
Ntp server communication connection;Wherein, the PLC substantially refers to live PLC device;
The background server, for carrying out time synchronization with ntp server, to synchronize to obtain from ntp server
Standard time;
The high speed data acquisition system, for carrying out time synchronization with ntp server, thus synchronous from ntp server
The standard time is obtained, and the standard time synchronized from ntp server is covered to the time stamp data uploaded by PLC
Afterwards, current time stamp data is uploaded to background server and carries out corresponding data processing.
As the preferred embodiment of this system embodiment, the PLC is specifically used for the time stamp data of itself to mark
The form of quasi- data format is sent to high speed data acquisition system.
As the preferred embodiment of this system embodiment, the high speed data acquisition system includes:
Synchronization module, for carrying out time synchronization with ntp server, thus when synchronizing to obtain standard from ntp server
Between;
Digital sampling and processing, for the standard time synchronized from ntp server to be carried out normal data lattice
The Data Format Transform of formula, then, after the standard time after Data Format Transform is covered the time stamp data uploaded by PLC,
Current time stamp data is uploaded to background server and carries out corresponding data processing.
For a kind of above-mentioned clock synchronization system based on high speed data acquisition system, as shown in Fig. 2, its specific synchronous method
Step includes:
Step 1, by high speed data acquisition system and background server and ntp server carries out the time in a manner of Ethernet
It is synchronous, thus enable high speed data acquisition system and background server from ntp server synchronize obtain the standard time;
Step 2, high speed data acquisition system are uploaded the standard time synchronized from ntp server covering by PLC
After time stamp data, even standard time for being synchronized from ntp server of high speed data acquisition system as PLC it is current when
Between stab data, complete the standardization of PLC time stamp data, current time stamp data be then uploaded to background server and carries out phase
The data processing answered.
As the preferred embodiment of this method embodiment, the step 2 is specifically included:
PLC by using the system protocol of offer, network adapter or fieldbus mode, by the timestamp number of itself
The form of standard data format is sent to high speed data acquisition system accordingly;Then, high speed data acquisition system will be from ntp server
The standard time synchronized carries out the Data Format Transform of standard data format;Then, high speed data acquisition system is by data lattice
After standard time after formula conversion overrides the time stamp data uploaded by PLC, current time stamp data is uploaded to backstage
Server carries out corresponding data processing.Hereafter, PLC continuous transmission time stamp data is to high speed data acquisition system, high-speed data
The temporal information of itself is replaced original PLC time stamp data by collector, as new PLC time stamp data, i.e., currently
The PLC time stamp data at moment can synchronize as universal time, and then, high speed data acquisition system is by the PLC after standardization
Time stamp data is transmitted to background server and carries out corresponding data processing.
As the preferred embodiment of this method embodiment, judgment step, the judgment step are equipped with after the step 2
Specifically:
Judge that last high speed data acquisition system and background server carry out the history fortune of time synchronization with ntp server
Whether the row time has been more than setting time value, that is, is judged high speed data acquisition system and background server from the last time and NTP
Whether the history run time that server carries out time synchronization is more than setting time value, such as a week or one month, if so, weight
High speed data acquisition system and background server is newly enabled to carry out time synchronization with ntp server;Conversely, then terminating.
As the preferred embodiment of the systems and methods embodiment, the standard data format is Unix
Timestamp format.
One specific embodiment of the method for the present invention
Setting PLC includes PLC1, PLC2, PLC3, and when current time is on January 9th, 2017 14:15:27, PLC1
Between be 14:14:00 on January 9th, 2017, the PLC2 time be 14:15:27 on January 8th, 2017, the PLC3 time be January 1 in 1970
Day 14:15:27.
A kind of method for synchronizing time based on high speed data acquisition system, specific steps include:
S101, high speed data acquisition system and background server are subjected to the synchronous of current time with ntp server, enabled high
Fast data collector and background server obtain the standard time from ntp server;
The obtained standard time is converted into the data (lattice of Unix timestamp format by S102, high speed data acquisition system
At the Lin Weizhi time 1970 01 month 01 day 00 00 divide 00 second to present total number of seconds), i.e., the Unix stored at this time
The standard time of timestamp format is 1483942527;
The time stamp data of itself is transmitted to high speed data acquisition system and with Unix by S103, PLC1, PCL2, PLC3
Timestamp format carries out data storage, wherein at this point, the time stamp data of PLC1 is the timestamp of 1483942440, PLC2
The time stamp data that data are 1483856127, PLC3 is 22527;
S104, in high speed data acquisition system, the standard time synchronized from ntp server is override at this time
The time stamp data of PLC1, PLC2, PLC3 realize the standardization of PLC temporal information;
S105, PLC1, PLC2, PLC3 continuous transmission time stamp data, be standardized every time the time cover and store and
It is sent to background server;
S106, background server carry out corresponding data processing.
It is obtained by above-mentioned, advantage included by method and system of the invention has:
1, can be avoided the time between live PLC it is skimble-scamble happen, and realize the multiple PLC in scene, high speed number
According to the time synchronization of collector and background server;
2. PLC has a possibility that initialization time after restarting, directly covered using the normalized temporal of high speed data acquisition system
The method of lid can be avoided the case where time changes after PLC is initialized, and operating flexibility and convenience are high;
3. the standard of PLC timestamp information can be carried out in the case where not changing PLC internal timer or PLC program
Change, to realize that data are synchronous and acquisition, have many advantages, such as to be easily achieved, operation element amount it is low, at low cost;
4, the normalized temporal information of each PLC can be accurately obtained, so that data have more real-time and authenticity, no longer
Error is generated because of the time difference of PLC, so that background server be enable accurately to show that some station acts in the industry
At the time of, the probability of error is reduced, the real-time collecting and processing of data are more advantageous to.
It is to be illustrated to preferable implementation of the invention, but the invention is not limited to the implementation above
Example, those skilled in the art can also make various equivalent variations on the premise of without prejudice to spirit of the invention or replace
It changes, these equivalent deformations or replacement are all included in the scope defined by the claims of the present application.