Summary of the invention
Purpose of the present invention provides a kind of multi-label collision referee method that is used for the adaptive binary tree of rfid system just for the shortcoming that overcomes above-mentioned prior art, whether no matter it all have the less arbitration time under the vicissitudinous situation at label, and need not to predict the varied number of label, the unlimited phenomenon that prolongs of label skip or time for reading can not take place, and has obtained adaptive performance preferably.
The objective of the invention is to be achieved through the following technical solutions.
The multi-label collision referee method that is used for the adaptive binary tree of rfid system, the rfid system of this method is made of a read write line and two labels in its coverage at least, read write line is given an order earlier, and label is carried out corresponding operation after receiving order, and concrete grammar is:
1. the shared time rule of process that a read write line and at least two labels in its coverage are carried out a full communication is a read cycle, and a read cycle is made of following four-stage:
A, initial: read write line activates the label in its coverage and sends querying command;
B, transmission ID: label sends its ID to read write line, then carries out the conflict arbitration method if plural label is arranged or do not have label to send ID, otherwise enters data exchange phase;
C, exchanges data: only have a label to send ID to read write line this moment, and read write line returns to successfully order of label, carries out exchanges data with read write line after label receives orders;
D, end: the data of read write line and all labels have all exchanged and have finished;
2. a read write line and at least two labels in its coverage are carried out a shared time of full communication and are divided into several slots, send the state of data, time slot is divided into following three types according to each time slot interior label:
A, empty slot: in this time slot, do not have label ID to send;
B, readable time slot: in this time slot, have and only have a label ID to send;
C, conflict time slot: in this time slot, have the label ID more than two to send;
3. the state of communicating by letter with read write line according to label, each label has following four kinds of states:
A, close closed state: read write line un-activation label or carry out exchanges data with read write line at a read cycle interior label;
B, ready attitude: read write line activates label;
C, ID attitude: label sends its ID to read write line;
D, exchanges data attitude: label and read write line carry out exchanges data;
4. each label all has a counter and a random number transmitter, realizes that with them the method for binary tree is to avoid the conflict between label; Whether counter equals 0 has determined that whether label sends ID to read write line, represents with COUNT; The random number transmitter only produces 0 or 1 random number, represents with RND;
5. all store a priority number in the storer of each label, this priority number has determined when label communicates by letter with read write line in the crack, represents with PN, and the initial p N when dispatching from the factory is random integers; PN all can do the self-adaptation adjustment to reduce conflict and empty slot according to the current time slots state in each read cycle, adjusted PN can be deposited in the storer of label before each read cycle finishes again;
6. carry out the multi-label collision arbitration according to the following steps:
A, when initial, read write line is opened the label in its coverage of radio-frequency electromagnetic field activation;
The initial p N that b, the label that is activated will be stored in storer sends among the COUNT, and label enters ready attitude by closing closed state;
C, when each time slot begins, judge whether the label of ready attitude, if the label of ready attitude is arranged, judge COUNT again, the ready attitude label of COUNT=0 becomes the ID attitude, the ready attitude label of COUNT>0 still is ready attitude; If the label of no ready attitude, then a read cycle finishes;
D, consider from following two aspects according to the situation of ID attitude label: when the label of no ID attitude, current time slots is an empty slot, and at this moment, oneself subtracts 1 the COUNT of all ready attitude labels and PN, and system enters next time slot; When the label of ID attitude, two or more ID attitude labels need have been judged whether, when if two above ID attitude labels are arranged, then showing has plural label to send its ID to read write line, read write line is given all label one orders, to show that current time slots is the conflict time slot, at this moment, for the COUNT of all ready attitude labels and PN from adding 1, for all ID attitude labels, its RND produces random number 0 or 1, random number is 1 ID attitude label, and COUNT and PN are from adding 1, and random number is 0 ID attitude label, COUNT and PN are constant, and system enters next time slot; If have only an ID attitude label, then have only a label to send its ID to read write line, read write line gives all label one orders to show that current time slots is readable time slot, at this moment, from subtracting 1, transfer the exchanges data attitude to for the COUNT of all ready attitude labels for ID attitude label, after exchanges data finishes, this label deposits the PN that upgrades in storer, transfers the pass closed state then to, and system enters next time slot.
The present invention has the following advantages at least:
1. stamping-out time of conflicting is less than BTree and RS method
What the present invention was different with BTree is to have introduced PN, it has been remembered each label and when has communicated by letter with read write line in a read cycle, and can make the self-adaptation adjustment according to the current time slots type, thus in the next read cycle, reduce conflict and empty slot, therefore also reduced the conflict arbitration time.And the initial value of PN is a random number, and it can also reduce the conflict number of times of label in the first read cycle.Therefore, BTree only is equivalent to that all label PN are 0 special case among the present invention, and RS is equivalent to the special case of the present invention in the first read cycle.
2. the conflict arbitration time is less than ABS
ABS has adopted " distribute number " to finish the function that is similar to PN, and be 0 initial " distribute number " of each label in ABS.When label changed, " distribute number " was 0 because initial, and therefore new label can increase initial collision, the label that leaves simultaneously stays more empty slot again, therefore work as label variations more for a long time, total timeslot number increases greatly, even has surpassed BTree and RS.And the initial collision of some labels has not only been avoided in initial p N Random assignment of the present invention, but also can fill up the empty slot that some stays because label leaves, so the conflict arbitration time is less than ABS.
3. can not produce the unlimited problem that prolongs of label skip and read cycle
ABS needs one " stop number " to finish a read cycle.If the skip phenomenon then takes place less than the number of tags that will discern in " stop number "; Then read cycle will be circulated always and can't be stopped if " stop number " is greater than number of tags; Have only " stop number " to equal number of tags, conflict arbitration could be finished smoothly.Therefore, ABS must know the number of tags that will discern in advance, and when the variation number of label was the unknown, ABS can't operate as normal.Decide communicating by letter of label and read write line and whether the ABTree agreement equals 0 according to COUNT, when the label of COUNT=0 and read write line swap data finish just to enter the pass closed state, if all entering, all labels close then just end of read cycle of closed state, therefore ABTree need not to know label variations quantity, also can not produce the unlimited problem that prolongs of label skip and read cycle.
Further set forth content of the present invention below in conjunction with Figure of description.
Embodiment
The rfid system of the inventive method is made of a read write line and two labels in its coverage at least, and read write line is given an order earlier, and label is carried out corresponding operation after receiving order, and concrete grammar is:
1. the shared time rule of process that a read write line and at least two labels in its coverage are carried out a full communication is a read cycle, and a read cycle is made of following four-stage:
A, initial: read write line activates the label in its coverage and sends querying command;
B, transmission ID: label sends its ID to read write line, then carries out the conflict arbitration method if plural label is arranged or do not have label to send ID, otherwise enters data exchange phase;
C, exchanges data: only have a label to send ID to read write line this moment, and read write line returns to successfully order of label, carries out exchanges data with read write line after label receives orders;
D, end: the data of read write line and all labels have all exchanged and have finished;
2. a read write line and at least two labels in its coverage are carried out a shared time of full communication and are divided into several slots, send the state of data, time slot is divided into following three types according to each time slot interior label:
A, empty slot: in this time slot, do not have label ID to send;
B, readable time slot: in this time slot, have and only have a label ID to send;
C, conflict time slot: in this time slot, have the label ID more than two to send;
3. the state of communicating by letter with read write line according to label, each label has following four kinds of states:
A, close closed state: read write line un-activation label or carry out exchanges data with read write line at a read cycle interior label;
B, ready attitude: read write line activates label;
C, ID attitude: label sends its ID to read write line;
D, exchanges data attitude: label and read write line carry out exchanges data;
4. each label all has a counter and a randomizer, realizes that with them the method for binary tree is to avoid the conflict between label; Whether equal 0 with counter and determined that whether label sends ID to read write line, represents with COUNT; The random number transmitter only produces 0 or 1 random number, represents with RND.Fig. 1 has provided the rule schema of tag state conversion.As shown in Figure 1, when initial, label is in the pass closed state, activated by read write line and enters ready attitude.The ready attitude label of COUNT ≠ 0 still is in ready attitude when next time slot begins; The ready attitude label of COUNT=0 then enters the ID attitude.Can consider in two kinds of situation for ID attitude label: if current time slots has two above labels to be in the ID attitude, all are in the label of ID attitude and still get back to ready attitude when next time slot begin; If current time slots only has an ID attitude label, this label enters the exchanges data attitude so, gets back to the pass closed state after the data exchanging completed.Be in ready and COUNT computing situation ID attitude label and can see Table 1.From table 1, can see, when the conflict time slot, ID attitude label will be carried out COUNT=COUNT+RND, this makes the conflict label be divided into ready attitude and ID attitude two class labels at random when next time slot begins, after carrying out so repeatedly, will in a time slot, only there be an ID attitude label, thereby avoids a conflict generation.
5. in the storer of each label, store a priority number, this priority number has determined when label with read write line communicates by letter in the crack, represent with PN, the initial p N that dispatches from the factory is random integers, and PN all can do the self-adaptation adjustment to reduce conflict and empty slot according to the current time slots state in each read cycle.The initial value of COUNT is sent into by PN, has determined label whether to send ID to read write line, so when label the crack is communicated by letter with read write line and will be determined by PN because whether COUNT equals 0.We can obtain like this, if plural label has identical PN, the conflict time slot are arranged then; If the difference of the PN of two labels that the PN value is adjacent then is free time slot greater than 1.The PN of each label can do the self-adaptation computing with minimizing conflict and empty slot according to its residing state and current time slots type, thereby reduces total conflict arbitration time.Be in ready and PN computing situation ID attitude label and can see Table 1.Can see by table 1, if current be empty slot, all from subtracting 1, this difference that has guaranteed two label PN that any PN value is adjacent all is not more than 1 to the PN of all ready attitude labels so; If current is the conflict time slot, the PN of all ID attitude labels will add 1 or 0 at random certainly so, and this makes that the last PN of all labels is all unequal.Therefore, through a read cycle, the PN of n label will be by 0,1 ... n-1 distributes successively, if next read cycle interior label does not change, will can not have conflict and empty slot so, and readable time slot is only arranged, and the required total time slot of conflict arbitration this moment only is n.
The PN of table 1 label and the operation table of COUNT
|
Readable time slot |
Empty slot |
The conflict time slot |
Ready attitude |
The constant COUNT--of PN |
PN--, COUNT-- |
PN++,COUNT++ |
The ID attitude |
PN, COUNT are all constant |
\ |
Work as RND=1, PN++, COUNT++; Work as RND=0, PN, COUNT is constant |
6. as shown in Figure 2, carry out the multi-label collision arbitration according to the following steps:
When (1) initial, read write line is opened the label in its coverage of radio-frequency electromagnetic field activation.(step 110)
(2) the initial p N that the label that is activated will be stored in storer sends among the COUNT, and label enters ready attitude.(step 120)
(3) if there is the label of ready attitude, forward step 140 to; If the label of no ready attitude forwards step 250 to.(step 130)
(4) for the label of all ready attitudes,,, still be ready attitude as if COUNT>0 if COUNT=0 then becomes the ID attitude.(step 140)
(5) if the label of ID attitude is arranged, forward step 160 to; Otherwise, forward step 200 to.(step 150)
(6) if two above ID attitude labels are arranged, forward step 220 to; Otherwise, forward step 170 to.(step 160)
(7) have only a label to send its ID to read write line, read write line gives all label one orders to show that current time slots is readable time slot.(step 170)
(8) for ID attitude label, read write line returns to an order after successfully receiving its ID again, and this label transfers the exchanges data attitude to, and after exchanges data finished, this label deposited the PN that upgrades in storage unit, becomes the pass closed state.(step 180)
(9) if there is ready attitude, its COUNT goes back to step 130 from subtracting 1; Otherwise, directly go back to step 130.(step 190~195)
(10) no label sends ID to read write line, and read write line gives all label one orders to show that current time slots is an empty slot.(step 200)
(11) for all ready attitude labels, its COUNT and PN go back to step 130 from subtracting 1.(step 210)
(12) have the label more than two to send its ID to read write line, read write line gives all label one orders to show that current time slots is the conflict time slot.(step 220)
(13) for all ready attitude labels, its COUNT and PN are from adding 1.(step 230)
(14) for all ID attitude labels, its RND produces random number 0,1: be 1 label, COUNT and PN are from adding 1; Be 0 label, COUNT and PN are constant.Go back to step 130.(step 240)
(15) read cycles finish.(step 250)
Fig. 3~Fig. 6 has represented the situation of read write line identification label in continuous four read cycles.Wherein, Fig. 3 has represented that A, B were arranged in first cycle, three labels of C, and the initial p N of A, B, C all is made as 1; Fig. 4 has represented second period interior label no change; Fig. 5 has represented to have in the 3rd cycle label D to arrive, and the initial p N of D is 1; Fig. 6 has represented that the 4th cycle interior label C, D leave away, and label E arrives, and the initial p N of E is made as 2.Table 2 represented each label in each time slot in each cycle COUNT and the situation of change of PN.
Table 2
The present invention is described in detail below in detail in the performance in this four cycles:
As shown in Figure 3, label A, B, C are arranged in first cycle:
When (1) initial, label A, B, C are activated and enter ready attitude, and its initial p N is 1, sends among the COUNT, and therefore COUNT and the PN of A, B, C is 1 in first time slot.Owing to there is not the label of COUNT=0, therefore not have label and send ID, be empty slot this moment, the COUNT of label A, B, C and PN are all from subtracting 1.
In (2) second time slots, COUNT and the PN of A, B, C become 0.Because the label of COUNT=0 has A, B, C, so current time slots is the conflict time slot.The RND of B produces random number 1, and the RND of A, C produces random number 0.
(3) because the RND of B has produced random number 1, so its COUNT and PN are 1 in the 3rd time slot; In like manner, the RND of A, C has produced random number 0, and its COUNT and PN should be 0 in the 3rd time slot.This moment, the label of COUNT=0 had A, C, had produced two ID attitude labels, so current time slots is the conflict time slot.So the COUNT of B and PN are from adding 1, the RND of A produces random number 1, and the RND of C produces random number 1.
In (4) the 4th time slots, COUNT and the PN of B become 2, and COUNT and the PN of A, C become 1.Do not have the label of COUNT=0 this moment, and current time slots is an empty slot.The COUNT of A, B, C and PN are all from subtracting 1.
In (5) the 5th time slots, COUNT and the PN of B become 1, and COUNT and the PN of A, C become 0.This moment, the label of COUNT=0 had A, C, and current time slots is the conflict time slot, and the COUNT of B and PN are from adding 1, and the RND of A produces random number 0, and the RND of C produces random number 1.
In (6) the 6th time slots, COUNT and the PN of B become 2, and COUNT and the PN of A become 0, and COUNT and the PN of C become 1.This moment, the label of COUNT=0 only had A, and current time slots is readable time slot.The ID of label A is identified by read write line, carry out exchanges data after, deposit its PN=0 in storage unit, and become the pass closed state.In addition, the COUNT of B, C is all from subtracting 1.
In (7) the 7th time slots, the COUNT of B and PN become 1 and 2 respectively, and the COUNT of C and PN become 0 and 1.This moment, the label of COUNT=0 only had C, and current time slots is readable time slot.Label C is identified by read write line, after exchanges data finishes, deposits its PN=1 in storage unit, and becomes the pass closed state.In addition, the COUNT of B is from subtracting 1.
In (8) the 8th time slots, the COUNT of B and PN become 0 and 2 respectively.This moment, the label of COUNT=0 only had B, and current time slots is readable time slot.Label B is identified by read write line, after exchanges data finishes, deposits its PN=2 in storage unit, and becomes the pass closed state.So far, all labels all become the pass closed state, and first read cycle finishes.
As shown in Figure 4, second period interior label no change still has label A, B, C:
When (1) initial, label A, B, C are activated and enter ready state.Its initial p N is respectively 0,2,1 by the decision of read cycle last time, sends among the COUNT, and therefore the COUNT of A, B, C also is respectively 0,2,1 in first time slot.Because the label of COUNT=0 only has A, so current time slots is readable time slot.Label A is identified by read write line, after exchanges data finishes, deposits its PN=0 in storage unit, and becomes the pass closed state.In addition, the COUNT of B, C is from subtracting 1, and the PN of B, C is constant.
In (2) second time slots, the COUNT of B, C becomes 1,0, and the PN of B, C still is 2,1.Because the label of COUNT=0 only has C, so current time slots is readable time slot.Label C is identified by read write line, after exchanges data finishes, deposits its PN=1 in storage unit, and becomes the pass closed state.In addition, the COUNT of B is from subtracting 1, and the PN of B is constant.
In (3) the 3rd time slots, the COUNT of B becomes 1,0, and the PN of B still is 2.Because the label of COUNT=0 only has B, so current time slots is readable time slot.Label B is identified by read write line, after exchanges data finishes, deposits its PN=2 in storage unit, and becomes the pass closed state.Arrive this, all labels all become the pass closed state, and second read cycle finishes.
As shown in Figure 5, the 3rd cycle interior label D arrives:
When (1) initial, label A, B, C, D are activated and enter ready state.The initial p N of A, B, C is respectively 0,2,1 by the decision of read cycle last time, sends among the COUNT, and therefore the COUNT of A, B, C also is respectively 0,2,1 in first time slot.D initial p N is 1, sends into COUNT, and therefore the COUNT of D also is 1 in first time slot.Because the label of COUNT=0 only has A, so current time slots is readable time slot.Label A is identified by read write line, after exchanges data finishes, deposits its PN=0 in storage unit, and becomes the pass closed state.In addition, the COUNT of B, C, D is from subtracting 1, and the PN of B, C, D is constant.
In (2) second time slots, the COUNT of B, C, D becomes 1,0,0, and the PN of B, C, D still is 2,1,1.This moment, the label of COUNT=0 had C, D, and current time slots is the conflict time slot, and the COUNT of B and PN are from adding 1, and the RND of D produces random number 0, and the RND of C produces random number 1.
In (3) the 3rd time slots, the COUNT of B, C, D becomes 2,1,0, and the PN of B, C, D is 3,2,1.Because the label of COUNT=0 only has D, so current time slots is readable time slot.Label D is identified by read write line, after exchanges data finishes, deposits its PN=1 in storage unit, and becomes the pass closed state.In addition, the COUNT of B, C is from subtracting 1, and the PN of B, C is constant.
In (4) the 4th time slots, the COUNT of B, C becomes 1,0, and the PN of B, C still is 3,2.Because the label of COUNT=0 only has C, so current time slots is readable time slot.Label C is identified by read write line, after exchanges data finishes, deposits its PN=2 in storage unit, and becomes the pass closed state.In addition, the COUNT of B is from subtracting 1, and the PN of B is constant.
In (5) the 5th time slots, the COUNT of B becomes 0, and PN still is 3.Because the label of COUNT=0 only has B, so current time slots is readable time slot.Label B is identified by read write line, after exchanges data finishes, deposits its PN=3 in storage unit, and becomes the pass closed state.Arrive this, all labels all become the pass closed state, and the 3rd read cycle finishes.
As shown in Figure 6, the 4th cycle interior label C, D leave away, and E arrives:
When (1) initial, label A, B, E are activated and enter ready state.The initial p N of A, B is respectively 0,3 by the decision of read cycle last time, sends among the COUNT, and therefore the COUNT of A, B also is respectively 0,3 in first time slot.E initial p N is 2, sends into COUNT, and therefore the COUNT of E also is 2 in first time slot.Because the label of COUNT=0 only has A, so current time slots is readable time slot.Label A is identified by read write line, after exchanges data finishes, deposits its PN=0 in storage unit, and becomes the pass closed state.In addition, the COUNT of B, E is from subtracting 1, and the PN of B, E is constant.
In (2) second time slots, the COUNT of B, E becomes 2,1, and the PN of B, E still is 3,2.Not having the label of COUNT=0 this moment, is empty slot therefore, and the COUNT of label B, E and PN are all from subtracting 1.
In (3) the 3rd time slots, the COUNT of B, E becomes 1,0, and the PN of B, E is 2,1.Because the label of COUNT=0 only has E, so current time slots is readable time slot.Label E is identified by read write line, after exchanges data finishes, deposits its PN=1 in storage unit, and becomes the pass closed state.In addition, the COUNT of B is from subtracting 1, and the PN of B is constant.
In (4) the 4th time slots, the COUNT of B becomes 0, and the PN of B still is 2.Because the label of COUNT=0 only has B, so current time slots is readable time slot.Label B is identified by read write line, after exchanges data finishes, deposits its PN=2 in storage unit, and becomes the pass closed state.Arrive this, all labels all become the pass closed state, and the 4th read cycle finishes.