Professional Documents
Culture Documents
Andreic Master
Andreic Master
Andreic Master
Andrei Costescu
Department of Informatics
Faculty of mathematics and natural sciences
UNIVERSITY OF OSLO
Spring 2019
Medical Implant NFC Embedded System
Andrei Costescu
© 2019 Andrei Costescu
http://www.duo.uio.no/
This work is part of the SUPRE (SUbcutaneous PREssure sensor system) [1] research
project with the goal of developing health services for patients with dysfunctional
urinary bladders. The NANO group at UiO has previously designed and implemented
an ASIC SoC (System-on-Chip) using NFC for a blood glucose sensor, while the
Polytechnique Montreal has developed an embedded system based on MICS (Medical
Implant Communication Service) for a bladder pressure sensor.
The system in this work is an alternative to the ASIC design, aiming to achieve
similar results using an embedded system. The goal is to achieve a more flexible system
with shorter redesign times at the cost of a larger form factor with higher power draw.
The design is based around a Xilinx FPGA with an integrated ADC, further increasing
flexibility at the cost of size and power.
The functionality is implemented primarily using finite state machines, the code
was written in VHDL. The goal is to be able to communicate with an NFC tag through
SPI and use its on-board memory to temporarily store the pressure sensor readings.
The system is idle until a request is initiated externally, for example by an NFC capable
mobile phone, after which the analog input is sampled and written back to the tag.
A prototype system has been implemented with the AMS 3955 NFC tag and a
Basys3 FPGA development board. A custom PCB is the next step for an embedded
system, a proposal of which is included in this thesis.
i
ii
Contents
I Introduction 1
1 Goals of this thesis 3
2 Background 5
2.1 Motivation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Previous work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.3 Fundamental Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.1 NFC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.2 SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.3.3 Android Application . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.4 FPGA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.3.5 XADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.6 Vivado . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3.7 Basys3 development platform . . . . . . . . . . . . . . . . . . . . . 9
2.4 Usage illustration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
II The project 11
3 Planning 13
3.1 Microcontroller Based Design . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.1 All-in-One NFC Tag . . . . . . . . . . . . . . . . . . . . . . . . . . 13
3.1.2 Amplifier . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1.3 Microcontroller . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1.4 NFC Tag . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.1.5 Component summary . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.1.6 AS3955 Demo Kit . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.1.7 PIC Reprogramming . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2 FPGA Based Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4 Digital design 19
4.1 AS3955 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1.1 Power supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1.2 Data structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
4.1.3 Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.1.4 Interrupt registers . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.2 System Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
4.2.1 Decision diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
4.3 SPI module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
iii
4.3.1 Module overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
4.3.2 FSM diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.3 SCLK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.3.4 Internal setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
4.3.5 Command decoding . . . . . . . . . . . . . . . . . . . . . . . . . . 29
4.3.6 Sending and receiving data . . . . . . . . . . . . . . . . . . . . . . 30
4.4 ADC module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4.1 Module overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4.2 FSM diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4.3 XADC Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 32
4.4.4 Sampling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
4.5 Control module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.5.1 Module overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
4.5.2 FSM diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
4.5.3 Interrupt and its registers . . . . . . . . . . . . . . . . . . . . . . . 36
4.5.4 Reading EEPROM . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.5.5 Sample and write . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
4.5.6 Overall timing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37
5 PCB 39
5.1 Why a custom PCB? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.2 Proposal limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.3 FPGA Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4 Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.5 ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
5.6 Digital IO . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.7 Power Supply . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
5.8 Schematics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
5.9 Bill-Of-Materials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
III Results 55
6 Simulation 57
6.1 SPI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.1.1 Register R/W . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
6.1.2 EEPROM R/W . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59
6.2 XADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
6.3 System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
6.3.1 Reading registers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
6.3.2 Reading ROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
6.3.3 ADC sample . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
6.3.4 ROM write . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
6.3.5 ROM clear . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
7 Measurements 69
7.1 ADC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
iv
IV Conclusion 71
8 Discussion 73
8.1 Areas of improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.1.1 FPGA . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
8.1.2 PCB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.2 Possible applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
8.3 Future Work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
v
vi
List of Figures
vii
viii
List of Tables
ix
x
Preface
xi
xii
List of Abbreviations
xiii
SCLKSerial Clock, 195 kHz clock used by SPI
SMDSurface Mount Device, also written as SMT
SPI
Serial Peripheral Interface
TI
Texas Instruments
VCCPositive supply voltage, also VDD
VHDL VHSIC Hardware Description Language, one of the two main HDLs in
use, the other is Verilog
XML Extensible Markup Language
xiv
Part I
Introduction
1
Chapter 1
Goal: Evaluate an alternative to the ASIC design that is more flexible with shorter
redesign cycle but that is less compact and consumes more power.
Objective: Find suitable components, implement them on a test board and propose design
of implantable PCB.
3
4
Chapter 2
Background
2.1 Motivation
For many, including myself, working in a field where one could positively impact
people’s lives is a great motivator. The intended application of the system, namely
urinary bladder pressure sensors, has the potential to help over 220 000 people in
Norway alone [2]. The opportunity to work on something which could improve some
of their lives is fantastic.
Any new project involves learning new skills, whether we are aware of what they
are when we start or not. For me personally, learning something new about areas of
interest is always an opportunity I take advantage of. This project would expand my
horizons regarding hardware as well as software.
Small integrated devices have been rising in popularity in recent years, from Internet-
of-Things to medical implants saving people’s lives. The task of making the smallest
possible device is generally reserved for ASICs, having to achieve a similar result using
multiple off the shelf components makes the hardware choices for this project a non-
trivial task.
The software aspect was one of the most appealing as I enjoy the problem solving
skills required by programming languages, whether they are meant for traditional
computers, embedded systems or digital circuits. Deciding on a particular way of
solving a problem is difficult and always results in some kind of tradeoff, be it related
to code complexity (making further work more difficult) or performance.
5
power alone.
An embedded system based on MICS was presented in a paper by A. Tantin et al. in
[6]. In their work they develop a wireless system for monitoring bladder pressure, the
implant utilizing a MICS transceiver, microcontroller, two amplifiers and two sensor
probes. This system is also relying on a battery to supply power and it is the only
system utilizing FDA approved RF technologies.
2.3.1 NFC
NFC [7] is a set of short-range communication protocols, typically used for contactless
cards (such as payment, identity and keycards). A notable entity is the NFC Forum
non-profit association, it is responsible for setting up standards and certifying devices.
The NFC tag used in this project is NFC Forum Type 2 compliant, the carrier frequency
is 13.56 MHz with an expected bitrate of 106 kbps.
So why are we using NFC? Its first advantage over other solutions is security. The
very short communication range (a couple centimeters) compared to other protocols
such as MICS or Bluetooth (ranges measured in meters), makes unauthorized access
much more difficult, as the reader would have to be practically touching the NFC tag
to establish a connection.
Another advantage is its wide compatibility, something it shares with Bluetooth.
Most modern smartphones are capable of reading and writing NFC tags, making
them compatible with the system. MICS is typically only compatible with medical
equipment, making larger scale adoption more difficult.
A disadvantage is that while the 13.56 MHz carrier frequency is approved for use in
human implants, NFC’s viability in particular is unknown. Another issue stems from
its limited range which could make it challenging to find the right positioning in order
to establish a connection.
2.3.2 SPI
SPI [8] is a communication specification operating on a master-slave principle. That is
to say, there is one controlling device and one or more "slaves" or listeners. The slaves
cannot initiate communication themselves, they have to wait for the master to do so.
Multiple slaves are possible by using an SS line for each of them. They may all share
the same clock and data connections.
This is in contrast to another similar technology, I2C which uses addresses in order to
support multiple masters and slaves. SPI was chosen for this application because only
one slave is required (the AMS3955 NFC tag), making it easier to implement.
SPI requires 4 signal lines to function:
SCLK Serial Clock, clock provided by the master
MOSI Master Out Slave In, output data from the master
MISO Master In Slave Out, output data from the slave
6
SS Slave Select, active low signal provided by the master initiating communication
2.3.4 FPGA
FPGAs [10] are highly flexible integrated circuits intended to be reconfigured after
manufacture. The basic building blocks of FPGAs are look-up tables, flip-flops and
full-adders. Using VHDL or Verilog, an engineer can program the FPGA to form other
logic gates and more complex combinational logic in hardware. This ability makes FP-
GAs excellent for low-level applications where logic gate precision is required.
7
Further, it is possible to reprogram an FPGA as many times as required. A single chip
can change its configuration completely and there are emerging techniques to do this
without a complete restart (partial reconfiguration).
Due to this extreme flexibility, FPGAs have been on the radar for many industries
for years, however when compared to ASICs they are significantly slower (under 1
GHz while ASICs can exceed 5 or more) and larger in area while consuming more
power. In low quantities, FPGAs are orders of magnitude more affordable than ASICs,
but as the volume increases, the FPGA prices remain relatively constant while ASICs
drop to a couple of pennies in comparison.
FPGAs are therefore excellent for prototyping and low quantity projects, but if mass
production or lowest power consumption is required, ASICs remain the better choice.
The process of transforming HDL code into logic gates is called synthesis and is
done by a synthesis tool, for Xilinx FPGAs it is the Vivado software suite. After
synthesis there is another process called implementation, this is what determines how
the basic building blocks (LUTs, FFs) are used in order to form the logic gates dictated
by the code. During implementation, the tool decides which parts of the chip are used
and how, although this could be done manually if needed.
2.3.5 XADC
The XADC is a pair of 12 bit, up to 1 mega sample per second ADCs included with 7
series Xilinx FPGA’s (Spartan and higher, excluding XC7S6 and XC7S15). It is capable
of a variety of operations (such as temperature measurements) but we are mainly
interested in its ability to sample analog differential inputs using an event driven
model, that is, it remains idle until told to start a conversion.
The exact number of auxiliary inputs depends on the specific FPGA PCB used, the
XADC itself supports up to 16 different channels. For this project, only one of them
was used.
The output is a hexadecimal number between 0x000 and 0xFFF, corresponding to 0 V
and 1 V respectively. Voltage can be converted to a hex number with equation 2.1, the
voltage can be calculated back from the hexadecimal number by dividing it by 0xFFF.
Vin
FFFh = HEXin (2.1)
1.0
As an example, in figure 2.1b the value 0xB60 at address 0x0B corresponds to 0.7111 V.
2.3.6 Vivado
The Vivado software suite is being developed by Xilinx Inc. primarily for use with
their FPGAs. It includes an IDE, simulator and synthesis tool.
Its primary role is to generate the proprietary files used to program the FPGA, called
bitstreams. The included hardware manager can then program the FPGA via USB
using these bitstreams. It is also possible to generate binary files which can be flashed
to the SPI flash on the board, this is useful because the FPGA will then program itself
on start-up instead of needing to be programmed manually each time.
In addition, the software provides useful statistics such as resource utilization (how
8
many LUTs and FFs we’re using), timing information (whether a piece of code is
too slow) and estimated power consumption figures. The accuracy of the power
consumption figures are unknown, but they are the only way to get any information
about this when using a development board such as the Basys3.
9
2.4 Usage illustration
Figure 2.3 is an illustration of how the complete system might be used. The goal is to
develop a small enough device such that it can be implanted, enabling the use of an
NFC enabled mobile phone to read data from it. This thesis concerns itself with the
design and implementation of the implanted device.
Consider contacting
a professional
Bladder pressure
implant
!
10
Part II
The project
11
Chapter 3
Planning
13
3.1.2 Amplifier
The expected voltage swing of the pressure sensor is in the 100 mV range, however,
in order to reach the advertised accuracy of an ADC, one must use the entire input
range. Typically this is between ground and the supply voltage and so the input must
be amplified before going in to the ADC in order to maximize accuracy.
The amplifier must have differential input and tunable gain, a type of amplifier par-
ticularly well suited to this application are instrumentation amplifiers. [14] Standout
features are input buffers which eliminate the need for impedance matching.
An example of such an amplifier is Texas Instruments’ line of low power instrumen-
tation amplifiers, prefixed with INA. For example the INA317 [15] has programmable
gain, tuned by an external resistor, of up to 1000.
3.1.3 Microcontroller
A microcontroller is required because both the NFC tag and a potential dedicated ADC
chip can only operate as SPI slaves. Thankfully, many MCUs include an ADC so there
is no need to add another discrete component to the system, one would only have
to replace the ADC with an MCU. Microcontrollers are a diverse and broad type of
component, here are a couple of options that were narrowed down, both are TI parts.
• MSP430FR2000 Cheapest option, 0.5 kB RAM with a slope ADC. Claimed power
consumption 120 µA/MHz. [16]
• Able to write to the EEPROM using NFC, 472 bytes of user data
14
3.1.5 Component summary
All prices in table 3.1 are based on data from Mouser Electronics.
The ASIC project has run into difficulties regarding NFC power harvesting, the
figures given in AMS’ datasheet are best case scenarios with unspecified antenna
configurations. Actual current output is likely to be lower than the quoted 5 mA
figure (potentially significantly so) and must therefore be validated before we can state
whether or not the system can run battery-less.
15
3.1.6 AS3955 Demo Kit
Due to lack of experience in working with the NFC protocol, a demo kit for the
AMS 3955 NFC tag was acquired. The demo kit [18] is intended to demonstrate
the functionality of the NFC tag using a Windows program as well as an Android
application. It quickly became clear that the demo applications are too limited to
be of much use to this project. Fortunately, the source code used to program the
microcontroller (Microchip PIC24FJ128GB202 [19]) was included so the intention then
was to modify it such that it is able to read external analog input, convert it using the
integrated ADC and send it to the AS3955 via I2C or SPI.
16
that if something were to go wrong in the main function, causing it to stall or otherwise
break in some fashion, the USB part of the code would never load, rendering the MCU
impossible to reprogram via software.
During the early phases of experimentation, an attempt was made to assign one of the
unused pins to a variable. This seemingly harmless piece of code was added too early
in the main function, causing the exact problem described above. With no reply from
AMS support and no hardware reprogrammers on hand, the decision was made to use
something else that was, specifically an FPGA.
17
18
Chapter 4
Digital design
19
4.1 AS3955
The chip has two means of storing data, its internal registers and 472 bytes of EEPROM.
A register is a very fast, limited capacity volatile memory-like circuit typically
implemented using FFs. This makes them ideal for applications such as status
indicators or basic configuration. They are not used for data storage due to their lack
of capacity and volatility, meaning they will erase themselves after losing power. The
configuration registers are automatically loaded from the EEPROM during power-up.
The EEPROM is non-volatile and thus it is where all persistent data must be stored in.
Compared to the registers, its capacity is much higher but it suffers from slow read
and write speeds, as well as having limited rewrite counts (the EEPROM eventually
becomes unusable after being overwritten too many times). After a write command,
once SS goes high we must wait a minimum settling time of 8.3 ms and maximum of
9.5 ms, as per the datasheet ([17, p. 77]).
In addition to the registers and EEPROM, there is also a 32 byte buffer available which
behaves the same as register operations (no delay after writing). Its contents might not
be predictable (other internal operations of the chip might write data to it), so it has
not been explicitly used for this project.
The list of all registers is shown in table 4.1, while the list of EEPROM blocks (a block
is comprised of 4 bytes) is shown in table 4.2.
20
Address [hex] Description Access
00 IO config RW
01 IC config 0 RO/RW
02 IC config 1 RO
03 IC config 2 RO/RW
04 RFID status RO
05 IC status RO
08 Mask interrupt 0 RW
09 Mask interrupt 1 RW
0A Interrupt 0 RO
0B Interrupt 1 RO
0C Buffer status 2 RO
0D Buffer status 1 RO
0E Last NFC address RO
1E Major version RO
1F Minor version RO
21
4.1.3 Commands
Table 4.3 shows the commands that were implemented, following the specification
from [Fig. 55 17, p. 60] in the datasheet. All commands start with 3 bits indicating
what the operation we are about to perform is.
For register operations the next 5 bits are the address, after which we will either send
or receive 8 bits of data. All register operations must therefore complete in 16 clock
cycles.
For EEPROM operations we send the 3 command bits as usual, but this time they are
followed by 5 copies of the LSB (five zeroes for writes and five ones for reads). The
EPPROM is much larger than the registers, so its addresses are 7 bits wide.
Note that SPI is expected to work in byte sized chunks, that is, 8 bits at a time. As a
result of this, the 7 bit address is padded with an extra 0 at the end in order to complete
a byte.
Following the 2 bytes we’ve sent now, we will either have to send an additional 4
bytes with the data to be written or start reading 4 bytes, depending on the requested
operation. All EEPROM operations must complete in 48 clock cycles.
22
Interrupt register 0 structure is shown in table 4.4, based on [Fig. 92 17, p. 85] in
the datasheet. Of particular interest is bit 4 which is triggered when the EEPROM has
been written to through RF, such as by an NFC enabled mobile phone.
Some of the other bits could prove useful for catching potential errors during
operation, for example one would expect bit 2 to be set after we write something to
the tag, if it is not, that would indicate a failure in the system that should be handled
(for example by retrying the operation). Such measures have not been implemented as
they were deemed unnecessary.
Interrupt register 1 structure is shown in table 4.5, based on [Fig. 93 17, pp. 85, 86]
in the datasheet. This register is read but none of the values are used.
Figure 4.1 is a top level overview of the entire system. Outside of the FPGA, every
block is a dedicated component, and on the inside they are separate modules. There
is a section dedicated to each of the FPGA’s modules following this one, only a brief
description of each will be given here.
Starting with the main control module (labelled CTRL module), its job is to wait for
interrupts from the AS3955 and send the appropriate commands over internal buses to
the SPI and ADC CTRL modules. Depending on the data received from the NFC tag,
the control module will now send an enable pulse to the ADC controller and wait for
its response. Finally, the data from the ADC is sent to the SPI module to be written to
the NFC tag, making it available to other devices.
The SPI module sends the data on its input buses serially over SPI, it automatically
adjusts between the various commands described in AS3955 section 4.1.3.
The ADC control module sends the conversion start pulse, waits for EOC and places
the relevant 12 bit result on the DOUT bus.
The XADC module is proprietary Xilinx IP, it is automatically generated by Vivado. Its
inputs are external analog connections, with the possibility for differential input.
23
Implant
FPGA
IRQ
EN
SCLK SCLK
MOSI DOUT32
SPI / CTRL
AS3955 SS
/
3 CMD
MISO module 7 ADR
module
/
32 DIN
/
EN
12
/
DOUT
DONE
CONV
DEN
VAUXP EOC
Pressure DRDY ADC CTRL
XADC BUSY
sensor VAUXN module
DOUT 16
/
7 ADR
/
24
4.2.1 Decision diagram
Figure 4.2 shows the basic decisions taken by the control module and by extension, the
entire system.
At idle, we are simply waiting for the IRQ line to go high, once it does both interrupt
registers are read. If bit 4 in register 0 (I_eew_rf, indicating the EEPROM has been
written to) was set, then we proceed by reading a dedicated "command" address in the
EEPROM. This is done so that the user can still write something else to the EEPROM
without triggering a conversion. If any of these steps fail, either by not detecting an
EEPROM write or detecting that something unexpected was written, we go back to
idle and wait for the next interrupt.
If they both succeed, a sample is taken, the result is written to a set EEPROM address
and finally the command address is zeroed out. The clear operation is done to ensure
that we only perform one sample per request.
Wait
interrupt
No
EEPROM
written to?
Clear
Yes command
No
address in
EEPROM
Conversion
request?
Yes
ADC Write
sample result to
EEPROM
25
4.3 SPI module
4.3.1 Module overview
Figure 4.3 shows all the connections related to the SPI module.
Description of module inputs (right arrows) and outputs (left arrows):
↔ AS3955 I/O Described previously in sections about SPI 2.3.2 and the tag’s
interrupt registers 4.1.4
CLK
EN
SCLK
SS
SCLK 3 CMD
SS /
SPI CTRL
AS3955 MOSI
ADR
MISO module 7
/ module
32 DIN
/
DOUT 32
/
IRQ
26
4.3.2 FSM diagram
Figure 4.4 shows the possible states of the SPI module. Any state which involves
data transmission takes more than one SCLK cycle to complete, this is represented by
"counter" in the figure. Its initial value depends on the operation, it can be 8 (register
command and data), 16 (EEPROM command) or 32 (EEPROM data).
en=0
Idle
counter=0
en=1
counter=0
Decode
cmd
counter>0 counter>0
counter>0
4.3.3 SCLK
The SPI module generates the serial clock (SCLK) using a simple clock divider. The
generating process is running off of the FPGA master clock (100 MHz) and inverts
SCLK every 256th rising edge, the resulting frequency for SCLK is approximately 195
kHz (a period of 5.12 µs). This frequency was arbitrarily chosen, the most important
requirement is that it adheres to the NFC tag’s specification (100 kHz - 5 MHz).
One must also take note of the EEPROM read specification which dictates a minimum
of 1 µs SCLK period, and since we are reading from the EEPROM, the practical
frequency range is between 100 kHz and 1 MHz. Another consideration is that the
control module also uses SCLK for its internal clock divider, that must also be modified
should SCLK change its period.
27
4.3.4 Internal setup
The module’s operation is based on two 32 bit shift registers and two corresponding
counters. A shift register is analogous to a stream of bits, inserting a bit in one end leads
to another bit "falling out" the other, this behaviour makes them suitable for sending
or receiving serial data.
When writing data, a 0 is inserted as the LSB, the MSB pops out and is placed on the
output line (MOSI). By repeating this process n times for n bits, we would have serially
sent all the data. A step by step example of a 4 bit shift register is shown in figure 4.5
below, suppose the output data is 1011.
When reading data, the incoming bit is inserted into the LSB instead of a 0, the MSB
popping out is discarded. Step by step example of a 4 bit shift register reading data is
shown in figure 4.6, suppose the input data is 1010.
This architecture allows for total flexibility when it comes to the number of bits in
any given operation, however one must account for the difference in bit orders be-
tween sending and receiving. Sending starts from the MSB going down, while reading
starts from the LSB going up, as a direct result of this, the bits we wish to send have to
start from the MSB, while if we received less than maximum, we must read them from
the LSB.
This fact is reflected in the design when looking at how register and EEPROM op-
erations differ, register data to be sent is placed as the 8 MSBs of the data in bus (in/out
refer to the direction in reference to other FPGA modules, data in to the SPI module,
going out serially via SPI), while data that has been read is placed as the 8 LSBs of the
32 bit data out (serial data coming in from the tag) bus.
To keep track of the number of bits we should be expecting, two separate counters are
used that are set during command decoding.
The drawback is that we are using more resources in the FPGA, however even the
smallest FPGAs should easily fit two 32 bit registers together with their respective
counters. A possible optimization is to use one 8 bit shift register (both for sending
and receiving), this would increase FSM complexity slightly as we would have to keep
track of which byte we are dealing with, i.e when receiving 32 bits we’d have to know
when byte 1 ended and when byte 2 started.
28
4.3.5 Command decoding
The first step after an enable pulse is to determine whether the operation requires 8 or
32 bits. If the middle CMD bit is 1, then we are dealing with 32 bit EEPROM data and
if it is 0 we have to adjust for 8 bit data (refer to table 4.1.3 for specifics about what each
bit means).
For register R/W, preparation is simple, we only have to concatenate the 3 command
bits with 5 address bits (assumed to be placed as LSBs in the 7-bit wide ADR data bus).
The counter here is set to 8.
Tables 4.7 and 4.6 show more clearly where the bits are placed in the shift register.
Intervals such as B28-B24 mean that all bits between 28 and 24 (5 total) are the same
value, 1 for reading and 0 for writing.
Once the counter and shift registers are set up, the only thing left to do is to repeat the
shift process as many times as the counter dictates. Upon sending the command and
address information, we are ready to send or receive data.
29
4.3.6 Sending and receiving data
Now we must prepare the shift registers again, for EEPROM commands the counter
will always be 32 and for register commands it will be 8.
If we are receiving, the receive shift register is zeroed out and we can start putting data
in as it comes every falling edge of SCLK.
If we are sending, the send shift register is set to the value on the DIN bus. It is assumed
that the data is placed correctly (i.e <32 bit data is placed as the MSBs).
Figure 4.7 illustrates the difference between sending and receiving, mainly that data
is to be placed on the MOSI line every rising edge of the clock, while it is read at the
falling edge, the same principle applies when the FPGA is reading from the tag.
30
4.4 ADC module
4.4.1 Module overview
Figure 4.8 shows the ADC CTRL module’s inputs and outputs, refer to figure 4.1 for
a complete system overview. The module acts as an abstraction layer for the CTRL
module to more easily sample data. Description of module inputs (right arrows) and
outputs (left arrows):
→ CLK FPGA master clock, used to clock the XADC as well as the control FSM
→ EN Global module enable signal, can be continuously high, at which point it will
perform back to back conversions
→ DRDY Data ready, indicates when the conversion data is ready to be read from
the ADC’s data bus
→ EOC End Of Conversion, goes high for one clock cycle once conversion is
finished
← DEN Data enable, has to be pulsed in order for the ADC’s data bus to be enabled
← CONVST Conversion start, should be held high for one clock cycle in order to
initialize a conversion
CLK ADC-DONE
ADC
EN CTRL / ADC-OUT
12
/ /
16
7
BUSY
DRDY
EOC
DCLK
DEN
CONVST
DOUT
DADR
31
4.4.2 FSM diagram
EN=0 or BUSY
Read
Idle
data
EN=1 DRDY=1
Pulse DRDY
DRDY=0
convst wait
EOC=0
The ADC control module is responsible for instantiating and controlling the XADC.
Technical details of its setup can be found in UG480 [20]. A brief description will be
provided here.
In order to utilize the XADC, Vivado provides an IP wizard which generates the
module for us.
32
Option name Configuration
Interface DRP
Startup channel Single channel
AXI4STREAM Disabled
DCLK freq. 100 MHz
ADC conversion rate 50 KSPS
Timing mode Event
Event trigger convst_in
Alarms Off
Channel VAUXP6 VAUXN6
Sequencer Off
Averaging Off
With a configuration like in table 4.8, the result of a conversion is read from the
XADC’s status registers. Channel 0 starts at address 0x10 and since we have chosen
channel 6, its results are stored at address 0x16 (table and figure 3-1 in UG480). We are
only interested in the 12 MSBs, the rest of the data is invalid.
As we are only reading one channel/register, the XADC’s DADR input is kept constant
at 0x16 by the ADC control module.
4.4.4 Sampling
In the idle state, we wait for EN to go high, while BUSY has to be low (there is no point
in trying to start a conversion if the ADC is busy). If both requirements are met, we
enter the Pulse convst state which pulls CONVST up and immediately goes to the
next state.
EOC wait pulls CONVST back down (it is important that it is kept high for only one
clock cycle) and waits for EOC from the XADC to go high. Once it does, the same
process is repeated but with DEN and DRDY instead of CONVST and EOC.
In the final state, the 12 MSBs from DOUT are placed on ADC-OUT and ADC-DONE
goes high for one clock before it is reset upon entering the idle state.
33
4.5 Control module
4.5.1 Module overview
Figure 4.1 shows how the control module is connected to the other modules of the
system, while figure 4.10 shows all its inputs (left) and outputs (right), but does not
include their source or destination.
Short description of inputs (right arrow) and outputs (left arrow):
CLK SPI-EN
EN
SCLK
SS ADC-EN
IRQ
ADC-DONE
CTRL
/ CMD
module 3
ADC-OUT / / ADR
12 7
DOUT / / DIN
32 32
34
4.5.2 FSM diagram
Figure 4.11 is a lower level illustration of the control module’s states, complementing
figure 4.2. Essentially all states of this module require multiple clock cycles, the only
exceptions being the two decision states (check ir0 and check data). The FSM is
clocked at 100 MHz, this is dictated by the XADC’s enable and ready signals.
SS=0
t<20ms t<20ms
ms
20
t≥
SS=0
SS=0
Write en=0 or irq=0 Read
EEPROM =1 ir0
q
1,ir
en=
EOC=1
SS=1
Idle
EOC=0
SS=0
Sample Read
ir1
t
es
No
u
req
wr
Request
SS=1
No
ite
SS=0
35
4.5.3 Interrupt and its registers
Once an interrupt is received, we must read both of the AS3955’s interrupt registers.
The control module uses the falling edge of SS to determine when data transmission
has started and the rising edge for transmission end. Each of the register reads takes
16 SCLK cycles.
The results are stored in two internal 8 bit buffers, the content of the first interrupt
register is checked to see whether or not the EEPROM was written to over NFC, more
specifically, it checks whether bit 4 (I_eew_rf) is set or not. If it is, we can proceed to
the next step, reading the EEPROM to check for a request. If it is not, we return to idle
and wait for the next interrupt.
This architecture allows the system to be easily expanded to enable checking of other
bits in either register, such as parity checks, verifying the outcome of commands and
more.
It is important to restate that reading both registers is crucial, even though we are only
interested in one of the 16 total bits. Failure to read both will result in the IRQ input
remaining high indefinitely, defeating the purpose of an event driven model.
36
4.5.6 Overall timing
Excluding timeouts, the overwhelming majority of the time is spent on waiting for SPI
commands to complete. In order, a complete sample request performs the following
operations:
The total number of SCLK cycles required is 180, however this excludes the two 21 ms
delays after writes.
OP Cycles Time
SCLK us
Reg RW 16 81.92
ROM RW 48 245.76
ADC 3.3 16.8
Total 180 918
Table 4.9 summarizes how long each operation takes. Notice how the total "active"
time is under 1 ms, while the waiting period is 42 ms total. Effectively then, a request
is completed in just under 43 ms, with the potential to be cut in half. The application
has very loose timing requirements, it is expected to be under one per second so even
at 43 ms it is much faster than necessary.
37
38
Chapter 5
PCB
39
There are smaller commercially available FPGA boards, one such example is
the Digilent Cmod S7 [21] which is 1.8x7.7 cm but this is also too large. Another
consideration is the fact that commercially available boards would have to be
connected to an NFC tag externally (using wires).
40
5.4 Configuration
The FPGA requires some kind of flash memory so that it can reprogram itself on power-
up, this is most easily done with an SPI NOR flash chip such as the Cypress S25FL032P
[26]. The important characteristics are that it can run on the main 3.3 V supply and the
8-pin SO package is small (5x8mm).
In addition, the board requires an external way of reprogramming the FPGA and/or
the SPI flash. The Basys3 and Cmod S7 have USB controllers as well as JTAG
connections, neither of these features are included in this proposal.
The schematic for the configuration bank is found in figure 5.2.
5.5 ADC
The ADC requires at least two auxiliary inputs as it is capable of differential input. An
extra pair of inputs was wired out in case they would be needed. The differential pairs
are filtered and output to a 6-pin female header. This could be improved by removing
the extra pair and soldering the inputs directly to the source, using headers is likely to
introduce noticeable noise in the system.
In addition to the inputs, it requires filtering for its VCC and GND connections. This is
done using two 600Ω ferrite chokes, but as seen later in section 7.1, a separate power
supply and more filtering is required to achieve 12 bit accuracy. The schematic for the
XADC inputs is found in figure 5.3.
41
5.6 Digital IO
Bank 14 was chosen for use with digital signals. The SPI flash, AS3955 and 100 MHz
clock generator are connected to various pins on it.
The SPI flash is connected to dedicated pins as described by the 7 series pinout
specification. [25]
The AS3955 is connected in a similar fashion as it is on the prototype implementation
using the Basys3 demo board, available pins from bank 14 were chosen and connected
to the tag.
The FPGA master clock is also going into bank 14, it is generated by a Microchip
DSC1033 [27]. Any 3.3 V 100 MHz oscillator can be used.
Pin Function
P14 CLK
K14 SS
J15 SCLK
K15 MOSI
L13 MISO
M13 IRQ
C6 AD0P
C7 AD0N
D7 AD8P
D8 AD8N
Table 5.1 is an overview of the main pins one must take care of when writing a
constraints file for this board. The schematic for the digital IO is found in figure 5.4.
42
5.7 Power Supply
The FPGA requires the following voltages in order to function: 1.0 V, 1.8 V and 3.3 V.
These voltages have to be generated from a 5 V input, this is taken care of by
two Analog Devices regulators, a LTC3621 [28] and a LTC3633 [29]. The former is
configured for 1.8 V and the latter 1.0 V and 3.3 V.
Both of these parts are relatively old, there is potential to replace them with a single
three channel regulator instead.
The schematic for the power supply is found in figure 5.5.
43
44
5.8 Schematics
45
Figure 5.3: Bank 15, used for analog inputs. 332-06 is a female 6 pin header.
46
Figure 5.4: Bank 14 with its connections to the AS3955 and main clock generator
47
Figure 5.5: Power supplies
48
Figure 5.6: Board layout, dimensions are in mm
49
5.9 Bill-Of-Materials
50
CC0201KRX5R5BB104 6 0.52 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 100nF 6.3V
X5R 10%
C0201C104K9PAC 2 0.33 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 6.3V 0.1uF
10% X5R
C0201C103K4PACTU 2 0.28 Multilayer Ceramic
Capacitors MLCC
- SMD/SMT 16V
10000pF X5R 10%
ZRB15XC80J106ME05D 1 0.419 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 6.3V 10uF
CBR02C130F3GAC 1 0.367 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 25V 13pF
C0G 0201 1%
GRM033R71C161JA01D 1 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 160UF 16V
5% 0201
GRM0335C1H181JA01D 1 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 0201 180pF
50volts C0G 5%
GCM0335C1H180FA16D 1 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 50V 18pF
GRM0335C1E102GA01D 2 0.122 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 25V 1000pF
GRM033R61A105ME15J 1 0.367 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 10V 1uF
GRM033R61A225KE47J 4 0.94 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 2.2UF 10V
10% 0201
UMK063BJ222KP-F 1 0.114 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 2200pF 50V
X5R 10% 0201
51
C0402C223K5RECAUTO 1 0.14 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 50V 0.022uF
X7R 0402 10% AEC-
Q200
GRM033R71E472KE14D 1 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 0201 4700pF
25volts X7R 10%
GRM0335C1E471JA01D 1 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 0201 470pF
25volts C0G 5%
CC0402KRX7R6BB472 3 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 4700pF 10%
10V MLCC
CGA1A2C0G1E560J030BA 2 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT CGA 0201
25V 56pF C0G 5%
AEC-Q200
GJM0335C1H6R2BB01J 2 0.192 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 50V 6.2pF
GRM0335C1E620GA01D 1 0.087 Multilayer Ceramic
Capacitors MLCC -
SMD/SMT 0201 62pF
25volts C0G +/-2%
NR5040T1R5N 1 0.38 Fixed Inductors 5040
1.5uH 26mOhms +/-
30%Tol 3.6A HiCur
NR5040T2R2N 1 0.376 Fixed Inductors 5040
2.2uH 28.6mOhms
+/-30%Tol 3.5A HiCur
NR4018T3R3M 1 0.393 Fixed Inductors 4018
3.3uH 84mOhms +/-
20% 1230mA LwPrfl
419-10-206-00-006000 1 3.78 Pin & Socket Connec- ADC input pins
tors .100" 6P 2R SPRING
MATE W/.042" PLNGR
BLM31KN601SH1L 2 0.5 Ferrite Beads 1206
600ohms 2.9A
AECQ200 Pwrtrain/Saf
AS3955A-ATDM-S4 1 2.14 RFID Transponders
AS3955A-ATDM-S4
MLPD10 LF T&RDP
52
DSC1033DI1-100.0000T 1 1.66 Standard Clock Oscilla- 100MHz clock
tors MEMS Oscillator, generator
3.3V, -40C-85C, 50ppm
FDV301N 3 0.79 MOSFET N-Ch Digital
LTC3621IMS8E 1 5.94 Switching Voltage Reg- 1.8V regulator
ulators 17V, 1A, 1MHz
Synchronous Step-
Down Regulator with
Ultralow Quiescent
Current
LTC3633AEFE 1 9.3 Switching Voltage Reg- 1V and 3.3V regu-
ulators Dual 3A, 20Vin, lator
4MHz, Monolithic Syn-
chronous Step-Down
Regulator
319-10-102-00-006000 1 3.17 Pin & Socket Connec- 2pin header for
tors .100" 2P 1R SPRING 5V/GND
MATE W/.042" PLNGR
S25FL032P0XMFA013 1 3.18 NOR Flash
122-2121-ND 1 31.06 Xilinx XC7S25- DigiKey
2CSGA225C FPGA
All prices in Euros, components are sourced from Mouser Electronics, with the
exception of the FPGA which is from Digikey.
Some components are only available in bulk (10 000 or more), it is advisable to change
their packaging from 0201 to 0402 in order to use cheaper parts available for purchase
in lower volumes.
53
54
Part III
Results
55
Chapter 6
Simulation
The main clock frequency for all simulations is 100 MHz (clock period of 10 ns). The
resulting SCLK frequency is 195.3 kHz (5.12 µs).
Major milestones are annotated on the figures, as well as writing the binary value that
is being sent or received. When interpreting these graphs, it is important to recall that
data is always being read at the falling edge of SCLK.
Whenever the FPGA is sending data, MOSI is what’s being read (by the tag) and when
it is receiving data, we are interested in MISO.
Hexadecimal equivalents of each section are included, notice how the data buses match
the serial data.
6.1 SPI
This section presents simulation results from the SPI module.
57
CMD 0x0 Address 0x1 Sending data 0xAC
0 0 0 0 0 0 0 1 1 0 1 0 1 1 0 0
0 0 1 0 0 0 0 1 0 0 0 1 1 0 1 0
58
6.1.2 EEPROM R/W
These operations require the MODE byte and additional address byte before the data
can be read or written. Note that the NFC tag only reads the 7 MSBs of the address
byte, this is why it is written in parenthesis on the plots (it is ignored).
The command phase then lasts 16 SCLK cycles, after which data is sent or received for
the next 32 cycles.
A complete operation takes exactly 48 SCLK (245.76 µs).
These simulations also use randomly generated MISO.
Example EEPROM read/write operations are shown in figure 6.3.
59
CMD 0x2 Trailer 0x00 Address 0x01 Send byte 1 0xAC Send byte 2 0x0A Send byte 3 0x0C Send byte 4 0x0A
0 1 0 0 0 0 0 0 0 0 0 0 0 0 1 (0) 1 0 1 0 1 1 0 0 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 1 0 1 0
60
CMD 0x3 Trailer 0x1F Address 0x01 Read byte 1 0xC6 Read byte 2 0x16 Read byte 3 0x56 Read byte 4 0x2B
0 1 1 1 1 1 1 1 0 0 0 0 0 0 1 (0) 1 1 0 0 0 1 1 0 0 0 0 1 0 1 1 0 0 1 0 1 0 1 1 0 0 0 1 0 1 0 1 1
16610 16630 16650 16670 16690 16710 16730 16750 16770 16790 16810 16830 16850 16870 16890 16910 16930
The XADC has special functionality
idle
available when we’re simulating, namely
800
the capability read a text file containing done_wait
analog data at various times. This allows read_drp
us to still get data out of the ADC when it
is being simulated.
The period where the ADC is working was
cut out because nothing is happening while
BUSY is high. wait_drp
start_drp
A single conversion takes 16.8001 µs (1680
CLK cycles or 3.3 SCLK cycles).
The result for this simulation run was
0x800 (as can be seen on the DOUT bus at
the end).
Time [ns]
10 20 30 40 50 60 70 80 90 100110
wait_eoc
start_conv
STATE idle
DOUT X
EN
CLK
CONVST
BUSY
EOC
DRDY
61
6.3 System
If we wish to simulate the entire system, we must also simulate the NFC tag’s
responses. For this purpose, a simplified NFC tag model was written. An FSM, much
like the one for the SPI controller, is used to read MOSI every falling edge of SCLK
and respond to SPI commands as the NFC tag would, i.e by setting MISO 1 or 0 at the
rising edge of SCLK.
This extra module includes 4 internal registers, two 8 bit registers for each of the
interrupt registers (set to 0x10 and 0x1F respectively) and two 32 bit registers for
EEPROM address 0x0A and 0x0B. The module has no additional connections, its only
inputs and outputs are the 4 SPI lines, exactly like the AS3955.
A change in the code was made for aesthetic purposes in order to reduce the write
delay from 21 ms down to a couple microseconds, the delay is only needed for the
real hardware to function and serves no purpose when demonstrating functionality
through simulation.
Figure 6.10 shows the entire system operation in one plot, there are also figures for
each major stage (register read, ROM read, ADC sample and ROM writes).
One might notice that not all states described in previous sections are visible in the
following plots, this is because the FSM’s are clocked at 100 MHz while SPI operates
over 500 times slower, at 195 kHz. An aesthetic decision was made to exclude these
states from the plots, only the most recent state within approximately 10 µs is shown.
The result is that instead of going from "Read ir1" to "Check ir0" and finally to "Read
EEPROM", it goes straight from waiting for SPI to finish reading ir1 ("Read ir1" in FSM
diagram 4.11 and "wait_irq1" on simulation plot) to preparing to read the EEPROM.
62
6.3.1 Reading registers
In figure 6.5 both interrupt reg-
isters are read.
After this, bit 4 of register 0 is
1
checked and if it is 1 then we pro-
1
ceed to read from EEPROM ad-
1
dress 0A.
0 0 0 1 1
Data byte in 0x1F
For this simulation, bit 4 will al-
ways be 1. Note that even if it was
not, we would read the second in-
terrupt register before going back
1
to idle.
Address 0x0B
0 1 0 1
0 0 1
CMD
Short timeout
0 0 0 1 0 0
0
0
Data byte in 0x10
0
Address 0x0A
0 1 0 1
0 0 1
CMD
63
6.3.2 Reading ROM
In figure 6.6 the EEPROM is
read and the LSB is checked.
0 1 0 1 0 1 0 1
Note how in this example, address
0x0A has 0101 in it, but as long
Byte 4 0x55
as the LSB is 1, it will continue
performing a single conversion.
Again notice how several states
0 1 0 1 0 1 0 1
are missing, it is going straight
from waiting for SPI to finish to
waiting for the ADC to finish,
Byte 3 0x55
this is because the ADC’s state
transitions typically occur every
10 nanoseconds, the scale of the 0 1 0 1 0 1 0 1
64
6.3.3
ADC sample
SCLK
65
SS
MOSI
MISO
DRDY
BUSY
EOC
CMD 3 2
ADR A B
DIN 0 8F5
DOUT 1F 55555555
1 0 1
Note that after this write, we typ-
ically wait 20 ms before the next
1 1 1 1 0
step.
Byte 4 0xF5
Notice how the fake NFC tag’s
ROM data at address 0x0B has
changed to match ADC_OUT, both
0 0 0
are now 0x8F5, remember that we
only take the 12 MSBs from the
0 0 0 0 1
ADC’s output.
Byte 3 0x08
0 0 0
0 0 0 0 0
Byte 2 0x00
0 0 0
0 0 0 0 0
Byte 1 0x00
1 1 (0)
0 0 0 1 0
Address 0x0B
0 0 0 0 0
Trailer
0 1 0
CMD
66
6.3.5 ROM clear
In figure 6.9 we are writing all
zeroes to address 0A. Another 20
0 0 0
ms waiting period would typically
follow this step.
0 0 0 0 0
Notice how the tag’s data at ad-
Byte 4 0x00
dress 0x0A has now changed from
0x55555555 to all zeroes.
After this step we go back to idle
0 0 0
and wait for another interrupt to
repeat the process.
0 0 0 0 0
If this simulation were to continue
Byte 3 0x00
as is, it would return to idle after
reading EEPROM, the only way to
perform another conversion is to
0 0 0
67
Read EEPROM address 0x0A
Read IR0 Read IR1 Data in 0x55555555 ADC Write 0x8F5 to EEPROM address 0x0B Write 32 0's to EEPROM address 0x0A
68
Figure 6.10: Complete simulation
Chapter 7
Measurements
7.1 ADC
Basic measurements were taken in order to validate the XADC’s performance. A
multimeter was used to measure the input voltage at the FPGA’s input pins, the voltage
was set using a potentiometer placed between 3.3 V and ground, the input voltage was
stable within 0.1 mV according to the multimeter.
The display on the Basys3 was used to output the raw data coming out of the ADC
in hexadecimal. Steps of 100 mV were used with extra points at the minimum and
maximum measurable values. Only the minimum and maximum value at each step
was recorded due to the output on the display changing every sample.
The theoretical value is calculated by using formula 2.1.
Rather surprisingly, the raw data had lower accuracy than expected with an error
averaging 0x6 (1.465 mV). A 12 bit ADC is expected to have an accuracy of 0.244 mV
(7.1), but these measurements are between a 9 (7.3) and 10 bit ADC (7.2).
The reason for this error is unknown, although the Xilinx ADC documentation [20,
p. 77] talks about PCB design decisions to achieve full 12 bit accuracy. The Basys3
schematics do not seem to include some of these measures, this would explain at least
some of the accuracy losses.
1000
= 0.244 mV (7.1)
212
1000
= 0.976 mV (7.2)
210
1000
= 1.953 mV (7.3)
29
69
Vin Theoretical Min Max Avg
[mV] [hex] [hex] [hex] [hex]
0.10 000 006 009 007
2.30 009 00F 011 010
100.10 199 19E 1A2 1A0
200.60 335 33C 340 33E
300.00 4CC 4D0 4D5 4D2
400.20 666 66E 671 66F
499.20 7FC 803 809 806
600.60 99B 9A2 9A9 9A5
699.80 B31 B37 B3F B3B
800.00 CCC CD1 CD9 CD5
901.20 E6A E74 E7A E77
994.50 FE8 FF4 FFF FF9
FF9
E77
CD5
B3B
9A5
806
66F
4D2
33E
1A0
007
0.0001 0.1001 0.2006 0.3000 0.4002 0.4992 0.6006 0.6998 0.8000 0.9012 0.9945
70
Part IV
Conclusion
71
Chapter 8
Discussion
73
8.1.2 PCB
The PCB design needs a significant amount of work before it can be printed and tested.
• Board layout uses many layers and has unrealistic design rules set
• Some passive components with high values are better suited to larger packages,
such as 0201 to 0402
Investigate other protocols, one example is Bluetooth. There are presently two main
issues with such an implementation, it is not legally implantable and it uses drastically
more power. There are also security concerns as Bluetooth has much longer range than
NFC, potentially leading to unauthorized access. That is not to say that it is not worth
investigating. Bluetooth, like NFC, is a universal standard now included in all modern
mobile phones. The range can also be an advantage as it increases convenience and
ease of use due to not having to find a precise spot to place the reader at. An embedded
system based on Bluetooth is being investigated as of this writing.
74
Bibliography
[1] Forskningsrådet. (2015). Novel health services using implantable sensors con-
nected to wireless applications, [Online]. Available: https://www.forskningsradet.
no/prosjektbanken/#/project/NFR/248001/Sprak=en.
[2] SINTEF. (2014). Lifesaving sensor for full bladders, [Online]. Available: https :
//www.sintef.no/en/latest-news/lifesaving-sensor-for-full-bladders/.
[3] A. Zaher, “Introducing nfc for in-body and on-body medical sensors,” PhD
thesis, Faculty of Mathematics and Natural Sciences, University of Oslo, 2016.
[4] A. Zaher, J. Saersten, T. T. Nguyen, and P. Häfliger, “Integrated electronic system
for implantable sensory nfc tag,” in 2015 37th Annual International Conference of
the IEEE Engineering in Medicine and Biology Society (EMBC), Aug. 2015, pp. 7119–
7122. DOI: 10.1109/EMBC.2015.7320033.
[5] J. D. Særsten, “Single asic nfc sensor tag,” Master’s thesis, Department of Physics,
UiO, 2016.
[6] A. Tantin, A. Letourneau, M. Zgaren, S. Hached, I. Clausen, and M. Sawan,
“Implantable mics-based wireless solution for bladder pressure monitoring,” in
2017 IEEE Biomedical Circuits and Systems Conference (BioCAS), Oct. 2017, pp. 1–4.
DOI : 10.1109/BIOCAS.2017.8325205.
75
[15] T. Instruments, Ina317, Micro-power(50-µa), zero-drift, rail-to-rail-out instrumenta-
tion amplifier, 2017. [Online]. Available: http://www.ti.com/lit/ds/sbos896/sbos896.
pdf.
[16] ——, Msp430fr2000, Msp430fr21xx, msp430fr2000 mixed-signal microcontrollers,
2018. [Online]. Available: http://www.ti.com/lit/ds/symlink/msp430fr2111.pdf.
[17] A. ( M. Systeme), As3955, Nfc forum compliant dynamic tag, version 2.04, 2018.
[Online]. Available: https : / / ams . com / documents / 20143 / 36005 / AS3955 _
DS000400_6-00.pdf/4eed4b57-8384-9bbb-34d4-3e1125f7480f.
[18] ——, As3955, Standard board, version 1.00, 2015. [Online]. Available: https://eu.
mouser.com/ds/2/588/AS3955%20AN01%20v1.02-837703.pdf.
[19] Microchip, Pic24fj128gb204 family, 28/44-pin, general purpose, 16-bit flash micro-
controllers with cryptographic engine, iso 7816, usb on-the-go and xlp technology,
2014. [Online]. Available: http : / / cdn - reichelt . de / documents / datenblatt / A300 /
PIC24FJ128GB202_DS.pdf.
[20] Xilinx, 7 series fpgas and zynq-7000 soc xadc dual 12-bit 1 msps analog-to-digital
converter, User guide, 2018. [Online]. Available: https://www.xilinx.com/support/
documentation/user_guides/ug480_7Series_XADC.pdf.
[21] Digilent. (2018). Cmod s7 reference manual, [Online]. Available: https://reference.
digilentinc.com/reference/programmable-logic/cmod-s7/reference-manual.
[22] ——, Cmod s7 schematics, 2018. [Online]. Available: https : / / s3 - us - west - 2 .
amazonaws.com/digilent/resources/programmable- logic/cmod- s7/Cmod+S7_sch-
public.pdf.
[23] ——, Basys3 schematics, 2014. [Online]. Available: https://reference.digilentinc.com/
_media/basys3:basys3_sch.pdf.
[24] Xilinx, Cost-optimized portfolio, Product tables and product selection guide, 2018.
[Online]. Available: https : / / www . xilinx . com / support / documentation / selection -
guides/cost-optimized-product-selection-guide.pdf.
[25] ——, 7 series fpgas packaging and pinout, 2018. [Online]. Available: https://www.
xilinx.com/support/documentation/user_guides/ug475_7Series_Pkg_Pinout.pdf.
[26] Cypress, S25fl032p, 32-mbit 3.0 v flash memory, 2017. [Online]. Available: https :
//www.cypress.com/file/196861/download.
[27] Microchip, Low-power cmos oscillator, 2009. [Online]. Available: http : / /
ww1 . microchip . com / downloads / en / DeviceDoc / DSC1033 % 20Datasheet %
20MKQBPD0318091-7.pdf.
[28] A. Devices, 17v, 1a synchronous step-down regulator with 3.5µa quiescent current,
2013. [Online]. Available: https : / / www . analog . com / media / en / technical -
documentation/data-sheets/3621fc.pdf.
[29] ——, Dual channel 3a, 15v monolithic synchronous step-down regulator, 2010.
[Online]. Available: https://www.analog.com/media/en/technical-documentation/
data-sheets/3633fd.pdf.
[30] A. Costescu. (2019). System demo using basys3 board, [Online]. Available: https:
//youtu.be/rWj7oMH6dso.
76
[31] S. Larson. (2017). Debounce logic circuit, [Online]. Available: https://www.digikey.
com/eewiki/pages/viewpage.action?pageId=4980758.
[32] A. ( M. Systeme), As39513, Nfc sensor tag and data logger ic, 2018. [Online].
Available: http : / / ams . com / documents / 20143 / 36005 / AS39513 _ DS000576 _ 2 -
00.pdf/bbe4317b-9316-4c82-5058-b33158e8d696.
77