Debugging the RFID Module

11/8/2013— Eric Kolker

It’s nearly 4 AM. My hands and eyes are dry and tired, and my fingers probably smell like a mix of isopropanol and flux. I’m dehydrated and have been inhaling fumes for the last six hours, but it’s been a good day. Today we built all the modules which will be going out to our first round of Beta backers in less than two weeks. They’re shiny, they’re red, and they represent a hard day’s work in the lab. If my sleep schedule weren’t inverted, I’d probably be crashing about now (unless I caught the second wave), but it very nearly *is* inverted, so

< hour-long break where I read some articles, sign some paperwork, and browse Facebook >

it looks like I have a blog post and maybe some firmware ahead of me. With any luck, I’ll get up in time for a meeting around lunchtime. … Part of me wants to blame the startup life, but part of me knows my own habits get all the credit. Swap “credit” and “blame” as you see fit.

 

Hey readers! Eric here. We hinted in a recent blog post that we’d tell the tale of our RFID module sometime this week, so here goes.

Our story begins with the second round prototype. I knew that this version of the RFID board and the hardware we had bought from Adafruit differed in something that was subtle but also quite important. It wasn’t anything about the schematic or PCB layout per se (I had essentially forked my designs for both off of Adafruit’s), so I had to dig deeper and think a little harder.

I started by simulating the RF (radio frequency, anything operating above a few hundred kilohertz) TX/RX (transmit/receive) chain in LTSPICE (my circuit simulator of choice). The RF chain is made up of a network of passives (resistors, capacitors, and inductors), so I plugged in the values I had on the schematic, did a frequency sweep, and found that, surprise, the circuit had a resonant peak near 13.56 MHz. This is what that looks like in simulation:




A quick note on how to read the charts and what matters:

  • The top graph is called a Bode plot. It shows what happens to a sinusoidal waveform as it passes through my circuit. Frequency, in Hertz, is on the x-axis. Magnitude, in decibels, and phase shift, in degrees share the y-axis.

    • The solid lines show the magnitude of the frequency response of the circuit, which tells us if portions of the signal at any given frequency are amplified or attenuated as they travel through the system.

    • The dashed lines show the phase shift of the output waveform with respect to the input waveform, in this case measured in degrees. We don’t care about it so much in this case, but phase is really important in control systems design.

  • The bottom is the schematic I’m simulating. I’ve named all my components and nodes (places where components are connected) so that it’s easier for me to read the graphs, which in turn help me tune the values on the schematic, which, well, you get the idea.

In this case, I wanted to see a spike upwards around 13.56 MHz, which would tell me that the system resonates around that frequency. In layman’s terms, this means that the system is good at storing energy that comes in at that frequency. In the case of RFID, we mostly care about the current through the last inductor, I(L2), and in the very special case of the board we built, this inductor is actually a long, winding trace on the PCB. In any case, current through an inductor is related to the strength of the magnetic field and therefore the distance at which we can read an RFID tag. I included V(V_1) (the voltage at node V_1) as well to get a general sense of what inductor L1 and capacitor C1 do to the signal; it just so happens that the input section of a system often has a disproportionately large impact on output signal quality.

As I hoped, the system resonated at roughly 13.56 HMz. However, the system as simulated is a purely theoretical one, and it turns out that that is part of the problem.

I wanted to know how the real boards compared to my simulations, so I soldered a few wires onto both the boards (to nodes V_1, V_out, and ground) so that I could drive (provide input to) the antenna circuitry and measure the response. I then proceeded to beg my old wireless communications professor to let me use some of his lab equipment to characterize the system. Armed with a swank signal generator and spectrum analyzer (a poor man’s network analyzer, but still $35,000 in test equipment), I did frequency sweeps and collected some data:

This is another Bode plot (well, the magnitude portion), which shows the frequency response of our board (red) and Adafruit’s (blue) on top of one another. The fact that the curves look like gradients (as opposed to just lines) stems from how I took the measurements (like I said, poor man’s network analyzer), but the shape of the upper limits of the curves is what’s important in this case.

We care most about the response at 13.56 MHz, but the takeaways from this graph are mixed.

  • These graphs should look like the ones from SPICE, but definitely don’t. Hmm…

  • Our amplitude is slightly higher than Adafruit’s at 13.56 MHz (win! This means we’re more sensitive to signals at 13.56 MHz, which means we should be able to read RFID tags from further way)…but this finding is not actionable because we were apparently already doing fine.

  • Not instantly sure what’s going on on our board with the huge null around 17MHz, but because it’s outside the band of interest we don’t actually care.

  • The fact that the slope at 13.56 MHz is more gradual suggested to us that the LC resonant tank created between C3 and L2 (with R2 in the way) might be less ideal on our board than on Adafruit’s. Translation: Adafruit picked a few key parts to splurge on which might make all the difference. Time to figure out which ones.


