\section{Microcontroller}
A microcontroller is a self-contained system with peripherals, memory and a processor that can be used as an embedded system (it's brains). Most programmable microcontrollers that are used today are embedded in other consumer products or machinery including phones, peripherals, automobiles and household appliances for computer systems. Due to that, another name for a microcontroller is "embedded controller." 

Microcontroller can only manipulate with limited amount of data at once. Most today microcontrollers are working with 8, 16 or 32 bits.


\subsection{Brief history of microprocessors and microcontrollers}
Since microcontrollers evolved out of microprocessors, some milestones in their history are worth noting\cite{allan2001history}\cite{augarten1983state}:
\begin{itemize}
	\item Busicom - calculator manufacturer of Japan ordered design of some specific chips from Intel corporation (1969)
	\item M. E. Hoff came out with the idea of device, which operation will be governed by instructions stored in ROM memory
	\item F. Faggin built the actual device - the first microprocessor
	\item Intel bought rights to sell the device on their own from Busicom, Intel 4004 (4 bit) came to market (1971)
	\item Texas Instruments engineers G. Boone and M. Cohran packed CPU, RAM, ROM, I/O and peripherals to the one chip, the first microcontroller was born, but it was a commercial failure
	\item Intel improved the device, the Intel 8008 (8 bit) was born (1972)
	\item TI microcontroller was employed in calculators (1972)
	\item TI put their TMS1000 microcontroller on the market with a great success, for \$2/pc, millions were sold (1974)
	\item Motorola entered the market with 68000 and Zilog with Z80, which caused the competition to grow exponentially
\end{itemize}

\subsection{Microcontroller architectures and vendors}
Microcontrollers are produced by roughly two dozens of companies, so the great diversity exists. Advanced integration is causing that more and more functionality is packed into these devices.

Some of the present MCU architectures and vendors are:
\begin{itemize}
	\item 8051 introduced by Intel, today produced by most semiconductor manufacturers
	\item ARM
	\item MIPS
	\item AVR by Atmel
	\item PIC by Microchip
	\item DSP430, C2000 by Texas Instruments
	\item Freescale, ST Microelectronics, XMOS, \dots
\end{itemize}

\subsection{Structure of microcontroller}
On the very basic level, the microcontroller consists of basic building blocks, illustrated on Figure \ref{mcu:1}:
\begin{itemize}
	\item Microprocessor with  Arithmetic-logic Unit (ALU), Control logic and Instruction decoder
	\item Memory 
	\item Program counter
	\item Oscillator
	\item Input/Output circuitry
	\item Timers, Pulse-Width Modulation 
	\item Analog-to-digital converter
\end{itemize}

\begin{figure}[ht!]
	\centering
	\includegraphics[width=\textwidth,angle=0]{mcu_structure.jpg}
	\caption{Naive representation of what is inside the microcontroller}\label{mcu:1}
\end{figure}

Some additional blocks and peripherals are be included, depending on MCU model, such as:
\begin{itemize}
	\item Brown-out detection
	\item Serial communication interfaces\cite{susnea2006microcontrollers}
	\item USB controller
	\item Ethernet interface
	\item Watch-dog timer
	\item Interrupt routines
\end{itemize}

Every block can get really complex to explain. For simplicity, only the blocks, that are particularly important for the understanding the device will be described in deer detail.

\subsection{Microcontroller memories}
Most microcontrollers do possess three types of memory:

\begin{itemize}
	\item Flash stores instructions in order they will be executed
	\item RAM stores temporary data, needed for computations
	\item EEPROM stores data, that should be remembered, such as user configurations
\end{itemize}
Special-function Registers (SFRs) are part of RAM memory and changing them, will cause direct change in microcontroller behaviour.

\subsection{Oscillator}
Oscillator's job is to make sure, every block knows, when to do its job. It represents the function of commander, thus the drums illustration. There are two types of oscillators used:
\begin{itemize}
	\item external
	\item internal
\end{itemize}

\subsection{Serial communication interfaces}
Communication interfaces are used for communication between MCU and other MCU or other devices. Most standard serial interfaces are UART, I2C and SPI.

UART is used between two devices. When more devices are communicating, I2C or SPI is used. SPI provides faster communication over I2C at the expense of used pins on microcontroller.

\subsection{USB controller}
A USB port\cite{axelson2007serial} is a standard cable connection interface on personal computers and consumer electronics. USB ports allow stand-alone electronic devices to be connected via cables to a computer (or to each other).

USB is serial communication interface, derived off I2C. It can be implemented on microcontroller itself, or as standalone device/module.

\subsection{Other useful information}
Bluetooth is a wireless technology, for communication between devices and/or computers at short ranges. 
Display is the device showing visual information.
Human interface provides a way for human to control the device.
Non-volatile memory is preserving the data, even when power is lost.
%MicroSD card is a data storage device, mostly consisting of Flash memory.


\nomenclature{CPU}{Central Processing Unit}
\nomenclature{RAM}{Random-access Memory}
\nomenclature{ROM}{Read-only memory}
\nomenclature{I/O}{Input/output}
\nomenclature{TI}{Texas Instruments}
\nomenclature{Hz}{Hertz, unit of frequency}

\newpage
\section{RFID}
RFID stands for Radio-Frequency IDentification \cite{lehpamer2012rfid}. The acronym refers to small electronic devices that consist of a small chip and an antenna. The chip typically is capable of carrying 2,000 bytes of data or less. 

The RFID device serves the same purpose as a bar code or a magnetic strip on the back of a credit card or ATM card; it provides a unique identifier for that object. And, just as a bar code or magnetic strip must be scanned to get the information, the RFID device must be scanned to retrieve the identifying information.

From the energy point of view, RFID tags falls into one of the three categories:
\begin{itemize}
	\item active
	\item battery-assisted passive
	\item passive
\end{itemize}

\subsection{RFID frequencies}
RFID is considered as a non specific short range device. It can use frequency bands without a license. Nevertheless, RFID has to be compliant with local regulations. 

Frequencies used in RFID communication, illustrated on Figure \ref{rfid:1}:
\begin{itemize}
	\item LF - low frequencies: 125 kHz - 134,2 kHz
	\item HF - high frequencies: 13.56 MHz
	\item UHF - ultra high frequencies: 860 MHz
	\item SHF - super high frequencies: 2.45 GHz
\end{itemize}

\begin{figure}[ht!]
	\centering
	\includegraphics[width=\textwidth,angle=0]{rfid_freq.jpg}
	\caption{Graph of the electromagnetic spectrum with the frequency bands that the RFID systems can use}\label{rfid:1}
\end{figure}

\subsection{Mifare}
Mifare is a 13.56 MHz contactless NFC\cite{coskun2011near} technology owned by NXP (founded by Philips). It falls into high frequency, passive RFID tag category. Mifare has proven popular as the card to use in ticketing, low value transactions and in student's ISIC cards.  Mifare cards are powered by an internal antenna as the card moves into a magnetic field.

Cipurse is another such technology, although it is not owned by just one company, but rather alliance of companies. The next difference is that this standard is open. It's aim is to promote vendor neutrality, opposed to market Mifare dominance.

%\newpage
Some benefits of the Mifare are:
\begin{itemize}
	\item multiple applications
	\item secure encryption prevents unauthorised access 
	\item reduced maintenance, due to contactless technology
	\item alternatives to cards, such as fobs or watches
	\item only proximity is sufficient for read/write
	\item unique serial number (tag)
\end{itemize}

\subsection{RFID reader}
An RFID reader is basically a radio frequency transmitter and receiver controlled by a microprocessor. The reader, using an attached antenna, captures data from RFID enabled smart label tags, then passes the data to a microcontroller for processing. 



