Background technology
Technology of serial communication is simple because of its equipment, the convenience of realization, and obtained using very widely at industrial circle.A branched optical cable communication in its field is also because its strong interference immunity, and long transmission distance and being specially adapted to has the place of strong electromagnetic and uses.But there are two problems in existing technology of serial communication: first problem is, transceiver is because use different clock crystal oscillators, the problem of the transmitting-receiving bit phase shift that causes owing to the existence of crystal oscillator circular error; Suppose that transmitting apparatus A is slower than the clock crystal oscillator of receiving equipment B, and transmitting apparatus A, receiving equipment B send out, receive with identical baud rate; Then As time goes on, the transmission point of transmitting apparatus A moves after can be slowly with respect to the acceptance point of receiving equipment B.After the sufficiently long time of process, the transmission point of transmitting apparatus A can overlap with the acceptance point of receiving equipment B, the next bit that transmitting apparatus A sends, the acceptance point of twice experience of meeting receiving equipment B.In like manner, when transmitting apparatus A is faster than receiving equipment B crystal oscillator, can cause bit that transmitting apparatus A sends on receiving equipment B, not have an acceptance point at certain time point.Consider the foundation of accepting data and the requirement of retention time, this tends to cause mistake to receive.If exactly this problem occurs in the transmission data, then this time transmission will produce wrong result.Second problem is, for some communication media (such as optical fiber), because the problem of the duty ratio of the high-low level that the characteristic of medium itself causes distortion, referring to Fig. 1, such as, for 1521/2521, if use its preferred circuit to send 0101 with the interval of 200ns, then the low level time of receiving terminal accounts for 230ns, and high level time only accounts for 170ns.Suppose that the duty ratio distortion is 30ns, transmitting apparatus A sends 0101 ... if receiving equipment B begins within the 30ns to receive after the transmission point of transmitting apparatus A, then in receiving circuit was the low level cycle, receiving equipment B can experience two acceptance points; And in receiving circuit is the cycle of high level, acceptance point also wait less than.Thereby what cause that in fact receiving circuit receive is 0000 ... (as Fig. 2).Problem for this duty ratio distortion is relevant with the characteristic of transmission circuit parameter and transmission medium, and different circuit parameters is produced different distortion effects.The value that acceptance point 1,2,3 receives among Fig. 2 is always 0.
In the serial communication, having no idea to evade for first problem at present, can only be by the verification to received content wrong content to be weeded out; If but so exactly transmit significant data in the moment that makes mistake, then reliability, the efficient of whole communication are brought very big influence.
For second problem, then often need to increase the result that some analog circuits are revised transmission, receiving terminal, the duty ratio that guarantees receiving terminal is near 1.But because there is error in the parameter of analog circuit, and the characteristic of duty ratio and transmission medium (such as the length of optical fiber, technology etc.) is relevant, thereby the revision precision is not high; Guarantee certain transmission precision toward contact the mode of need assisting to reduce transmission speed.
Summary of the invention
The objective of the invention is always to have the characteristics of certain intervals at the transmission of serial communication, provide a kind of can the self adaptation transmitting-receiving two-end the clock phase shift and the duty ratio distortion that can tolerate serial communication, be applicable to the serial transmission processing method of programmable logic device.
Technical scheme of the present invention is: a kind of serial transmission processing method that is adapted to the high reliability of programmable hardware is provided, and it comprises receiving port, receives control module, controlled receiver module, and the step of its method for transmission processing is as follows:
1. receive control module at each receiving cycle interscan receiving port pre-determined number n (n 〉=4), define the scan period that is spaced apart of each scanning;
2. after finishing, each scanning judges whether the value of current receiving port variation has taken place:
If a) variation has taken place in the value of receiving port, then receive control module postpone set point number m (scan period of m<n/2), trigger controlled receiver module and receive information;
If a) receiving port receives to move apart from the last time and continued a pre-determined number n scan period and not variation, then trigger controlled receiver module and begin to receive;
3. whenever having received the triggering signal that receives control module, receiver module is collected the information of a bit from receiving port.
The present invention also provides a kind of device of realizing said method, comprises receiving port, receives control module, controlled receiver module; Wherein receiving port is the inlet of communication signal, and it is directly connected to peripheral communication receiving circuit; Receive the signal (at a receiving cycle interscan pre-determined number n) that control module regularly repeatedly scans receiving port, the triggering signal that receives according to the change dynamics adjustment of optical fiber receiving port signal; Controlled receiver module carries out concrete reception action by the triggering signal control that receives control module.
The present invention has following technique effect:
1. dynamically adjust the acceptance point of receiving terminal, solved the problem of the receipts of misconnection once in a while that cause because of the inconsistent problem of receiving and sending equipment crystal oscillator in the serial communication.
2. use the method that just receives after a period of stabilisation at receiving port, solved because the problem of the receiving terminal wave distortion that transmission medium and transmission circuit cause for the influence of communication reliability.
3. reduced requirement, improved reliability simultaneously for circuit.For the situation of frequent transmitting-receiving, in theory can be so that miscommunication is reduced to 0.
4. realize simply being applicable to programmable hardware circuit such as FPGA/CPLD, under the situation that does not increase hardware cost, realize the high reliability serial communication of fair speed.
5. this method and apparatus is specially adapted to the frequent occasion use that sends.
Embodiment
See also Fig. 3, Fig. 3 is an apparatus structure schematic diagram of the present invention.A kind of communicator comprises receiving port, receives control module, controlled receiver module; Wherein receiving port is the inlet of communication signal, and it is directly connected to peripheral communication receiving circuit; Receive the signal that control module regularly repeatedly scans receiving port, as at a receiving cycle interscan pre-determined number n, the triggering signal that receives according to the change dynamics adjustment of optical fiber receiving port signal; Controlled receiver module carries out concrete reception action by the triggering signal control that receives control module.
See also Fig. 4, Fig. 4 is the schematic flow sheet of processing method of the present invention.It is a kind of serial transmission processing method that is adapted to the high reliability of programmable hardware, and it comprises receiving port, receives control module, controlled receiver module (referring to Fig. 3), and the step of its method for transmission processing is as follows:
1, receives control module at each receiving cycle interscan receiving port pre-determined number n (n 〉=4), define the scan period that is spaced apart of each scanning;
2, judge whether the value of current receiving port variation has taken place after each scanning is finished:
If a) variation has taken place in the value of receiving port, then receive control module postpone set point number m (scan period of m<n/2), trigger controlled receiver module and receive information;
B) action has continued a pre-determined number n scan period and not variation if receiving port received apart from the last time, then triggers controlled receiver module and begins to receive;
3, whenever having received the triggering signal that receives control module, receiver module is collected the information of a bit from receiving port.
Be meant m the cycle or the constant duration of receiving port after the value that satisfies receiving port changes of the Rule of judgment that should receive among Fig. 4 reach under the condition of scan period pre-determined number n outside, then receive control module triggering reception and operate.
Illustrate below in conjunction with example and to adopt device of the present invention and method of the present invention are how to solve two problems in the background technology particularly.For first problem, i.e. different the and clock phase shift problem that causes of Transmitting and Receiving End crystal oscillator: establish,
1. each communication frames of serial communication all has start bit and stop bits, the value of start bit different with the value of stop bits (in general, the value of start bit is 1, and the value of stop bits is 0).
2. every frame of hypothesis serial communication length of not including start bit and stop bits accounts for a bit, the time interval maximum between per two frames is b bit, then maximum duration of not changing of receiving port is the maximum of a+1 bit and b+1 bit in theory, is made as c bit.
3. therefore, receive maximum lasting c of control module and send all after dates, adjust once.
4. for the crystal oscillator of receiving and dispatching, (n sends the scanning times in cycle for each as long as guarantee the deviation in the every c of a crystal oscillator transmission cycle of sending and receiving end to be not more than m/n in theory, m is for find to change to the interval of the scan period that receives next time) the individual transmission cycle, can guarantee that then the deviation of the crystal oscillator of sending and receiving end can not cause misconnection to receive.
For second problem, the i.e. problem of the distortion of the waveform duty cycle that causes because of media problem: suppose set point number m=1, predetermined scanning times n=4, the transmission cycle with 200ns sends 010101 ... the duration of receiving terminal 1 is 230ns, and 0 duration is 170ns, then:
1. if scanning time, receiving port exactly becomes 1 from 0, suppose that time point at this moment is 0.
A) then 50ns begins to receive constantly, and the value that receive this moment is 1.
B) 50ns backward constantly, every the 50ns run-down, scan 3 times after (moment is 200ns at this moment), become 0 at the moment of 230ns receiving terminal
C) in the moment of 250ns, receive the 4th scanning in back, find that variation has taken place receiving port, thereby receive that the value of receiving is 0 since 300ns.
D) backward at 300ns, every the 50ns run-down, then scan twice after, get back to the situation of a step.Thereby and the like, the result of reception is 10101
2. if scanning time, receiving port exactly becomes 0 from 1, and then the time point of hypothesis this moment is 0.
A) begin constantly to receive at 50ns, the value that receive this moment is 0.
B) 50ns has scanned (moment of this moment is 150ns) after 2 times constantly backward every the 50ns run-down, becomes 1 at the moment of 170ns receiving terminal.
C) constantly, the scanning for the third time after receiving finds that variation has taken place receiving port, thereby begins constantly to receive at 250ns, and the value of receiving is 1 at 200ns.
D) backward, change up to 400ns receiving terminal eloquence, be 3 scan periods this moment at interval, returns the situation of a step from 250ns, thus circulation successively, and the result of reception is 010101
3., suppose that time point at this moment is 0 if after scanning had just been finished, receiving port became 1 from 0:
A) begin scanning in the moment of 50ns, find that receiving port changes, then receive operation in the moment of 100ns, reception result is 1.
B) behind 100ns every the 50ns run-down, scanned 2 times after (this moment constantly be 200ns), 230ns constantly port become 0
C) remaining disposition is similar with 1.c.Thereby reception result remains 101010.
If just scan finish after, receiving port becomes 0 from 1, supposes that the time point of this moment is 0
A) begin scanning in the moment of 50ns, find that receiving port changes, then receive operation in the moment of 100ns, reception result is 0.
B) behind 100ns every the 50ns run-down, scanned 1 time after (this moment constantly be 150ns), 170ns constantly port become 1.
C) remaining disposition, similar with 2.c, thus the result who receives is 010101
According to the analysis thinking of front, be not difficult to analyze, in theory at set point number m=1, under the situation of predetermined scanning times n=4, can accept the situation that the duty ratio distortion reached for 1/4 transmitting-receiving cycle.Consider the variation of circuit parameter in the practical application, the interference of the foundation of circuit and the situations such as restriction of retention time, the circuit that the duty ratio distortion reaches about 20% can correctly receive fully.
Above-mentioned example is at setting set point number m=1, the analysis under the situation of predetermined scanning times n=4, and obviously, at set point number m, when predetermined scanning times n was other parameter, the present invention can realize that also at this moment the concrete analysis process is not given unnecessary details.