One of the things I learned to do early on in my engineering career was simulate things. It’s often easier to have a computer run the numbers than to run the test yourself (be it a circuit, mobile app, or load test for a large mechanical assembly). The blessing and the curse of simulations, however, is that they can only ever be as accurate as you care to make them. In other words, if real resistors, capacitors, inductors, and transistors were all perfect, ideal, purely mathematical devices, the board’s performance would match simulation’s, we’d be able to read RFID tags from a good distance away (and angels would sing on high as we did).

It turns out that these parasitic characteristics (think “this resistor should not be here because i’m supposed to be an inductor, not a resistor”) and other “nonidealities” (deviations from the pure mathematical models in the form of nonlinearities, dependence on temperature or voltage, hysteresis, etc.) are part of what separate not only real components from ideal ones, but also high quality real components from low quality ones.


Armed with the knowledge that the fundamental design I had in hand was good, I looked through the datasheets for the components we had used on our board and plugged in some values of series resistance to SPICE. The results, below, are quite different from what I had originally found.



Everything is smoother (this is bad: we want nice sharp resonant peaks), V_1 now has a null near 14.5 MHz (look familiar?), and the output voltage and current drop by around 20 dB (a factor of 10). Clearly the components we were using were no good.

I suspected then, that the inductor L1 was the primary offender, so I popped the corresponding part off of the Adafruit board and swapped it for what we had on ours. It helped, but did not completely solve the problem: RFID communication distance jumped from a millimeter (read: contact) to about a centimeter. I spent half an hour on Digi-Key “specing” (hunting for a part that not only has the right value, but also the right package, is economical in quantities of 100 and 1000, meets other required specifications, etc.) inductors to replace the ones we currently had on our board, ordered a few samples, and then turned my sights to the PCBs themselves.


I took the boards up to the lab and used a LCR meter to measure the inductance of the PCB antennas (L2 in my sim). I found that they were actually remarkably similar, but that the Adafruit board had a higher Q factor, which implied that it had a smaller resistance.

Next, I set up an ultra-precise four point resistance measurement and found that Adafruit’s antenna had a series resistance of about 0.37 Ohms. Ours clocked in at about 0.53 Ohms. Although the difference there is small, it’s the ratio that matters: their antenna was about 30% less resistive than ours, which was consistent with their higher Q factor.


These days, PCB mills are out of style. Well, they may be coming back into style for personal use, but the fact remains that most boards that are made in any volume are printed. For two-layer boards (the process is more complex with more layers), you start with a piece of copperclad: a sheet (generally fiberglass-based) with a thin layer of copper on the top and bottom. A series of processes lay down chemicals that become corrosion resistant when properly treated, and the remaining exposed copper is bathed in nasty chemicals and dissolved away. Afterwards the surface may be treated with some combination of metal plating, a nonconductive layer called the soldermask, and a layer of paint called the silkscreen.

As you can imagine, every step in this process can be customized, and the thickness of the copper is no exception. It’s specified in terms of ounces per square foot (which typically just gets shortened to “oz.”, or oz./ft. if you have the time) and corresponds to “if you took x ounces of copper and mashed it over one square foot…well, that’s how thick the copper is on each side of your board”. Most boards use one-ounce copper (at least for the outer layers) and “heavier” boards are typically only needed for high power applications (the highest I’ve held is 4 oz., but I’m sure the sky’s the limit).


Finally, I grabbed a pair of calipers and set to measuring the thickness of the copper plating on the PCB. I measured the “bare” board first, then the board with the antenna trace. The differences were not the same: Adafruit’s copper was, in fact twice as thick as ours, putting it at two ounces.

I let out a sigh, emailed Jia, and told her to find me a PCB house that would do two ounce copper in a reasonable amount of time. At this point, it was late, I was tired, and it would be better to continue to match Adafruit’s working design as best we could, rather than chase down more rabbit holes.


Fast forward a week or so, and there I was in the lab with two boards in front of me, fresh back from the oven. They were two ounce copper, had the funky fresh inductors I had picked out, and were ready to test. I plugged one in, loaded some code, watched the RFID chip enumerate, pulled out my CharlieCard (Boston’s RFID-enabled subway fare card), and held my breath.

I brought the card close, and watched as my screen displayed a very familiar, but lately aloof, four byte sequence: my identifier in the eyes of the MBTA.

It had worked, and at a distance of roughly three inches, so naturally I threw my hands in the air in celebration. In my hurry to capslock the success to the rest of team over HipChat, I lost my Charlie card somewhere on my desk. I’m sure it’ll turn up eventually.

~e