Background technology
At present, data transmission technology is widely used in every field, is used widely too in water conservancy system and Crude Oil Transportation field.In water conservancy system,, usually need the water level in the irrigated area, flow, one-tenth gradation parameter are measured and transmitted in order to save water resource, regulation and control agricultural irrigation water.
Usually, the irrigated area adopts some data transfer mode to multiple spot to transmit each parameter mostly.So-called some data transfer mode of multiple spot is referred to, set up a central station in the irrigated area, in the trunk canal, branch canal, lateral canal etc. locate to be provided with several measuring points, central station can carry out transfer of data separately with each measuring point respectively.Wherein, central station sends request msg to each measuring point respectively, requires each measuring point collection and uploads data; Each measuring point response request, and response data (for example water level, flow, one-tenth gradation parameter) transferred to central station, carry out integral body metering, scheduling and control by central station.
In the prior art, can adopt the mode of wired connection between each measuring point and the central station, transmit data by cable.But in actual applications, the irrigated area system is generally huger, and the distance between measuring point and the central station is distant, often reaches tens of kilometers.Therefore,, need between the concentricity station of each measuring point, lay very long cable, make cost higher if adopt the wired connection mode to carry out transfer of data.In addition, adopt the wired connection mode to grow the transfer of data of distance, because cable is longer, the probability that faults such as opening circuit occurs increases, and this makes reliability of data transmission descend, so that can incur loss through delay normal water scheduling of whole irrigation district and control.
In view of the defective of wired connection mode, people then in the irrigated area employing wireless data transfer mode realize transfer of data between the concentricity station of each measuring point.
See also Fig. 1, be in the prior art central station with the transfer of data schematic diagram between each measuring point.Central station is with adopting some data transfer mode to multiple spot between each measuring point.Each measuring point (measuring point 1, measuring point 2, until measuring point N-1 and measuring point N) and central station are respectively arranged with wireless transceiver (figure does not show) and antenna (scheming not show).Wherein, each measuring point and central station are in asynchronous transfer mode, and just, the wireless transceiver of each measuring point and antenna are in accepting state all the time, can receive and respond the request msg from central station at any time.
In data transmission procedure, wireless transceiver that central station has by himself and antenna directly send request msg to each measuring point respectively; Wireless transceiver that each measuring point is provided with by self and antenna directly receive the request msg from central station, and respond; Each measuring point directly sends response data to central station; Central station receives the response data from each measuring point respectively.So just realized that central station is respectively with the transfer of data between each measuring point.
Wherein, the set antenna of central station is an omnidirectional antenna, be used for its coverage in each measuring point carry out the wireless transmission of data respectively.Each measuring point is provided with the directional antenna towards central station, be used to realize and central station between transfer of data.
Adopt some the data transfer mode to multiple spot can realize the transfer of data between each measuring point and central station in the irrigated area.But in actual applications, inevitably there is following defective in said method:
One, it is bigger to consume energy.The normal data transfer mode that adopts any to multiple spot in the prior art, just each measuring point communicates with central station respectively.Because the distance between each measuring point and the central station is often all longer, need in central station and each measuring point, powerful transceiver be set and antenna could be realized remote transfer of data.Like this, make that the energy consumption of each measuring point and central station is bigger.
Simultaneously, because each measuring point and central station are in asynchronous transfer mode, each measuring point is started shooting all the time and is in accepting state, and this causes energy consumption bigger equally.
Its two, cost is higher.Because in order to carry out remote transfer of data, central station and each measuring point need adopt powerful transceiver and antenna in the prior art, this makes cost higher.Simultaneously, because each measuring point is in accepting state all the time, power consumption is bigger, often needs to dispose the battery than macro-energy, and this causes cost higher equally.
Summary of the invention
The technical problem that the present invention solves is: a kind of data transmission system method of unifying is provided, can have cut down the consumption of energy, reduce cost.
For this reason, the technical scheme of technical solution problem of the present invention is:
A kind of method of transfer of data is provided, is used to realize the transfer of data between central station and several measuring points; Comprise step:
Setting up procedure regularly: each measuring point starts simultaneously according to timing signal and is in accepting state;
Descending step: central station is sent to first measuring point with request msg, and the measuring point of confessing one's crime rises, and will be forwarded to adjacent descending measuring point from the request msg of central station, by that analogy, and until being sent to the tail measuring point from the request msg of central station;
Up step: from the tail measuring point, each measuring point will be sent to adjacent up measuring point from the response data of adjacent descending measuring point and this measuring point response data, by that analogy, until first measuring point the response data of all measuring points will be sent to central station.
Described descending step specifically comprises: measuring point judges whether destination address in the request msg comprises the address of this measuring point; If, response request then, and request msg is forwarded to adjacent descending measuring point; If not, then directly transmit request msg to adjacent descending measuring point.
Also comprise the clock byte in the request msg of described descending step, be used for when each measuring point receives request msg relatively whether this measuring point clock is identical with described clock byte record clock data; If different, then come the clock of fair copy measuring point, and revise the data of described clock byte according to described clock byte; If identical, then only revise the data of described clock byte.
The process of revising the clock byte data in the described descending step specifically comprises: each measuring point adds that with the clock byte data that receives this measuring point receives the time of delay and the data processing time of request msg.
The step that before described descending step, also comprises the specified data transmission path.
The step of specified data transmission path specifically comprises: determine that concentricity station carries out the first measuring point of transfer of data; In the measuring point of remainder, select with the nearest measuring point of first measuring point as adjacent descending measuring point; By that analogy, until definite tail measuring point.
Come the path of specified data transmission according to the measuring point geographical position.
A kind of system of transfer of data is provided, comprises central station and several measuring points, described system also comprises: start unit regularly is used for controlling each measuring point according to timing signal and starts simultaneously and be in accepting state; The downlink transfer passage, be used to carry out the downlink data transmission operation: the request msg of central station is sent to first measuring point, and the measuring point of confessing one's crime rises, and will be forwarded to adjacent descending measuring point from the request msg of central station, by that analogy, until being sent to the tail measuring point from the request msg of central station; The uplink passage, be used to carry out the transmitting uplink data operation: from the tail measuring point, each measuring point will be sent to adjacent up measuring point from the response data of descending measuring point and this measuring point response data, by that analogy, until first measuring point the response data of all measuring points will be sent to central station.
Described timing start unit comprises being arranged on and is used in each measuring point regularly and exports the timer of timing signal and according to the microprocessor of timing signal executive control operation.
Described timing start unit also comprises the clock alignment module, is used to calibrate the clock signal of measuring point.
Described measuring point also comprises power subsystem, is used under the control of timer and microprocessor, regularly provides operating voltage for measuring point.
Described measuring point further comprises omnidirectional antenna.
Described central station also comprises the reference clock unit, is used to described system that reference clock signal is provided.
With respect to prior art, the invention has the beneficial effects as follows:
The first, energy consumption is low.Adopt point-to-point data transfer mode among the present invention, have only the direct concentricity station of a measuring point (first measuring point) to carry out transfer of data in the whole system, carry out transfer of data in all the other measuring points in twos between the measuring point mutually.Just, in downlink data transmission, central station is sent to first measuring point with request msg, central station is sent to first measuring point with request msg, the measuring point of confessing one's crime rises, to be forwarded to adjacent descending measuring point from the request msg of central station, by that analogy, until being sent to the tail measuring point from the request msg of central station.。In transmitting uplink data: from the tail measuring point, each measuring point will be sent to adjacent up measuring point from the response data of adjacent descending measuring point and this measuring point response data, by that analogy, until first measuring point the response data of all measuring points will be sent to central station.Because the distance between the measuring point is much smaller than the distance between the concentricity station of each measuring point in twos, like this, adopt the data transmission system provided by the invention method of unifying, power is less when just making each measuring point data transmission, thus energy consumption is lower.
Simultaneously, be provided with timer in each measuring point of the present invention, microprocessor comes according to timing signal that regularly starting measuring point enters accepting state, requires each measuring point to be in accepting state all the time and need not to resemble the prior art.Thereby compare with prior art, adopting the data transmission system provided by the invention method of unifying, energy consumption is lower.
The second, cost is less.Because unifying, data transmission system provided by the invention have only a concentricity station of measuring point to carry out transfer of data in the method, all the other measuring points carry out transfer of data between any two mutually, the distance of transfer of data data transmission distance more of the prior art reduces, thereby need not to adopt powerful transceiver and antenna, thereby, reduced cost.Simultaneously, the energy consumption of method is less because data transmission system provided by the invention is unified, and need not to adopt the storage battery of macro-energy or often change battery, makes cost less equally.
Embodiment
Seeing also Fig. 2, is the schematic flow sheet of data transmission method of the present invention.Among the present invention, the data transmission procedure between central station and several measuring points specifically comprises the steps:
Setting up procedure regularly: each measuring point starts simultaneously according to timing signal and is in accepting state;
Descending step: central station is sent to first measuring point with request msg, and the measuring point of confessing one's crime rises, and will be forwarded to adjacent descending measuring point from the request msg of central station, by that analogy, and until being sent to the tail measuring point from the request msg of central station;
Up step: from the tail measuring point, each measuring point will be sent to adjacent up measuring point from the response data of adjacent descending measuring point and this measuring point response data, by that analogy, until first measuring point the response data of all measuring points will be sent to central station.
Wherein, first measuring point refers to the measuring point that transfer of data is carried out at direct concentricity station.The tail measuring point refers to the final measuring point that receives request msg in descending step.
Descending measuring point refers to: when measuring point carried out transfer of data in twos in descending step, the measuring point that receives request msg was called the descending measuring point of the measuring point that sends request msg; When measuring point carried out transfer of data in twos in up step, the measuring point that sends response data was called the descending measuring point of the measuring point that receives response data.
Up measuring point refers to: when measuring point carried out transfer of data in twos in the descending step, the measuring point that sends request msg was called the descending measuring point of the measuring point that receives request msg; When measuring point carried out transfer of data in twos in up step, the measuring point that receives response data was called the up measuring point of the measuring point that sends response data.
Be example with the data transmission procedure between central station and N the measuring point below, describe data transmission method of the present invention in detail.
In the timing setting up procedure, N measuring point starts simultaneously according to timing signal and enters accepting state, so that receive the request msg from central station.
In descending step, central station is sent to measuring point 1 with request msg, and measuring point 1 will be sent to measuring point 2 from the request msg of central station, by that analogy, will be sent to measuring point N from the request msg of central station until measuring point N-1.
In up step, measuring point N will be sent to measuring point N-1 from the response data of measuring point N, measuring point N-1 will be sent to measuring point N-2 from the response data of measuring point N-1 and measuring point N, by that analogy, until measuring point 2 measuring point 2 to the response data of measuring point N is sent to measuring point 1, and will be sent to central station from measuring point 1 to the response data of measuring point N by measuring point 1.
Wherein, direct concentricity station carry out transfer of data measuring point 1 promptly headed by measuring point; Measuring point N is the tail measuring point.Measuring point 1 is the up measuring point of measuring point 2, and correspondingly, measuring point 2 is descending measuring points of measuring point 1; In like manner, measuring point 2 is up measuring points of measuring point 3, and measuring point 3 is descending measuring points of measuring point 2, and by that analogy, measuring point N-1 is the up measuring point of measuring point N, and measuring point N is the descending measuring point of measuring point N-1.
The data frame format of the response data in the up step is referring to table one:
Table one, data frame format
Synchronous 1 | Synchronous 2 | Destination address | Control section begins | The clock byte | Control section finishes | Data segment begins | Node number | Nodal information | Node number | Nodal information | 。。 | Node number | Nodal information | Data segment finishes | The CRC verification |
Wherein, after each measuring point received request msg in the descending step, needs judge whether the destination address in the request msg comprises the address of this measuring point; If then take off the data (to call private data in the following text) of issuing this measuring point, and, simultaneously request msg continued to send to next measuring point according to the private data response request; If not, will continue to send request msg.
Wherein, the Data Control frame format of the request msg in the descending step is referring to table two:
Table two, the Data Control frame format
Synchronous 1 | Synchronous 2 | Destination address | Control section begins | Control word | The clock byte | Control section finishes | Data segment begins | Node number | Nodal information | Node number | Nodal information | 。。 | Node number | Nodal information | Data segment finishes | The CRC verification |
Wherein, the clock byte is used in the downlink data transmission process, and the reference data of calibration clock is provided for each measuring point.Because in actual use, the clock accuracy of each measuring point is low than the clock accuracy of central station, and the clocking error of each measuring point is uncertain, and this makes that the clock signal of same each measuring point of the moment can be inequality.Because each measuring point and central station are operated in synchronous transfer module, if each measuring point is not followed unified clock signal, but it is only regularly next according to clock separately, will make each measuring point not start simultaneously and enter accepting state like this in the same moment, thereby cause whole system can not enter synchronous transfer module, also just can not normally carry out transfer of data., just need calibrate, so that whole system is all followed unified clock the clock signal of each measuring point for this reason.
The method of calibration clock can be: after each measuring point received request msg, relatively whether this measuring point clock was identical with the clock data of clock byte record; If different, then be as the criterion with the clock byte, come the clock of fair copy measuring point, and revise the data of clock byte; If identical, then only revise the data of clock byte.The so-called clock byte of revising refers to data delay time and the data processing time that each measuring point adds the data of the clock byte of reception this measuring point.
Illustrate below and how to carry out clock alignment.
The data of clock byte are 20s in the request msg that measuring point 1 receives, be 100ms the time of delay of 2 transfer of data and from measuring point 1 to measuring point, the data processing time of measuring point 2 (promptly receive request msg and send time interval of request msgs to measuring point 3 from measuring point 2) 10ms is 20.11ms by measuring point 2 to the time byte that measuring point 3 sends so.Wherein, be meant that request msg is issued to the time interval that the transceiver of next measuring point receives by the transceiver of measuring point the time of delay of transfer of data between the described measuring point.
It is pointed out that before descending step, to comprise the step of determining N measuring point data downlink transmission path, before up step, can also comprise the step of determining N measuring point data uplink transmission path.
In actual applications, determine that the method for N measuring point data transmission path in the system has multiple: method one can be determined the path of N measuring point data transmission according to the measuring point geographical position, just determines the transfer of data order of each measuring point along river system.Method two also can be provided with router in each measuring point, determine the data transfer path of N measuring point by route.
The detailed process of method two is: at first, determine the measuring point 1 of concentricity station communication; Then, in a remaining N-1 measuring point, select with the nearest measuring point of measuring point 1 as measuring point 2; Again, in a remaining N-2 measuring point, select with the nearest measuring point of measuring point 2 as measuring point 3; By that analogy, until definite measuring point N.
The present invention also provides a kind of system of transfer of data, comprises central station, several measuring points, timing start unit, downlink transfer passage and uplink passage.
Wherein, start unit regularly is used for controlling each measuring point according to timing signal and starts simultaneously and be in accepting state.Described timing start unit comprises again being arranged on and is used in each measuring point regularly and exports the timer of timing signal and according to the microprocessor of timing signal executive control operation.
The downlink transfer passage, be used to carry out the downlink data transmission operation: the request msg of central station is sent to first measuring point, and the measuring point of confessing one's crime rises, and will be forwarded to adjacent descending measuring point from the request msg of central station, by that analogy, until being sent to the tail measuring point from the request msg of central station.
The uplink passage, be used to carry out the transmitting uplink data operation: from the tail measuring point, each measuring point will be sent to adjacent up measuring point from the response data of descending measuring point and this measuring point response data, by that analogy, until first measuring point the response data of all measuring points will be sent to central station.
Seeing also Fig. 3, is the theory diagram of the unified preferred embodiment of data transmission system of the present invention.Comprise central station 310 an and N measuring point in the data transmission system of the present invention, can realize point-to-point transfer of data.
Wherein, central station 310 is used for sending request msg to measuring point, and receives response data from measuring point.
Measuring point 1 is used for concentricity station or carries out transfer of data with measuring point 2; To be sent to measuring point 2 from the request msg of central station, perhaps be sent to central station with measuring point 1 with from measuring point 2 to the response data of measuring point N.
Remaining N-1 measuring point is used to realize the transfer of data between the measuring point in twos.Concrete transmission course is: measuring point 2 will be sent to measuring point 3 (figure does not show) through the request msg of the next central station of measuring point 1 transmission, measuring point 3 is sent to measuring point 4 (figure does not show) with the request msg of central station, by that analogy, until measuring point N-1 the request msg of central station is sent to measuring point N; Measuring point N is sent to measuring point N-1 with response data, and measuring point N-1 is sent to measuring point N-2 with the response data of measuring point N-1 and measuring point N, by that analogy, until measuring point 3 measuring point 3 to the request of data of measuring point N is sent to measuring point 2.
Each measuring point all comprises timer 322 and microprocessor 321 in this system.
Wherein, timer 322 is used for regularly, and the output timing signal.
Microprocessor 321 is used to control the transfer of data and the processing of measuring point, and starts measuring point according to the timing signal of timer 322 output and enter accepting state, perhaps enters closed condition.
Seeing also Fig. 4, is the theory diagram of each measuring point in the data transmission system of the present invention.In actual applications, each measuring point comprises timer 322, microprocessor 321, power subsystem 523, transceiver 524, antenna 525 and clock alignment module 526.
Wherein, timer 322 is used for regularly, and the output timing signal.
Microprocessor 321 is used to control the transfer of data and the processing of measuring point, and starts measuring point work (entering accepting state) according to the timing signal of timer 322 outputs, and (entering closed condition) perhaps quits work.
Power subsystem 523 is used for regularly providing operating voltage for measuring point under timer 322 and microprocessor 321 controls.
Clock alignment module 526, the clock signal that is used to calibrate measuring point.
Transceiver 524 is used under the control of microprocessor 321, receives and send data.
Antenna 525 is used for the data from transceiver 524 are sent, and receives the data from central station.Measuring point antenna 525 can adopt omnidirectional antenna, and the central station that carries out transfer of data with measuring point also adopts omnidirectional antenna.
It is pointed out that the central station that carries out transfer of data with measuring point can comprise reference clock unit (figure does not show), is used to whole system that reference clock is provided.
Following mask body is set forth in the system and method provided by the invention, the process of Point-to-Point Data Transmission.So-called transfer of data can be central station and measuring point 1, the transfer of data between the perhaps adjacent in twos measuring point.Wherein, the measuring point or the central station of initiating transfer of data are called main frame, and the measuring point or the central station that receive the transmission data are called slave.Just, in downlink transmission process, be main frame near the measuring point of central station, be slave away from the measuring point of central master station, data pass to the slave end away from central station from the host side near central station; And in the uplink process, be main frame away from the measuring point of central station, be slave near the measuring point of central station, data pass to the slave near central station from the main frame away from central station.
Seeing also Fig. 5, is the process schematic diagram of data normal transmission among the present invention.
Data transmission procedure begins, and main frame sends request signal to slave;
Slave sends correctly and replys (ACK) signal after receiving request signal from main frame;
Main frame receive from slave correctly reply (ACK) after, send data to slave;
After slave is successfully received data, correctly reply (ACK) signal to the main frame transmission;
Main frame is successfully received from correctly the replying of slave (ACK), is finished this data transmission procedure.
See also Fig. 6, data transmission procedure schematic diagram during the slave no response among the present invention.Before data transmission procedure, need to be provided with main frame sends number of times thresholding from request signal to slave.
Data transmission procedure begins, and main frame sends request signal to slave, and waits for the answer signal from slave;
Stand-by period is overtime, and main frame sends request signal to slave once more, and waits for the answer signal from slave;
Stand-by period is overtime, and main frame sends request signal to slave again, and the wait slave is received and dispatched out answer signal;
The number of times that sends request signal until main frame surpasses threshold value, this data transmission procedure failure.
For example, main frame is made as 5 times to the number of times threshold value that slave sends request signal.Main frame sends request signal to slave, and waits for the answer signal from slave; Wait timeout resends request signal; Send request signal until main frame the 5th to slave, and wait for again from the answer signal of slave overtime after, this data transmission fails also finishes.
Seeing also Fig. 7, is transmission course schematic diagram when transmitting corrupted data among the present invention.
Data transmission procedure begins, and main frame sends request signal to slave;
Slave is received behind the request signal to send correctly to main frame and is replied (ACK) signal;
Main frame receive from slave correctly reply (ACK) signal after, send data to slave;
Data are damaged in transmission course, and slave sends wrong responses (NACK) signal;
Main frame resends data to slave after receiving wrong responses (NACK) signal from slave;
After slave is received correct data, correctly reply (ACK) signal to the main frame transmission;
Main frame is successfully received from what slave sent and is correctly replied (ACK) signal, this time DTD.
Be understandable that the number of times that main frame allows to resend data to slave also can be set, and not only is confined to resend once in the present embodiment.And, surpass to allow number of times after, when main frame receives that signal from slave is still for the no response signal, then judge this data transmission fails, and the end data transmission.
Seeing also Fig. 8, is transmission course schematic diagram during loss of transmitted data among the present invention.
Data transmission procedure begins, and main frame sends request signal to slave;
Slave is received from sending correctly to main frame behind the request signal of main frame and is replied (ACK) signal;
Main frame receive from slave correctly reply (ACK) signal after, send data 1 to slave, and wait for that slave sends response signal;
Data 1 are lost in the transmission course, the slave no response;
The host waits answer signal is overtime, resends data 1 to slave;
After slave is received data 1 from main frame, send to main frame and correctly to reply (ACK) 1 signal;
Main frame is successfully received from slave and is correctly replied (ACK) 1 signal, this ED.
In the present embodiment, be that example is told about data transmission procedure with the odd-numbered frame, wherein data 1, correctly reply (ACK) 1 and be odd-numbered frame.
Be understandable that the number of times that main frame allows to resend data to slave also can be set, and not only is confined to resend once in the present embodiment.And after allowing number of times, main frame receives that slave sends signal still for behind the no response signal, then judges this data transmission fails.
Seeing also Fig. 9, is the data transmission procedure schematic diagram of replying among the present invention when losing.
Data transmission procedure begins, and main frame sends request signal to slave;
Slave is received behind the request signal to send correctly to main frame and is replied (ACK) signal;
Main frame receive from slave correctly reply (ACK) signal, send data 1 to slave, and wait for that slave sends response signal;
After slave is received data, correctly reply (ACK) 1 signal to the main frame transmission;
(ACK) 1 signal of correctly replying that slave sends is lost in transmission course, and the host waits answer signal is overtime;
Main frame resends data 1 to slave, and the wait slave is sent answer signal;
Slave resends correctly and replys (ACK) 1 signal after receiving data from main frame;
Main frame is successfully received and is correctly replied (ACK) 1 signal, this DTD from slave.
In the present embodiment, be that example is told about data transmission procedure with the odd-numbered frame, wherein data 1, correctly reply (ACK) 1 and be odd-numbered frame.
Be understandable that the number of times that main frame allows to resend data to slave also can be set, and not only is confined to resend once in the present embodiment.And after allowing number of times, main frame is not still received the answer signal that slave sends, and then judges this data transmission fails.
It is pointed out that in transmitting uplink data and the downlink data transmission process that the operation that main frame and slave are taked is different when data transmission fails.
When bust this appears in the downlink data transmission process:
Main frame is used as the finish node upstream nodes transmission data of network to this machine, and fills descending error flag on from the data bit of downstream node.
Slave is regarded as the reference clock of downstream node to the clock of this machine, and transmits descending erroneous frame to downstream node.
Wherein, the concrete form of descending erroneous frame is referring to table two.
Table two, descending wrong frame format
Synchronous 1 | Synchronous 2 | Destination address | Control section begins | Error flag | The mistake node number | The clock byte | Control section finishes | CRC check |
When bust this appears in the transmitting uplink data process:
Slave is used as the finish node upstream nodes transmission data of network to this machine, and fills up error flag on the data bit of downstream node.The operation of main frame when this operation is same as the downlink data transmission process and bust this occurs.
Main frame then keeps the error of transmission sign, the misregistration time.
Wherein, described node refers to measuring point and the central station in the data transmission system of the present invention.
The above only is a preferred implementation of the present invention; should be pointed out that for those skilled in the art, under the prerequisite that does not break away from the principle of the invention; can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.