I don't see this working with 110000 and 001111. Both are valid edges but BitFlag is set to opposing values. It's easy enough to fix but ...
It does work, there are an even number of bits outside the window and the value of the bits inside the window is < $F
I have annotated the code further with my rationale on how I arrive at the result
mov Bitflag, #1 'set error mov t1, manniesbits 'get sample
'this tests for bits outside the sync window. In a proper sample with a transition inside
'the sync window, you will have 2 high bits outside the window
'test for bits outside and parity of them
test t1, #%1100_0011 wz,wc
'if z = 0 then we matched our mask, if c = 0 then we had even number of bits
'now check a mask inside the sync window and report whether we matched something
if_nz_and_nc and t1, #%0011_1100 wz
'if z = 0 we matched something in the sync window
'now test to see if what we matched was all high bits (invalid)
'or had at least 1 low bit in the window
if_nz cmp t1, #$F wc
'if the the value matched in the mask is less than $F, we have an edge
'when c = 1 the masked value is less than the mask, so we have some low bits in the
'the sync window, now clear the error flag
if_c mov BitFlag, #0
'if z = 0 we matched something in the sync window
'now test to see if what we matched was all high bits (invalid)
'or had at least 1 low bit [COLOR="red"]in the window[/COLOR]
if_nz cmp t1, #$F [COLOR="red"]<< 2[/COLOR] wc
Silly me, I would have used 11_1100 in real code, but in the pseudo forum coding I bugged it up!
I hate writing code in forums because it's not representative of the write, compile, run cycle. If it was a simpler issue I'd have coded it up and posted my actual resulting code.
Hey Everyone, thanks for your help! I was able to work on it a little this evening and finish it up with 8 instructions to spare...
This code is for an RFID reader using only 6 passive components ... (5 capacitors and 1 resistor) ... With this particular design I'm getting about 3+ inches of detection.
Here is a description of the operation: (Keep in mind, everything for the RFID driver/detector is running under on COG)
The RFID reader uses an 8-Bit Software implemented ADC to capture a sample at every 125kHz pulse. This serves a double purpose...
1) sampling only when the 125kHz signal is HIGH results in a 'software rectifier' to demodulate the AM nature of the RFID signal.
2) sampling at 125kHz also has a way of creating a natural signal rejection to the 125kHz so this eliminates any hardware approach to filtering that can end up attenuating the signal. This basically allows you to detect the tag from a further distance.
The next software filtering stage implements a method to Increase the signal to noise ratio using an "ensemble averaging" method with 8 125kHz samples. Ensemble averaging is basically over sampling. If you taking the square root of the number of times you over sample, in this case 8, it will give you the signal to noise gain. With 8x it's about 2.83
Following that, the next software filter is a simple Automatic gain control where the mean average is used to create a virtual signal threshold... This stage acts like a comparator to establish the HIGH and LOW signal transitions present in the RFID signal.
The bit rate of the 125kHz RFID is 512us which equates to 64 125kHz pulses per bit. The ensemble averaging divides 64 by 8, leaving us with 8 samples per each RFID bit or 8 phases of each RFID bit that we can use to help decode the TAG signal.
The RFID data is Manchester encoded and follows the EM4100 64-Bit Protocol. The Resulting output are two LONG (32-bit wide) variables containing the decoded data.
Relatively simple bit parsing can decode the two longs into a "Human readable" number.
Note: The "Double D" configuration stems from my previous knowledge of metal detectors... And yes, this RFID reader can also double up as a metal detector. The idea of using two coils has a few beneficial filtering/amplification characteristics that are favorable for this design. Basically the double coil works like this ... You have a drive coil and a sense coil. The drive coil possesses the most magnetic flux in the center of the coil, while outside of the coil you have a weaker less concentrated flux of opposite polarity. The sense coil should be positioned so that it's sitting at an equilibrium point of the drive coil where the magnetic flux cancels out. In this configuration your sense coil is the most sensitive... very small disturbances in the magnetic flux from the RFID tag (as it modulates) create a large imbalance that can easily be detected in the sense coil.
1) sampling only when the 125kHz signal is HIGH results in a 'software rectifier' to demodulate the AM nature of the RFID signal.
I wonder if you could increase range or S/N further by sampling both HIGH and LOW and subtracting the low readings from the high readings. This would be akin to a full-wave rectifier. It could be done automatically with a logic counter that uses both the transmit pin and ADC feedback pin as inputs. I suspect you're already using two counters, so that would add another cog. However, neither the transmit counter nor the ADC counter have to be in your PASM cog and could reside in the main Spin cog.
"If you could make it decode a bi-phase encoded tag (FDXB), I would be ecstatic. " ... I'm looking into that possibility... no promises though. At the moment I don't have any FDX-B tags (except for our dog). From the looks of it, FDX-B seems a bit easier to decode than the HDX protocol.
At the moment I don't have any FDX-B tags (except for our dog).
Honey, I need to borrow the dog for a while...I promise I won't hurt him! Meanwhile each time he tries to scan the chip, the dog gets a little tingle in it's back and starts doing the phantom leg scratch!
Beeep, scratch scratch, beeep, scratch scratch.
Hey honey, watch this video I put on YouTube....ROFL!
"If you could make it decode a bi-phase encoded tag (FDXB), I would be ecstatic. " ... I'm looking into that possibility... no promises though. At the moment I don't have any FDX-B tags (except for our dog). From the looks of it, FDX-B seems a bit easier to decode than the HDX protocol.
In the US, pets are tagged with FDXA chips which are manchester encoded. Livestock and fish are tagged with the FDXB (and HDX) chips. So, your doggy wouldn't be of much help.
Hi Beau, do you plan to publish your RFID project in the OBEX?
I would like to implement a half-duplex NFC between 2 props with only one coil.
Your work on the RFID project would help me very much.
I PM'd you on this ... At the moment I am not planning to open source the code due to a conflict of interest, but at some point I would like to implement the reading method into our current RFID reader as it is superior in distance detection than our current reader. The finalized reader version would also be able to read the 124kHz/134kHz ISO tags in addition to the current 125kHz EM4100 64-Bit Protocol tags.
I can walk anyone that is interested through the steps involved that the code takes, but at the moment I can't release any code.
Comments
I have annotated the code further with my rationale on how I arrive at the result
I hate writing code in forums because it's not representative of the write, compile, run cycle. If it was a simpler issue I'd have coded it up and posted my actual resulting code.
I'm not dense, honest!
This code is for an RFID reader using only 6 passive components ... (5 capacitors and 1 resistor) ... With this particular design I'm getting about 3+ inches of detection.
Here is the video in action:
http://www.youtube.com/watch?v=LbMUWwuCx0w
Here is a description of the operation: (Keep in mind, everything for the RFID driver/detector is running under on COG)
The RFID reader uses an 8-Bit Software implemented ADC to capture a sample at every 125kHz pulse. This serves a double purpose...
1) sampling only when the 125kHz signal is HIGH results in a 'software rectifier' to demodulate the AM nature of the RFID signal.
2) sampling at 125kHz also has a way of creating a natural signal rejection to the 125kHz so this eliminates any hardware approach to filtering that can end up attenuating the signal. This basically allows you to detect the tag from a further distance.
The next software filtering stage implements a method to Increase the signal to noise ratio using an "ensemble averaging" method with 8 125kHz samples. Ensemble averaging is basically over sampling. If you taking the square root of the number of times you over sample, in this case 8, it will give you the signal to noise gain. With 8x it's about 2.83
Following that, the next software filter is a simple Automatic gain control where the mean average is used to create a virtual signal threshold... This stage acts like a comparator to establish the HIGH and LOW signal transitions present in the RFID signal.
The bit rate of the 125kHz RFID is 512us which equates to 64 125kHz pulses per bit. The ensemble averaging divides 64 by 8, leaving us with 8 samples per each RFID bit or 8 phases of each RFID bit that we can use to help decode the TAG signal.
The RFID data is Manchester encoded and follows the EM4100 64-Bit Protocol. The Resulting output are two LONG (32-bit wide) variables containing the decoded data.
Relatively simple bit parsing can decode the two longs into a "Human readable" number.
Note: The "Double D" configuration stems from my previous knowledge of metal detectors... And yes, this RFID reader can also double up as a metal detector. The idea of using two coils has a few beneficial filtering/amplification characteristics that are favorable for this design. Basically the double coil works like this ... You have a drive coil and a sense coil. The drive coil possesses the most magnetic flux in the center of the coil, while outside of the coil you have a weaker less concentrated flux of opposite polarity. The sense coil should be positioned so that it's sitting at an equilibrium point of the drive coil where the magnetic flux cancels out. In this configuration your sense coil is the most sensitive... very small disturbances in the magnetic flux from the RFID tag (as it modulates) create a large imbalance that can easily be detected in the sense coil.
-Phil
Honey, I need to borrow the dog for a while...I promise I won't hurt him! Meanwhile each time he tries to scan the chip, the dog gets a little tingle in it's back and starts doing the phantom leg scratch!
Beeep, scratch scratch, beeep, scratch scratch.
Hey honey, watch this video I put on YouTube....ROFL!
In the US, pets are tagged with FDXA chips which are manchester encoded. Livestock and fish are tagged with the FDXB (and HDX) chips. So, your doggy wouldn't be of much help.
I would like to implement a half-duplex NFC between 2 props with only one coil.
Your work on the RFID project would help me very much.
-Uwe
I PM'd you on this ... At the moment I am not planning to open source the code due to a conflict of interest, but at some point I would like to implement the reading method into our current RFID reader as it is superior in distance detection than our current reader. The finalized reader version would also be able to read the 124kHz/134kHz ISO tags in addition to the current 125kHz EM4100 64-Bit Protocol tags.
I can walk anyone that is interested through the steps involved that the code takes, but at the moment I can't release any code.