NFC antenna tuning without a VNA

Recently I started work on a new board. This one will be a front door entry system, so I decided to go with something that could read my NFC implant but also had a numeric keypad for the kids (and anyone else) to use. Not everyone wants to be chipped. Crazy, isn’t it? I’ll write more up on the board when it gets closer to completion, but for this post I’m going to concentrate on a small PCB antenna that’s intended for use with a tiny implanted tag. I’ve successfully used a wirewound inductor before, but I decided it was time to try a PCB trace antenna. This is the most common way to make an NFC reader, but nobody seems to have tried to tune one for an implant – probably because it means it will be worse at reading larger tags. Anyway, this is about creating a small PCB antenna and more importantly tuning it so that it read well.

IMG_20181025_215846So, this is the PCB. It’s based around a MSP430FR2633 for it’s great capacitive sensing for the buttons. There is also a TRF7970A NFC transceiver as I’m familiar with this. You may also notice that I’ve gone for a reverse mount RGB LED that shines through that unmasked piece of the board. I’m really pleased with how that works. Check out this video of the buttons in action to see if you agree.

No VNA?

The NFC part also worked fine, but I must admit the range and sensitivity wasn’t great. I had calculated that the PCB antenna should have an inductance of about 1μH so I just used the same matching components that worked well previously. What I really needed to tune the matching circuit was a Vector Network Analyser (VNA). Unfortunately these are very expensive and I’d likely only ever use one for this. Is there another way? Well, luckily I came across an article entitled “Impedance matching for 13.56 MHz NFC antennas without VNA” which seemed to be just what I was after. Then only slight problem was that I needed an accurate measurement of the impedence of the PCB trace – by which I mean it’s inductance and resistance. I needed to buy a slightly less expensive piece of equipment – an LCR meter. I went for the DER DE-5000 which I must say I’m extremely happy with.

Measuring and calculating

So it turns out that the PCB trace I expected to be about 1μH turned out to be 0.627μH with a resistance of 0.867Ω – otherwise expressed as 0.867 + j53.42Ω. The article suggested a parallel resistor of 362Ω so i went with the closest I had of 470Ω. Calculating the parallel and series capacitances seemed trickier. I ended up using some Smith Chart software from Fritz Dellsperger. and to be honest I sort of went with trial, error and adjustment to try to get the final point as near to 50Ω as possible. I managed a theoretical 54.973 – j1.455Ω

Smith chart

I approximated the parallel  capacitance to 100μF + 47μF = 147μF and the serial to 68μF + 15μF = 83μF. With the measured value of my PCB trace and the matching components I had it had been 8.847-j135Ω. No wonder it wasn’t great!

The end result

Whilst reworking the board I measured the lowish tolerance capacitors I was using and by selecting the most appropriate ones I ended up a little bit closer to my goal. Did it work? You bet it did. I must admit I was surprised how well. Just as I was surprised when the reader and keypad worked too. Maybe I should have a bit more confidence in these things (and myself).

Advertisements

Getting into FPGAs

minized20reset20corner20viewSo, I obviously decided that my world wasn’t already filled with enough random stuff. I decided that it would be a good idea to get my head around FPGAs. I’m sure many of you know what FPGAs are but just in case you don’t I’ll give you a quick summary. A Field Programmable Gate Array is user defined hardware. If you decide that you need some logic (e.g. an AND gate) you could use a discrete logic gate – hello 74LS08. You could of course use a microcontroller which might even be cheaper than the logic gate. Weird, but it’s starting to be true.

The other way is to have a big ball of programmable logic that you can configure however you want. Powerful, flexible, fast. Bizarrely, you can even program enough logic to create an processor. Yes, you can create (via software) some hardware that will run software. This is just a taste of how strange the world of FPGAs can get.

I asked a few questions about the easiest way in and got loads of different answers. Anyway, someone was kind enough to send me an Arty S7 FPGA board that he’d finished with. There is a course going on at Element 14 all about programming FPGA SoCs – that’s a chip with a microprocessor and some FPGA in one. So I bought a MiniZed.

