Master's thesis - Multi-purpose system for measuring electrical power supplied by electric sockets
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
latex-masters-thesis/problemexpres.tex

377 lines
32 KiB

\section{Electric power fundamentals}
In general physics terms, power is defined as the rate at which energy is transferred (or transformed). Electric energy in particular, begins as electric potential energy – what we commonly refer to as voltage. When electrons flow through that potential energy, it turns into electric energy. In most useful circuits, that electric energy transforms into some other form of energy. Electric power is measured by combining both how much electric energy is transferred, and how fast that transfer happens.
The electric power P is equal to the energy consumption E divided by the consumption time t \cite{meade2002foundations}
$$P = \frac Et$$
where P is the electric power in watt [W], E is the energy consumption in joule [J] and
t is the time in seconds [s].
Electrical Power, in a circuit is the amount of energy that is absorbed or produced within the circuit. A source of energy such as a voltage will produce or deliver power while the connected load absorbs it. Light bulbs and heaters for example, absorb electrical power and convert it into heat or light. The higher their value or rating in watts the more power they will consume.
\subsection{Ohm's law}
Ohm's Law deals with the relationship between the voltage and the current in an ideal conductor. This relationship states that: the potential difference (voltage) across an ideal conductor is proportional to the current through it \cite{henry2008ohm}. The constant of proportionality is called the \textit{resistance}.
$$I = \frac U R $$
where I is the current expressed in amperes [A], U is the voltage, bearing the volt units [V] and R is the electrical resistance in ohms [$\Omega$].
The Ohms's law can be further expanded \cite{beaty1998electric}, to get these three quantities in relationship with \textbf{power}, such as
$$P = I \cdot U = I^2 \cdot R = \frac{U^2}R$$
\subsection{Direct current (DC) circuits}
Generally, Ohm's law is used on \gls{dc} circuits, containing a current of fixed magnitude (amplitude) and a definite direction associated with it. \acrlong{dc} is produced by power supplies, batteries, dynamos and solar cells to name a few.
We also know that \gls{dc} power supplies do not change their value with regards to time\cite{herman2012direct}, they are a constant value flowing in a continuous steady state direction. In other words, \gls{dc} maintains the same value for all times and a constant uni-directional DC supply never changes or becomes negative unless its connections are physically reversed.
\subsection{Waveforms and alternating current (AC) circuits}
An alternating function or \gls{ac} waveform on the other hand is defined as one that varies in both magnitude and direction in more or less even manner with respect to time making it a “bi-directional” waveform \cite{whitaker2006ac}. An AC function can represent either a power source or a signal source with the shape of an AC waveform generally following that of a mathematical sinusoid as defined by
$$A(t) = A_{max} \cdot sin(2 \pi f t)$$
\begin{figure}[ht!]
\centering
\includegraphics[width=.8\textwidth,angle=0]{waveforms}
\caption{The common types of waveforms visualised as a function of amplitude}\label{f:waveforms}
\end{figure}
The term AC or to give it its full description of Alternating Current, generally refers to a time-varying waveform with the most common of all being called a \textbf{Sinusoid} better known as a \textbf{Sinusoidal waveform}. Sinusoidal waveforms are more generally called by their short description as \textbf{Sine Waves}. Sine waves are by far one of the most important types of AC waveform used in electrical engineering.
This means then that the \gls{ac} waveform is a “time-dependent signal” with the most common type of time-dependant signal being that of the Periodic Waveform. The periodic or \gls{ac} waveform is the resulting product of a rotating electrical generator. Generally, the shape of any periodic waveform can be generated using a fundamental frequency and superimposing it with harmonic signals of varying frequencies and amplitudes but that is out of the waveform fundamentals theory.
Alternating voltages and currents can not be stored in batteries or cells like \gls{dc} can, it is much easier and cheaper to generate these quantities using alternators or waveform generators when they are needed. The type and shape of an AC waveform depends upon the generator or device producing them, but all \gls{ac} waveforms consist of a zero voltage line that divides the waveform into two symmetrical halves. The main characteristics of an \gls{ac} waveform \cite{nicolaides1996electrical} are defined as:
\begin{itemize}
\item \textbf{Reriod (T)} is the length of time in seconds that the waveform takes to repeat itself from start to finish. This can also be called the Periodic Time of the waveform for sine waves, or the Pulse Width for square waves
\item \textbf{Frequency} is the number of times the waveform repeats itself within a one second time period. Frequency is the reciprocal of the time period, defined as $f = \frac 1 T$, with the unit of frequency being the Hertz [Hz]
\item \textbf{Amplitude} is the magnitude or intensity of the signal waveform
\end{itemize}
\subsection{Power in AC circuits} \label{ss:ac_power}
When a reactance (either inductive or capacitive) is present in an \gls{ac} circuit, the Ohm's law formula does not apply and different approach must be taken to express and calculate power \cite{rawlins2000basic}.
\textbf{Real power} (or true power) is the power that is used to do the work on the load:
$$P = U_{RMS} \cdot I_{RMS} \cdot cos\,\varphi$$
where P is the real power in watts, $U_{RMS}$ is the \gls{rms} voltage, defined as $U_{peak}/\sqrt{2}$ in volts, $I_{RMS}$ is the RMS current, defined as $I_{peak}/\sqrt{2}$ in amperes and $\varphi$ is the impedance phase angle - phase difference between voltage and current.
\textbf{Reactive power} on the other hand, is the power that is wasted and not used to do work on the load. Curiously, it is defined as
$$Q = U_{RMS} \cdot I_{RMS} \cdot sin\,\varphi$$
with $Q$ being the reactive power in volt-ampere-reactive [var].
\textbf{Apparent power} is the power that is supplied to the circuit. Definition:
$$S = U_{RMS} \cdot I_{RMS}$$
where the unit of apparent power $S$ is volt-ampere [VA]. It can be seen that it is not phase-angle dependent.
The relation all these three quantities are in is defined as
$$ P^2 + Q^2 = S^2 $$
however, again, nothing in the real world is perfect, and this relation only applies for a perfectly \textbf{sinusoidal waveforms}!
\subsection{Phasor and phase shift}
A phasor\cite{2009electrical} is a constant complex number representing the complex amplitude (magnitude and phase) of a sinusoidal function of time. It is usually expressed in exponential form. Phasors are used in engineering to simplify computations involving sinusoids, where they can often reduce a differential equation problem to an algebraic one. The origin of the word phasor comes from phase + vector.
Phasor is a vector that represents a sinusoidally varying quantity, as a current or voltage, by means of a line rotating about a point in a plane, the magnitude of the quantity being proportional to the length of the line and the phase of the quantity being equal to the angle between the line and a reference line.
\begin{figure}[ht!]
\centering
\includegraphics[width=.75\textwidth,angle=0]{phase_diff}
\caption{The phase difference between voltage (blue) and current (red), the origin of phase difference of angle $\varphi$}\label{f:ph_diff}
\end{figure}
Considering the figure \ref{f:ph_diff}, the voltage waveform above starts at zero along the horizontal reference axis, but at that same instant of time the current waveform is still negative in value and does not cross this reference axis until 30\textdegree later. Then there exists a Phase difference between the two waveforms as the current cross the horizontal reference axis reaching its maximum peak and zero values after the voltage waveform.
As the two waveforms are no longer \textit{in-phase}, they must therefore be \textit{out-of-phase} by an amount determined by phi, $\varphi$. The waveform of the current can also be said to be \textit{lagging} behind the voltage waveform by the phase angle $\varphi$. This angle represents the phase shift (also called phase difference) between two sinusoids \cite{maxfield2011electrical}.
\subsection{Power factor and power factor correction}
The power factor is just a specific name for a phase shift between the sinusoids of a current and voltage. So the figure \ref{f:ph_diff} in fact shows the power factor. However, it is not expressed in a plane angle, but rather as a dimensionless number between -1 and 1.
The power factor is defined as $\frac{P}{S}$, as a ratio of the real power over the apparent power\cite{dixit2010electrical}. If $\varphi$ is the phase angle between the current and voltage, then the power factor is equal to the cosine of the angle, $cos\,\varphi$.
If the power factor is 1, it means that all the supplied power is completely consumed by purely resistive load. A positive power factor that is lower than 1 indicates that some power is not consumed by the load and is returned back. The lower the factor, the more power is returned. When power factor is equal to 0, the energy flow is entirely reactive, and stored energy in the load returns to the source on each cycle. A negative power factor means that the device, considered to be power load is in fact a power source (produces more power than consumes).
How can this information be useful? Every load with a power factor other than 1 returns some power back to the transmission line. Since the transmission lines does have some resistance, this returned power translates to some wasted power in a form of heat. Energetic companies want to minimise the power wasted in the transmission lines to increase their profit, so numerous laws are coming into effect to correct \cite{singh2008electric} (increase) the power factor.
\subsection{Electric power measurement}
Measuring the electric power makes most sense on the customer appliances. The first reason is, that they generally consume power that is purchased on contract. The energetic company measures all the power used up by the end customer, but customer has no easy way to see how much and how \textit{effectively} is power used by the appliances. The second important reason is that the appliances has a standardised connector (plug) that is guaranteed to fit in all the area using it, which is not a case for example on battery powered devices (batteries has different sizes, connectors and general properties.
When it comes to measuring the electrical power, the first and the most important thing to discuss is safety. Only after all the safety precautions had been made clear, the theory can be clarified and subsequently, the practice can be applied.
%\subsubsection{Voltage ranges and safety disclaimer}
%The \gls{iec} international standard \textbf{IEC 60038:1983} defines a set of standard \glspl{voltage} for use in AC electricity supply systems.
%
%\begin{table}[ht!]
%\centering
%\caption{International standards grouping ranges of supply voltages to three categories}
%\label{t:volt_ranges}
%\tabcolsep=5pt
%\renewcommand{\arraystretch}{1.3}
%\begin{tabular}{|l|l|l|l|}
%\hline
%{\bf IEC voltage range} & {\bf AC} & {\bf DC} & {\bf defining risk} \\ \hline
%High voltage & \textgreater 1000 V$_{RMS}$ & \textgreater 1500 V & electrical arcing \\ \hline
%Low voltage & 50–1000 V$_{RMS}$ & 120–1500 V & electrical shock \\ \hline
%Extra-low voltage & \textless 50 V$_{RMS}$ & \textless 120 V & low risk \\ \hline
%\end{tabular}
%\end{table}
%The appliances under test work on mains voltage. In Europe, the nominal voltage of mains line for appliances is 230 V / 50 Hz. This falls into the voltage range, with defining risk of \textbf{electrical shock} as described in the table \ref{t:volt_ranges}.
If not handled with care, operating or manipulating with voltage can cause permanent damage to appliance or health, or can cause fire or even death. Thus, respect, increased care and knowledge is necessary in all further practical steps involved.
%\subsubsection{Measurement procedure}
%With the formula for the electrical power being
%$P = I \cdot U$
%the conclusion can be made, that the procedure for measuring the electrical power produced or consumed by circuit consists of measuring the current flowing at the given voltage at the time instant and then multiplying them together. Repeating this sufficiently enough times, the power can be plotted with respect to time.
%
%However, as seen in a subsection \ref{ss:ac_power}, this procedure would measure the \textit{apparent} power, which includes the power stored in reactive elements and later returned to the circuit. To have a useful result of a measurement, the \textit{real} power is desired. Thu keeping track of the \textit{phase angle} is needed.
%
%
%\subsubsection{Measuring electric power with a microcontroller}
%some words about sampling too
\subsection{Power measuring integrated circuits} \label{ss:pmic}
Although it is possible to construct a circuit out of discrete components that would measure \cite{webster2003electrical} the required physical quantities, and such a solution would probably be the cheapest solution out there, it would be highly impractical due to multiple reasons.
The most importantly, the obtained accuracy of the measurements would be dependent on the implementation and used components. It is safe to assume, that without multiple design iterations, the accuracy may be too low to be used in practice.
Another point is that, there is no definitive guide, ready to follow, about how to design such circuit. The reason of this is the vast amount of components available on the market and a lot of design considerations to take into account, depending on the requirements.
A special purpose \glspl{ic} are being developed for the exact purpose of measuring the real, apparent and reactive power, the power factor, and in most cases, gathering some other relevant information.
\begin{figure}[ht!]
\centering
\includegraphics[width=.85\textwidth,angle=0]{measurement_IC_diag}
\caption{The simplified block diagram for a power measurement \gls{ic}}\label{f:meas_IC_diag}
\end{figure}
From the block diagram \ref{f:meas_IC_diag}, it can be seen that the power measuring \gls{ic} is just a specialised microcontroller. It takes the data from the sensing circuitry, which in case of voltage can be measured \textit{directly}, provided that the galvanic isolation is included, for the sake of safety. The current however, must be measured \textit{indirectly}. There are three common ways \cite{srinivasan2015composite} of doing so:
\begin{enumerate}
\item \textbf{shunt resistor} - a resistor with a very small but precise value, that causes a voltage drop with a current passing through it due to the Ohm's law, regardless of frequency. The actual voltage drop is so small, that it can be assumed insignificant, but measurable. However, the voltage drop is still present and may cause some issues, if not taken into account. The advantage is really low price. External galvanic isolation must be provided.
\item \textbf{current transformer} - a current passing wire inside a current sensing coil. Since it is a magnetic induction based transformer, the galvanic isolation is naturally present. The disadvantage is, that the transformer has a cut-off frequency, below which it's effect diminishes rapidly. External magnetic fields can cause problems too. Suitable for measuring current of a fixed (or non-decreasing) frequency.
\item \textbf{Hall-effect sensor} - a sensor measuring absolute electromagnetic field in a conductor. In contrast to the current transformer, this sensor is able to measure low frequency currents, down to \gls{dc}, which is a feat that the shunt resistor possesses too. Can be placed anywhere near the current path and doesn't require physical connection, thus providing galvanic isolation too. The price increases with operating currents range and precision. Prone to be disturbed by external magnetic fields, too.
\end{enumerate}
Using dedicated power measuring IC has another advantage apart from being more accurate. In fact, the part \gls{datasheet} can be consulted and if all application notes and advices are abided, the specified accuracy can be guaranteed.
\newpage
\section{Embedded system}
An embedded \gls{system} is some combination of \gls{computer} \gls{hw} and \gls{sw}, either fixed in capability or programmable, that is specifically designed for a particular function \cite{ganssle2008embedded}. Industrial machines, automobiles, medical equipment, cameras, household appliances, airplanes, vending machines and toys (as well as the more obvious cellular phone and \gls{pda}) are among the myriad possible hosts of an embedded \gls{system}. Embedded \glspl{system} that are programmable are provided with programming \glspl{interface}, and embedded \glspl{system} programming is a specialized occupation.
\subsection{Processing units}
The term embedded \gls{system} is quite broad, so there is no surprise that the spectrum of used processing units is also wide. Since the general purpose microprocessors require external components, namely memories and \glspl{peripheral}, they tend to consume extra power and a board space. Since the design limitations of an embedded \glspl{system} are most of the time low physical size, low power consumption and/or long uptime and ruggedness (more components mean more parts could fail), microprocessors are seldom used. However, most of the commonly used architectures and word lengths are covered. Due to aforementioned reasons, microcontrollers are favored over microprocessors.
\subsection{System-on-chip}
Today's state of chip integration allows production costs of a complex \gls{system} on chip devices to be relatively low, thus making \gls{soc} attractive choice for embedded \glspl{system}. \glspl{soc} could be described as an \gls{ic} that integrates all components of a \gls{computer} or other electronic \gls{system} into a single chip. It may contain digital, analog, mixed-signal, and often \gls{rf} functions - all on a single chip substrate \cite{flynn2011computer}. \glspl{soc} are very common in the mobile electronics market because of their low power consumption. A typical \gls{soc} consists of (specific block diagram can be seen on \ref{f:ar_block}):
\begin{itemize}
\item a microcontroller, microprocessor or \gls{dsp} core(s)
\item memory blocks including a selection of \gls{rom}, \gls{ram}, \gls{eeprom} and \Gls{flash}
\item timing sources including oscillators and phase-locked loops
\item \glspl{peripheral} including counter-timers, real-time timers and power-on reset generators
\item external \glspl{interface}, including industry standards such as \gls{usb}, FireWire, \Gls{ethernet}, \gls{uart}, \gls{spi}
\item analog \glspl{interface} including \glspl{adc} and \glspl{dac}
\item voltage regulators and power management circuits
\item a bus connecting these blocks
\end{itemize}
\glspl{soc} can be implemented as an \gls{asic} or using a \gls{fpga}.
\subsection{Operating system}
An \gls{os} is a \gls{computer} \gls{program} that supports a \gls{computer}'s basic functions, and provides services to other \glspl{program} (or applications) that run on the \gls{computer}. The \glspl{application} provide the functionality that the user of the \gls{computer} wants or needs. The services provided by the operating \gls{system} make writing the applications faster, simpler, and more maintainable.
Over time, a lot of embedded \glspl{os} suited for embedded \glspl{system} were developed. An embedded \gls{os} is a type of \gls{os} that is embedded and specifically configured for a certain \gls{hw} configuration. \Gls{hw} that uses embedded \gls{os} is designed to be lightweight and compact, forsaking many other functions found in non-embedded (i.e. desktop) \gls{computer} \glspl{system} in exchange for efficiency at resource usage \cite{holt2014embedded}. This means that they are made to do specific tasks and do them efficiently. Notable embedded \glspl{os} currently in use by consumers include:
\begin{itemize}
\item \textbf{Embedded \Gls{linux}} - used in many other devices like printers, \glspl{router} or smart TVs; \Gls{android} is a derivative of embedded \Gls{linux}
\item \textbf{iOS} - subset of Mac \gls{os} X, used in Apple’s mobile devices Palm \gls{os}
\nopagebreak
\item \textbf{Windows Mobile} - Microsoft's \gls{os} for mobile devices
\end{itemize}
\subsection{Real-time operating system}
A \gls{rtos} is just a special purpose \gls{os}. The real time part of the name does not mean that the \gls{system} responds quickly, it just means that there are rigid time requirements that must be met. If these time requirements are not met, the results can become inaccurate or unreliable\cite{jean2002microc}. Embedded \glspl{system} frequently posses the real time requirement. There are two kinds of \glspl{rtos}:
\begin{description}
\item[Hard Real Time]- \gls{system} delays are known or at least bounded. Said to be operating correctly if the \gls{system} can return results within any time constraints.
\item[Soft Real Time]- critical tasks get priority over other tasks and will retain priority until the task is completed. This is another way of saying that real time tasks cannot be kept waiting indefinitely. Soft real time makes it easier to mix the \gls{system} with other \glspl{system}.
\end{description}
\subsection{Kernel}
The \gls{kernel} is the essential center of a \gls{computer} \gls{os}, the core that provides basic services for all other parts of the \gls{os} \cite{bovet2005understanding}. It has complete control over what happens in the \gls{system}. A \gls{kernel} can be contrasted with a \gls{shell}, the outermost part of an \gls{os} that interacts with user commands. \Gls{kernel} and \gls{shell} are terms used more frequently in Unix or Unix-like \glspl{os} than in IBM mainframe or Microsoft Windows \glspl{system}.
\begin{figure}[ht!]
\centering
\includegraphics[width=.6\textwidth,angle=0]{linux_block}
\caption{The simplified view on the \Gls{linux} \gls{system} structure}\label{f:linuxbl}
\end{figure}
The simplified view on the \Gls{linux} \gls{system} structure can be seen on \ref{f:linuxbl}. It does not include device \gls{driver}, \glspl{compiler}, \glspl{daemon}, \glspl{utility}, \glspl{command}, \gls{library} files and such, but should be enough for a demonstration.
\subsection{Embedded Linux}
\Gls{linux} itself is a \gls{kernel}, but \Gls{linux} in day to day terms rarely means so. Embedded \Gls{linux} generally refers to a complete \Gls{linux} distribution targeted at embedded devices. There is no \Gls{linux} \gls{kernel} specifically targeted at embedded devices, the same \Gls{linux} \gls{kernel} source code can be built for a wide range of devices, workstations, embedded \glspl{system}, and desktops though it allows the configuration of a variety of optional features in the \gls{kernel} itself. In the embedded development context, there can be an embedded \Gls{linux} \gls{system} which uses the \Gls{linux} \gls{kernel} and other software or an embedded \Gls{linux} distribution which is a prepackaged set of applications meant for embedded \glspl{system} and is accompanied by development tools to build the system\cite{hallinan2010embedded}.
With the availability of consumer embedded devices, communities of users and developers were formed around theses devices: Replacement or enhancements of the \Gls{linux} distribution shipped on the device has often been made possible thanks to availability of the source code and to the communities surrounding the devices. Due to the high number of devices, standardized build \glspl{system} have appeared, namely OpenWRT.
\subsection{OpenWRT} \label{ss:openwrt}
OpenWrt is an \gls{os} (in particular, an embedded \gls{os}) based on the \Gls{linux} \gls{kernel}, primarily used on embedded devices to route \gls{network} traffic. It has been optimized for size, to be small enough for fitting into the limited storage and memory available in home \glspl{router}.
OpenWrt is configured using a command-line \gls{interface} (ash \gls{shell}), or a web \gls{interface} (LuCI). There are about 3500 optional \gls{sw} packages available for installation via the \texttt{opkg} package management \gls{system}.
\subsection{Components of the OpenWRT}
The main components are the \Gls{linux} \gls{kernel}, \texttt{util-linux-ng}, \texttt{uClibc} and \texttt{BusyBox}. The \Gls{linux} \gls{kernel} was already mentioned. \texttt{util-linux-ng} is self explanatory - it is a set of \gls{linux} utilities used inside the OpenWWT distribution.
\texttt{BusyBox} is a software that provides several stripped-down \Gls{unix} tools in a single executable file. It runs in a variety of \gls{posix} environments such as \Gls{linux}, \Gls{android}, \gls{bsd} family and others, such as proprietary \glspl{kernel}, although many of the tools it provides are designed to work with \glspl{interface} provided by the \Gls{linux} \gls{kernel}.
\texttt{uClibc} is a small C standard library intended for \Gls{linux} \gls{kernel}-based operating systems for embedded \gls{system} and mobile devices.
\newpage
\section{GL.inet board} \label{s:glinet}
GL.inet Smart \Gls{router} is a remake of a common TP-Link \gls{router} TL-WR703N. The board changes include, but are not limited to, increased \gls{ram} and \Gls{flash} memory, custom \gls{firmware} and what is the most important - 5 usable \gls{gpio} pins exposed to the 2cm pin header for utility purposes. The frequency of \gls{cpu} is 400 \gls{mhz} and it is suited for running \Gls{linux} distributions for embedded devices, preferably OpenWrt or DD-Wrt. The board provides \gls{lan} and \gls{wan} connection, as well as other \glspl{interface} defined in \gls{ieee}. The information about the board are summed up in the table \ref{t:charact}.
\begin{table}[h]
\caption{The basic characteristics of the GL.inet board}\label{t:charact}
\medskip
\centering
\def\arraystretch{1.5}
\setlength{\tabcolsep}{12pt}
\begin{tabular}{|l|l|}
\hline
Model & GL-iNet 6408A / 6416A \\
\hline
\gls{cpu} & Atheros 9331, 400 \gls{mhz} \\
\hline
\gls{ram} & DDR 64 \gls{MB} \\
\hline
\gls{rom} & \Gls{flash} 8\gls{MB} (6408A) / 16\gls{MB} (6416A) \\
\hline
\Gls{interface} & 1 \gls{wan}, 1 \gls{lan}, 1 \gls{usb}2.0,
1 Micro \gls{usb}(Power), 5 \gls{gpio} \\
\hline
Wireless & \gls {ieee}802.11n/g/b, \gls{ieee} 802.3, \gls{ieee} 802.3u \\
\hline
\end{tabular}
\end{table}
\subsection{Atheros AR9331 Wi-Fi System-on-Chip}
The Atheros AR9331 is a highly integrated and cost effective \gls{ieee} 802.11n 1x1 2.4 G\gls{hz} \gls{soc} for \gls{wlan} \gls{ap} and \gls{router} platforms. The block diagram of the chip can be seen in figure \ref{f:ar_block}. Features of this \gls{soc} are following:
\begin{itemize}
\item Complete \gls{ieee} 802.11n 1x1 \gls{ap} or \gls{router} in a single chip
\item \gls{mips} 24K processor operating at up to 400 \gls{mhz}
\item External 16-bit \gls{ddram} or \gls{sdr} memory \gls{interface}
\item \gls{spi} NOR \Gls{flash} memory support
\item No external \gls{eeprom} needed
\item 4 \gls{lan} ports and 1 \gls{wan} port \gls{ieee} 802.3 Fast \Gls{ethernet} switch with auto-crossover, auto polarity
\item Fully integrated \gls{rf} front-end including \gls{pa} and \gls{lna}
\item Optional external \gls{lna}/\gls{pa}
\item Switched antenna diversity
\item High-speed \gls{uart} for console support
\item \gls{i2s}/\gls{spdif} audio \glspl{interface}
\item \gls{slic} for \gls{voip}/\gls{pcm}
\item \gls{usb} 2.0 host/device mode support
\item \gls{gpio}/\gls{led} support
\item \gls{jtag}-based processor debugging supported
\item 25 \gls{mhz} or 40 \gls{mhz} reference clock input
% \item Advanced power management with dynamic clock switching for ultra-low power modes
\item 148-pin, 12 mm x 12 mm dual-row \gls{lpcc} package
\end{itemize}
\begin{figure}[ht!]
\centering
\includegraphics[width=.9\textwidth,angle=0]{AR9331_block}
\caption{The block diagram of the Atheros AR9331 \gls{soc} used as a main processing unit on GL.inet board}\label{f:ar_block}
\end{figure}
\subsection{From TL-WR703N to GL.inet}
TP-Link TL-WR703N \gls{router} is a popular choice among \gls{hw} customisation community because of it's cheap price tag compared to processing power and usage of a full-grown \Gls{linux} distribution. People have figured out how to upgrade \gls{ram} / \Gls{flash} memories or to make use of not used \gls{gpio} / UART ports for their own needs. These solutions however were mostly crude and expensive to replicate. The GL.inet team saw an opportunity to grasp this public knowledge and rolled out their own improved board clone to the marked.
Whole printed circuit board of TL-WR703N was remade by the GL.inet team to expose the unused \gls{gpio} pins on the \gls{soc}, utilize two \Gls{ethernet} port instead of one and utilize the \gls{usb} 2.0 port. Memory chips were replaced by their higher capacity alternatives.
\begin{figure}[ht!]
\centering
\includegraphics[width=.5\textwidth,angle=0]{gl-inet_pcb_up}
\caption{The front side of the GL.inet board exposing the main Atheros \gls{soc}, \gls{ram} and \glspl{interface}}\label{f:board_front}
\end{figure}
\begin{figure}[ht!]
\centering
\includegraphics[width=.5\textwidth,angle=0]{gl-inet_pcb_down}
\caption{The back side of the GL.inet board exposing the \Gls{flash} memory and a main voltage regulator}\label{f:board_back}
\end{figure}
\newpage
\section{ESP8266 Wi-Fi module} \label{s:esp8266}
The ESP8266 Wi-Fi module is a self contained \gls{soc} with integrated \gls{tcpip} protocol stack that can give any microcontroller access to your Wi-Fi network. The ESP8266 is capable of either hosting an application or offloading all Wi-Fi networking functions from another application processor. The ESP8266 module is an extremely cost effective solution, with a huge code-base and community, making it a preferable option for many modern projects, mainly the ones that follow the \gls{iot} trend.
\begin{figure}[ht!]
\centering
\includegraphics[width=.4\textwidth,angle=0]{esp-01}
\caption{The first commercial iteration of the ESP8266 module, the ESP-1, exposing two \glspl{gpio}}\label{f:esp-01}
\end{figure}
This module has a powerful enough on-board processing and storage capability that allows it to be integrated with the sensors and other application specific devices through its \glspl{gpio} with minimal development up-front and minimal loading during runtime. Its high degree of on-chip integration allows for minimal external circuitry, including the front-end module, is designed to occupy minimal \gls{pcb} area.
\begin{figure}[ht!]
\centering
\includegraphics[width=.4\textwidth,angle=0]{esp-12e}
\caption{The certified ESP-12E module exposing all \glspl{gpio}}\label{f:esp-12e}
\end{figure}
\subsection{Features of a ESP8266 chip}
The list of features contained in a 24 pin plastic \gls{qfn} package are listed (but not limited to) in the following list:
\begin{itemize}
\item 802.11 b/g/n
\item Wi-Fi Direct (P2P), soft-AP
\item Integrated \gls{tcpip} protocol stack
\item Integrated \gls{lna}, power amplifier, matching network and power management
\item +19.5dBm output power in 802.11b mode
\item Power down leakage current of <10uA
\item 512kB - 4MB \Gls{flash} Memory (depending on manufacturer)
\item Integrated low power 32-bit CPU could be used as application processor
\item \gls{sdio} 1.1 / 2.0, \gls{spi}, \gls{uart}
\item Standby power consumption of < 1.0mW
\end{itemize}
\subsection{The boot-up process}
The Espressif code can boot in different modes, selected on power-up based on GPIO pin levels. Details are listed in the truth table \ref{t:esp-gpio}.
\setlength{\tabcolsep}{.3em}
\begin{table}[ht!]
\centering
\caption{The ESP8266 boot-up process, based on pin levels}
\label{t:esp-gpio}
\begin{tabular}{|c|c|c|l|l|}
\hline
\multicolumn{1}{|l|}{\textbf{GPIO15}} & \multicolumn{1}{l|}{\textbf{GPIO0}} & \multicolumn{1}{l|}{\textbf{GPIO2}} & \textbf{Mode} & \textbf{Description} \\ \hline
L & L & H & UART & Download code from UART \\ \hline
L & H & H & Flash & Boot from SPI Flash \\ \hline
H & x & x & SDIO & Boot from SD-card \\ \hline
\end{tabular}
\end{table}