Limpkin's blog - Tag - nfc<div>An electronics geek blog, dedicated to sharing and open source. Check out my stores: <a href="https://lectronz.com/stores/stephanelec" hreflang="en" title="Lectronz store">EU</a> / <a href="https://www.tindie.com/stores/stephanelec" hreflang="en" title="tindie store">EU & US</a>.</div>2024-03-29T00:41:47+00:00Mathieuurn:md5:51de6a3d917257edeff5a252fe925b02DotclearTrying to Make a Tiny NFC Reader with a TRF7970Aurn:md5:9d254e92633f3336f24ac58af2f5c91f2015-01-11T15:44:00+00:002023-04-14T13:47:00+01:00limpkinMy Projectsnfctrf7970a<p>Want a free board? Read below!<br /></p>
<p><img src="https://www.limpkin.fr/public/NFC/.nfc_board_m.jpg" alt="NFC board" style="display:table; margin:0 auto;" title="NFC board, janv. 2015" /><br /></p> <p>My regular readers may already know that I never stop working on a project half-way. This is unfortunately the only exception so far, motivated by the fact that an IC isn't doing what it's supposed to do, that my thread on the TI support forum was left unanswered for months and that I'd like to upgrade some of the chosen hardware.<br />
So a few months ago I wrote a <a href="https://www.limpkin.fr/index.php?post/2014/10/07/Using-a-Standard-Coil-for-NFC-Tag-Implant-Reading">quick post</a> about using a standard coil for NFC tag implant reading. The PCB you saw in the article is the one I'll be writing about.<br /><br /></p>
<h2>The Schematics<br /></h2>
<p><a href="https://www.limpkin.fr/public/NFC/nfc_schems.png" title="NFC schematics"><img src="https://www.limpkin.fr/public/NFC/.nfc_schems_m.jpg" alt="NFC schematics" style="display:table; margin:0 auto;" title="NFC schematics, déc. 2014" /></a><br />
The main components are:<br />
- the USB-enabled ATMega32U4<br />
- a connector for the NRF24L01<br />
- a Lithium-Ion battery charger<br />
- an NFC transceiver<br />
- a proximity sensor<br />
The main idea of this platform is to read NFC tags while <strong>keeping its power consumption low</strong>. The microcontroller is communicating with the NFC transceiver so you can use the platform as a <strong>standalone device or computer peripheral</strong>.<br />
You could therefore control a switch (using the expansion header), send the tag data via RF (using a NRF24L01 you'd connect) or simply have the ATMega32U4 forward the read/write commands sent from your computer. The original idea was to <strong>support libnfc</strong>.<br /><br /></p>
<h2>The Li-Ion battery charger<br /></h2>
<p><a href="https://www.limpkin.fr/public/NFC/bq24232h.png" title="bq24232"><img src="https://www.limpkin.fr/public/NFC/.bq24232h_m.jpg" alt="bq24232" style="display:table; margin:0 auto;" title="bq24232, déc. 2014" /></a><br />
The <strong>bq24232h</strong> is a neat little chip that is very convenient when having a USB powered platform. It'll of course charge your battery but will also behave like a standard LDO when none is connected. As Li-on battery charges can be very complex it has several inputs used to set the optimal charging parameters (charging/termination current, pre-charge/fast-charge safety timers, maximum current on the 5V USB input...). If you look at <a href="http://www.ti.com/product/bq24232" hreflang="en" title="bq24232h">its datasheet</a> you'll see on page 17/18 how a proper li-ion charge should be done. The chip can also monitor the battery temperature and even has short-circuit protection.<br /><br /></p>
<h2>The Microcontroller<br /></h2>
<p>A USB interface was required to operate the platform as a computer peripheral.<br />
The chosen ATMega32U4 has several low power modes, an integrated bootloader and has all of its IO pins used in our platform. As the voltage will vary anywhere between <3V and 4.6V we are running it at <strong>8MHz</strong>. Its 3.3V regulator is used to power an external NRF24L01. Given that the latter accepts 5V signals and that the ATMega32U4 also sees 3.3V signals, <strong>no voltage translation is required</strong>.<br />
Unfortunately the bq24232 doesn't have any battery <strong>under-voltage lockout</strong> so the li-ion battery voltage could theoratically go as low as 2.7V (minimum voltage for the ATMega32u4 and NFC transceiver).<br /><br /></p>
<h2>The proximity sensor<br /></h2>
<p><a href="https://www.limpkin.fr/public/NFC/pcf.png" title="pcf8883 principle"><img src="https://www.limpkin.fr/public/NFC/.pcf_m.jpg" alt="pcf8883 principle" style="display:table; margin:0 auto;" title="pcf8883 principle, janv. 2015" /></a><br />
The <strong>PCF8883</strong> is a capacitive touch/proximity switch with auto-calibration and very low power consumption (3uA). The goal of this chip in our platform (when operating as a standalone device) is to <strong>wake-up the microcontroller</strong> when the NFC tag/implant is close. Our device will therefore always be in power-down and will only consume power when <strong>it is actually needed</strong>. Given its voltage range is 3V->9V our platform will never wake-up once the li-ion battery goes under <strong>3V</strong>.<br /><br /></p>
<h2>The NFC transceiver<br /></h2>
<p><a href="https://www.limpkin.fr/public/NFC/trf.png" title="trf7970a block diagram"><img src="https://www.limpkin.fr/public/NFC/.trf_m.jpg" alt="trf7970a block diagram" style="display:table; margin:0 auto;" title="trf7970a block diagram, janv. 2015" /></a><br />
I chose the (not so cheap) <strong>TRF7970A</strong> from TI. This decision was motivated by a collaboration with Amal Gaafstra (the xNT tag creator), who was interested in having a transceiver with <strong>NFC peer to peer mode support</strong>. The TRF7970A is the updated version of the quite popular TRF7960.<br />
This transceiver is <strong>supposed to</strong> take care of all the low level stuff for you (modulation, framing and such) for the ISO15693/ISO18000-3, ISO14443A/B and FeliCa protocols. In short, you just need to give it the data you want to send to the tag using one of its interfaces (SPI or parrallel). It even has a 127 bytes FIFO.<br /><br /></p>
<h2>The problem<br /></h2>
<p><a href="https://www.limpkin.fr/public/NFC/nfc_debugging.JPG" title="NFC debugging"><img src="https://www.limpkin.fr/public/NFC/.nfc_debugging_m.jpg" alt="NFC debugging" style="display:table; margin:0 auto;" title="NFC debugging, janv. 2015" /></a><br />
To put it simply: the TRF7970A isn't doing what it's supposed to. I found several examples (provided by TI) of tag reading procedures that I implemented <strong>as is</strong>.... without success. I put the sniffed communications on the <a href="http://e2e.ti.com/support/wireless_connectivity/f/667/t/375663" hreflang="en" title="e2e forum">e2e forums</a> demonstrating the odd behavior yet my thread is left unanswered. In more details, among other things, I was forced to use 10ms delays to fetch data from the internal FIFO instead of using the dedicated RX interrupt.<br />
Thinking that I may have made a mistake on my PCB <strong>I even bought the official development board</strong>! This is something I practically never do :-) ... but that didn't help as I was still getting the same odd behavior. I couldn't find anything in the erratas either.<br /><br /></p>
<h2>The solution?<br /></h2>
<p><a href="https://www.limpkin.fr/public/NFC/nfc_debugging2.JPG" title="NFC debugging"><img src="https://www.limpkin.fr/public/NFC/.nfc_debugging2_m.jpg" alt="NFC debugging" style="display:table; margin:0 auto;" title="NFC debugging, janv. 2015" /></a><br />
If you want a <strong>free PCB</strong> and a small bag with most of the platform components in it, please <strong>drop me a message</strong> and I'll gladly send them to you. I decided to stop working on it because the official development board with the official tag reading commands <strong>didn't work</strong> but also because I currently am very busy working on the <strong>Mooltipass production process</strong>.<br />
I might get back to it some point in the future, though I may replace the NRF24L01 with an ESP8266.<br />
<strong>Edit (03/19/2015): 5 months later I got a reply, it seems that a possible solution to the problem would be <a href="http://e2e.ti.com/support/wireless_connectivity/f/667/t/326537" hreflang="en" title="errata">here</a>.</strong> Will try and let you know.<br /><br /></p>
<h2>The files<br /></h2>
<p>They're all CERN & GPLv3 licensed. If you look at the firmware you'll see that I implemented my own ISO14443A activation and selection procedure following the official specs.<br />
<a href="https://www.limpkin.fr/public/NFC/nfc_kicad.rar">kicad files</a> <a href="https://www.limpkin.fr/public/NFC/nfc_fw.rar">NFC firmware</a> <a href="https://www.limpkin.fr/public/NFC/nfc_ti_advices.rar">TI examples and advices</a> <a href="https://www.limpkin.fr/public/NFC/BoM_nfc_reader.xlsm">NFC reader BoM</a></p>Using a Standard Coil for NFC Tag Implant Readingurn:md5:b8ebb11661de65415c0a4c2bfa48e2422014-10-07T11:53:00+01:002024-03-09T11:02:16+00:00limpkinMy Projectsimplantnfcvna<p>Who knew it'd be possible to use this coil to read NFC tags?<br></p>
<p><img src="https://www.limpkin.fr/public/NFC/.PCB_m.jpg" alt="NFC reader PCB" class="media-center" title="NFC reader PCB, oct. 2014"></p> <p>A while ago I backed the <a href="https://www.indiegogo.com/projects/the-xnt-implantable-nfc-chip" hreflang="en" title="xNT campaign">xNT campaign</a>, which aimed at making an <a href="http://www.nxp.com/products/identification_and_security/smart_label_and_tag_ics/ntag/series/NTAG213_215_216.html" hreflang="en" title="NTAG216">NTAG216</a> based NFC implant for different purposes. After a few months of waiting and a few weeks of trying to find someone in Switzerland willing to do the very simple implant procedure, I finally became a cyborg:<br></p>
<p><a href="https://www.limpkin.fr/public/NFC/implant.JPG" title="The implant"><img src="https://www.limpkin.fr/public/NFC/.implant_m.jpg" alt="The implant" class="media-center" title="The implant, oct. 2014"></a><br>
Sorry for the poor picture quality... it's indeed extremely hard to take one when you don't have access to an xray machine.<br>
The implant can be read by most recent non-Apple branded phones and can be reprogrammed as many times as you want. It however only has <strong>868 bytes of non volatile memory</strong>, which is actually more than enough to store my contact information at the moment.<br></p>
<p><img src="https://www.limpkin.fr/public/NFC/coupling.png" alt="coupling factor" class="media-center" title="coupling factor, oct. 2014"><br>
As your intuition may tell you, using a big antenna to read a tiny implant isn't the best scenario we can imagine. Most phones typically only have a <strong>small sweet spot</strong> where implant reading is possible. This is due to what we call the <strong>coupling factor</strong> that only depends on the reader & NFC tag antenna geometries and the reading distance squared:<br></p>
<p><img src="https://www.limpkin.fr/public/NFC/coupling_factor.png" alt="coupling factor" class="media-center" title="coupling factor, oct. 2014"><br>
From the equation above, it is obvious that our coupling factor will be maximum when r1 = d1/2 = r2 = d2/2. However, <strong>contrary to our intuition</strong> a coupling factor greater than 10% will cause several communication problems (see the PDFs at the end of this article). But we may not need to worry about that because of our reading distance (I have a thick skin) and the angle between our tag and the reader.<br>
Conclusion? In a perfect world, <strong>our reader's antenna should have the same diameter as our implant's</strong>.</p>
<p><img src="https://www.limpkin.fr/public/NFC/coil.JPG" alt="chosen coil" class="media-center" title="chosen coil, oct. 2014"><br>
As I didn't want to wind my own antenna and thought that designing a small one on a PCB wouldn't be so convenient for hand positioning, I wondered if I could use a standard coil like the one shown above. This meant entering the wonderful world of <strong>antenna matching</strong>.<br></p>
<p><img src="https://www.limpkin.fr/public/NFC/.pcb_antenna_m.jpg" alt="PCB Antenna design" class="media-center" title="PCB Antenna design, oct. 2014"><br>
With a few hours of Googling you'll find many application notes containing standard PCB antenna designs. They're nice recipes you just need to follow to get a functional NFC reader in no time.<br>
The passive elements you see in the picture above (C1/C2/R1/C3/C4) are here so the <strong>complex</strong> impedance seen at "Ckt Feed" is exactly 50 ohms. If your antenna circuit impedance doesn't match your transmitter's your <strong>power transmission</strong> won't be optimal.<br></p>
<p><img src="https://www.limpkin.fr/public/NFC/.returnloss_m.jpg" alt="return loss" class="media-center" title="return loss, oct. 2014"><br>
Power transmission can be checked by looking at an antenna's <strong>return loss</strong> for a given impedance (usually 50 ohms). An ideal case is shown above.<br>
Note that the slopes around the 13.56MHz center point shouldn't be too steep as NFC ASK/FSK modulation creates other frequency components nearby. A typical 2MHz bandwidth is actually recommended to accommodate the upper and lower RFID sidebands for various data rates given in ISO15693 & ISO14443A/B.<br>
This is called the antenna circuit <strong>quality factor</strong>, equal to F/BW = 13.56MHz/2MHz = 6.78 in our case.<br><br></p>
<p><img src="https://www.limpkin.fr/public/NFC/.vna_m.jpg" alt="vna" class="media-center" title="vna, oct. 2014"><br>
So how do we measure an antenna's return loss <strong>and</strong> devise an impedance matching for a non-characterized antenna?<br>
We use a very expensive piece of equipment shown above called <strong>Vector Network Analyzer</strong> and some fancy software.<br>
This machine will allow us to first know the <strong>complex impedance</strong> of our small coil, which then enables us to find the passive components values for our impedance matching network.<br><br></p>
<p><a href="https://www.limpkin.fr/public/NFC/impedancemathcing.png" title="impedance matching"><img src="https://www.limpkin.fr/public/NFC/.impedancemathcing_m.jpg" alt="impedance matching" class="media-center" title="impedance matching, oct. 2014"></a><br>
I used the <a href="http://www.fritz.dellsperger.net/downloads.html" hreflang="en" title="Smith software">free Smith software</a> and a few applications notes to convert my coil's complex impedance to 50 Ohms. If you're interested in learning more about Smith charts, please have a look at the different documents at the end of this article.<br><br></p>
<p><a href="https://www.limpkin.fr/public/NFC/finalimpedance.jpg" title="Final impedance"><img src="https://www.limpkin.fr/public/NFC/.finalimpedance_m.jpg" alt="Final impedance" class="media-center" title="Final impedance, oct. 2014"></a><br>
As you can see the final measured impedance isn't so far off from its theoretical value. This is mostly due to the passive components' tolerances.<br><br></p>
<p><a href="https://www.limpkin.fr/public/NFC/reflection.jpg" title="Input Return Loss"><img src="https://www.limpkin.fr/public/NFC/.reflection_m.jpg" alt="Input Return Loss" class="media-center" title="Input Return Loss, oct. 2014"></a><br>
The maximum power transmission frequency isn't too far from our targeted 13.56MHz.<br><br></p>
<p><a href="https://www.limpkin.fr/public/NFC/withimplant.jpg" title="Smith chart with implant next to the antenna"><img src="https://www.limpkin.fr/public/NFC/.withimplant_m.jpg" alt="Smith chart with implant next to the antenna" class="media-center" title="Smith chart with implant next to the antenna, oct. 2014"></a><br>
The smith chart had an interesting shape when my implant was on top of the antenna... which made me believe my idea could actually work. A few days later I purchased an NFC reader with an SMA connector (that I won't mention here because of very poor customer service) and <strong>actually managed to read my implant with it</strong>.<br><br></p>
<p><a href="https://www.limpkin.fr/public/NFC/PCB.JPG" title="NFC reader PCB"><img src="https://www.limpkin.fr/public/NFC/.PCB_m.jpg" alt="NFC reader PCB" class="media-center" title="NFC reader PCB, oct. 2014"></a><br>
As you can guess, these empty footprints are here for a reason... but that'll be the topic for another article.<br><br>
In the meantime, here are the PDFs I mentioned:<br>
<a href="https://www.limpkin.fr/public/NFC/Antenna_matching_for_the_TRF7960_rfid_reader.pdf">Antenna matching for the TRF7960 rfid reader</a> <a href="https://www.limpkin.fr/public/NFC/RFID_antennas.pdf">13.56 MHz RFID systems and antennas design guide</a> <a href="https://www.limpkin.fr/public/NFC/smith_chart_fundamentals.pdf">smith chart fundamentals</a></p>https://www.limpkin.fr/index.php?post/2014/10/07/Using-a-Standard-Coil-for-NFC-Tag-Implant-Reading#comment-formhttps://www.limpkin.fr/index.php?feed/atom/comments/197