I’ve only just started, but already it’s quite a trip. An FPGA is usually programmed in either VHDL or Verilog. They’re both languages that look a bit like a programming language but really aren’t. I’ve heard the learning curve described as “the cliff of insanity” and I’m starting to know how that feels. Anyway, the journey so far is strange but I’m enjoying it. I never did ask if you start at the bottom of the cliff and climb it or if you start at the top and fall off.

Rohde & Schwarz RTM3004 review

I finally finished my review and road test of the Rohde & Schwarz RTM3004 oscilloscope. For those that don’t know, that’s a very high-end 1GHz oscilloscope. It’s a mixed signal oscilloscope (4 analog and 16 digital channels). It’s also got a built-in function and pattern generator. There’s also some really nice FFT and Spectrum Analysis functionality. It’s got a great 10″ touch screen.

RM3K with Keysight and RigolBasically it’s amazing compared to the Keysight DSOX1102G and Rigol DS1074Z that I’ve been used to. There’s nothing wrong with these two ‘scopes of course. It’s just that if they’re a nice family car, then I feel I’ve just been asked to drive around in a Ferrari for a month and write about it. Oh yeah – and you can keep the Ferrari when you’re done. As you can imagine, I’m quite happy about it.

I won’t reproduce the full road test here on the blog. If you’re interested in reading all about it then you can head over to Element14. If you’re after a video summary of the features then here you go.

Working on a oscilloscope review

You know how it can be sometimes. You’re working on one project, then it gets bumped by another. Sometimes that one gets bumped by a higher priority one. Your life is like a nested interrupt handler.

My latest project is moving my MSP430-based NFC reader over to the CC1310. It’s been competing with converting a garage into the noisy, smelly power tools and CNC side of my workshop setup.

img_20180603_112827638539278.jpgI’m very pleased to tell you than something more urgent had come up that has stalled these two. Rohde & Schwarz have asked me (via Element14) to road test one of their latest oscilloscopes – the incredible RTM3004. Even better, I get to keep it afterwards. This is a high end 1GHz 4 channel ‘scope with a 16 channel logic analyser, signal and pattern generator, spectrum analyser and loads of other features.

As you can imagine I feel obliged to put a reasonable amount of effort into this, although to do it in a fair and unbiased way. I’ve already started but I expect to spend at least another month of my free time on it. Stay tuned for the results which will appear on full over on Element14 but have a summary and link here too.

Philips Hue – control anything hack

To be honest, my recent simple relay hack wasn’t really all that great. It just used the high power constant current output to drive a SSR. It wasn’t ideal, but it worked. I decided that it was worth the effort to track down some more useful outputs and properly detect the desired state of the bulb.

b22_closeupAll it took was a little bit of poking around and probing the pins of the SAM R21 microcontroller with an oscilloscope. It wasn’t actually that hard. On the B22 bayonet fitting version of the bulb I found some.

PA16 (pin 17 of the microcontroller) has a simple on/off output. It’s high (3.3V) if the light is on  at all and low if not. This is the perfect output to use to drive a simple output for a relay. It can be run straight to a SSR if that’s appropriate for your load. Or it can be used as an input to another microcontroller, a transistor to drive a relay, etc. This is probably the easiest one to use for a simple load. A slightly easier place to access it is on the end of diode D3 nearest the micro. It’s still some fiddly soldering, but it’s easier that a QFN pad on the SAM R21 itself.

PA17 (pin 18 of the microcontroller) has a decent PWM output. Unlike the one I found on TP5 of the E27 bulb, this stays high when the bulb is 100% on. It’s a 3.3V signal. It doesn’t seem to be quite linear – i.e. 50% brightness isn’t a 50% duty cycle but this may be deliberate to compensate for how bright it actually looks.

TP25 has a DC voltage of about 14V which is fed to the LM2204 3.3V regulator. This seemed handy for driving the coil of a 12V relay.

I rigged up a simple relay circuit – using the 3.3V PA16 output to drive a NPN transistor that can then drive the relay. Add the usual flyback diode (and a MOV across the relay contacts for the benefit of inductive loads) and all is g0od!

Philips Hue – simple relay hack

img_20170102_162008OK, so I said I’d start simple but this is about as simple as it gets. I’m almost embarrassed it’s not a little more complicated. I’ve done a teardown of a LBW010 bayonet fitting bulb and thought I’d take a look at its E27 screw-in cousin. (I’ll post this teardown later, but here’s a photo to give you the gist of it.) You can see the main board in the centre and the LED board that I’ve removed. It was similar to the B22 but quite different too.

Coming in from the left in the main photo below are the Hue mains connections – blue neutral and red live. My apologies about the mixed colour schemes but those were the wires I had to hand. Heading out on the right are the positive (red) and negative (black) that normally run to the LED PCB. All I’ve done is connect these directly to the input of a solid state relay. That’s it.img_20170104_212708

So why is this hack a little blunt? Well the four wires you see that aren’t connected are my far more sophisticated attempt to dig out some useful logic signal from test point on the PCB. There’s some nice stuff there. I thought I’d use a PWM output I found on TP5 to drive the SSR. It was almost enough but I hit a small snag. (Currently it works as expected between 1 and 100% but irritatingly switched the SSR on when at 0%.) I thought about leading these to a logic circuit, maybe even another microcontroller.

Then I saw the 3-32V input on the SSR. 32V?? That’s a little bit more that the Hue puts out the the LEDs. Could I? Yes, I could. The Hue outputs are used to driving 260mA at about 31V so with minimal load it actually reached about 37V, but it seemed to work fine. I’m using a constant current driver to drive a low impedance and just getting lucky that the voltage limit is being hit. I know that’s not sensible.

So basically , rip the bulb apart, connect it to a SSR and you can now drive any mains lighting you like! It should work with the B22 and maybe even the GU10 bulbs too, but these single colour bulbs are the cheapest.

Things can certainly be done a little better and it will be. For instance:

  • I could use a voltage divider to tame that 37V a bit.
  • I could drive a normal relay if I added a  suitable series resistor and a flyback diode. SSR have problems driving some loads – ironically LED drivers being one of them.
  • I could dig further into that PWM signal and properly detect the power level of the light, maybe driving more than one relay or SSR.

Anyway, all this will come but I thought this simple hack was worth sharing as-is.

UPDATE: A better way to get to a decent signal to control anything (using a B22 bulb) here.

Philips Hue garden floodlight

So, after the initial teardown, it’s time to start the Philips Hue hacking. To be honest this is fairly simple so doesn’t really qualify as a hack. I said I’d start small and work up from there, so consider this a warm-up exercise.

I’ve got a motion sensing 10W LED floodlight mounted on my workshop. It’s supposed to light my way as I head out there but it doesn’t really work as I’d like. As I’m walking straight towards it the PIR only triggers when I’ve already trudged through the dark garden and I’m about a metre away. Also, the local foxes are constantly triggering it at night. Having this under Hue control would be ideal. Let’s take a look.

img_20161231_130126My Wicked brand floodlight contains a single chip LED which actually had 9 separate LEDs on the die. It has a constant current LED driver which outputs 350mA at about 24V. Hmmm – this could be very easy. They pretty much matches the Hue bulb I tore down. Electrically this might be as easy as connecting the spotlight’s LED in place of the Hue’s board. And you know what – it was! I did a quick check that the hue bulb circuitry was happy to dive the LED in the floodlight directly and then it was just a case of putting it all together. Out came the PIR sensor. Out came the constant current LED driver (the white box) and in went the Hue circuit board.

img_20170102_130311The only tricky bit was deciding where to put the PCB. Once the LED driver had gone, there was plenty of room behind the light. However, this was a metal case and the light is a fair distance away from the house. I didn’t think the Zigbee signal would reach. It didn’t have to be in the lamp at all of course, but it seemed neater.

I decided that the best place to put it was where the PIR has been. All it needed was a new 3D printed front cover. I could have saved space and printed a new back piece. I could have missed out the hinged bit and printed a two part case. My new Year’s resolution is to get project finished so I went with the simplest option.

img_20170102_131430So, here it is side by side with an original. Fitting was pretty easy. The only gotcha I has was that as i connected it, the Hue hub decided it would be a good time to update the firmware in the bulb. Hue bulbs normally switch on when first powered but whilst updating it was off. Cue some unnecessary checking of wiring, removing and remounting it, checking fuses, etc. Oh well, it working