\documentclass[12pt,a4paper,english]{tutthesis}

\nonstopmode

\usepackage{subfigure}

\usepackage{afterpage}
\usepackage{pslatex}
\usepackage[english,finnish]{babel}
\usepackage[hang,up,bf]{caption}% kuvatekstien kirjasinkoko ja asettelu
\renewcommand{\captionfont}{\em\normalsize}
\pagenumbering{Roman}

\usepackage{hyphenat}
\usepackage{amsmath}
\usepackage{amsthm}

\usepackage{listings}
\lstset{language=C++}

\usepackage{array}
\usepackage{enumerate}

\usepackage{totcount}
\newtotcounter{totalpages}
\chead{\stepcounter{totalpages}}

\usepackage{tikz}
\usepackage{pgfplots}
\usetikzlibrary{matrix}
\usetikzlibrary{positioning}
\usetikzlibrary{calc}
\usetikzlibrary{backgrounds}
\usetikzlibrary{chains}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{fit}
\usetikzlibrary{plotmarks}
\usetikzlibrary{decorations}
\usetikzlibrary{mindmap}
\usetikzlibrary{trees}
\usetikzlibrary{circuits.ee.IEC}

\tikzset{concept/.append style={fill={none}}}
\tikzset{help lines/.style={draw=black!15}}
\pgfplotsset{every axis/.style={grid=major,
    axis x line=bottom, axis y line=left},
    every axis y label/.style={
        at={(rel axis cs:0,1)}, anchor=south west, xshift=-2mm
    }
}
\pgfkeys{/pgf/number format/.cd,
    set thousands separator = {~}, set decimal separator = {,}
}

\usepackage{booktabs}
\setlength{\heavyrulewidth}{1.1pt}

\usepackage{hyperref}
\hypersetup{
    colorlinks,%
    citecolor=black,%
    filecolor=black,%
    linkcolor=black,%
    urlcolor=black,%
    bookmarksnumbered=true
}
\usepackage{cite}

\usepackage{float}
\newfloat{program}{bp}{lop}[chapter]
\floatname{program}{Programme}

\newcommand{\code}[1]{\texttt{#1}}
\newcommand{\unit}[1]{\ensuremath{\, \mathrm{#1}}}
\newcommand{\euro}[0]{€}

% Pilkut matikkatilassa parempaan kohtaan
%\let\oldprime\prime
%\renewcommand{\prime}{\kern1pt\lower3pt\hbox{$\scriptstyle\oldprime$}}

% Subfiguren referenssit
\renewcommand{\thesubfigure}{\alph{subfigure}}
\makeatletter
%   \renewcommand{\p@subfigure}{}
  \renewcommand{\@thesubfigure}{\alph{subfigure})\hskip\subfiglabelskip}
\makeatother

\usepackage[style=list, nonumberlist]{glossaries}
\makeglossaries
\newcommand{\addmglosb}[3]{\newglossaryentry{#1}{sort={#1}, name={#2}, description={#3}}}
\newcommand{\addmglos}[2]{\newglossaryentry{#1}{name={#1}, description={#2}}}
\newcommand{\addglos}[2]{\newglossaryentry{#1}{name={#1}, description={\mbox{}\\#2}}}
%\newcommand{\useglos}[1]{\useGlosentry{#1}{#1}}

\newcommand{\longbracetext}[1]{\text{\hbox to 0cm{\hss{#1}\hss}}}

\usepackage{doi}

\usepackage{url}

\begin{document}
% Vähennetään ylenpalttista tavutusta
\hyphenpenalty=6000
\tolerance=2000
\hfuzz=2pt

% Matikan rivitys
\relpenalty=1000
\binoppenalty=3000

\raggedbottom
\addtolength{\topskip}{0pt plus 3cm}

\pdfbookmark{Title page}{Title page}

\author{Petteri Aimonen}

\thispagestyle{empty}

\vspace*{-.5cm}\noindent
\includegraphics[width=8cm]{tut-logo.pdf}

\vspace{6.8cm}

\noindent{\bf\large \textsf{Petteri Aimonen}}\\
{\bf\large \textsf{Design of an embedded system for video performance measurements}}\\
\textsf{Master of Science Thesis}

\vspace{6.7cm} % jos kaksi otsikkoriviä vaihda -> 6.7cm

\begin{flushright}
  
\begin{minipage}[c]{7.3cm}
\begin{spacing}{1.0}
\raggedright
\textsf{Examiners: Prof. Timo D. Hämäläinen, Dr.~Erno Salminen}\\
\textsf{Examiners and topic approved by the}\\
\textsf{Faculty Council of the Faculty of}\\
\textsf{Computing and Electrical Engineering}\\
\textsf{on 5.2.2014}\\
\end{spacing}
\end{minipage}
\end{flushright}

\stepcounter{totalpages}
\stepcounter{totalpages}

\newpage
\setcounter{page}{1} % tämä tarvitaan, jottei ensimmäinen sivu kansilehden jälkeen olisi numero 2.
\pdfbookmark{Tiivistelmä}{Tiivistelma}
\chapter*{TIIVISTELMÄ}
\begin{spacing}{1.0}
\textsf{TAMPEREEN TEKNILLINEN YLIOPISTO}\\
\textsf{Signaalinkäsittelyn ja tietoliikennetekniikan koulutusohjelma}\\
{\bf \textsf{PETTERI AIMONEN: Sulautetun mittalaitteen suunnittelu videomittauksia varten}}\\
\textsf{Diplomityö, \total{totalpages} sivua, ei liitesivuja}\\
\textsf{Helmikuu 2014}\\
\textsf{Pääaine: Digitaali- ja tietokonetekniikka}\\
\textsf{Tarkastajat: Prof. Timo D. Hämäläinen, TkT Erno Salminen}\\
\textsf{Avainsanat: videotoiston suorituskyky, kuvataajuus, käyttäjäkokemus, sulautettu järjestelmä}\\
\end{spacing}
\noindent
\selectlanguage{finnish}
Tämä diplomityö kuvaa videomittauksiin käytettävän mittalaitteen suunnitteluprosessin. Kuvatun laitteen tarkoituksena on auttaa videotoiston optimoinnissa toistolaitteiden, kuten taulutietokoneiden, älypuhelimien ja televisioiden, suunnitteluprosessin aikana. Laite mittaa videon kuvataajuuden ja laskee mahdollisesti toistovaiheessa puuttumaan jääneiden kuvien lukumäärän käyttäen anturia, joka asetetaan toistolaitteen näyttöä vasten.

Ominaisuus, joka erottaa tämän mittalaitteen muista yleisistä tavoista mitata näytön kuvataajuus on se, että se toimii täysin mitattavan laitteen ulkopuolelta. Mitattavaan laitteeseen tai sen ohjelmistoon ei siis tarvita mitään muutoksia, ja kaikki laitteistotason ilmiöt, joita voi esiintyä esimerkiksi näytönohjaimessa, saadaan mitattua. Näin se mahdollistaa kattavamman analyysin toistolaitteen toiminnasta, ja mahdollistaa tulosten vertailun myös kilpailijoiden laitteisiin.

Mittalaitteen toteuttamiseksi suunniteltiin oma STM32F407-mikrokontrolleriin perustuva laitteistoalusta. Koska kohdemarkkinan tarpeet muuttuvat nopeasti uusien laitesukupolvien myötä, suunniteltiin mittalaite niin, että sitä voidaan helposti laajentaa esimerkiksi uusilla antureilla.

Mittausten tarvitsema signaalinkäsittely toteutettiin kokonaan ohjelmallisesti, jotta se olisi mukautettavissa eri tehtäviin. Tämä asettaa nopeusvaatimuksia laitteen ohjelmistolle, ja niiden täyttämiseksi ohjelmisto rakennettiin NuttX-reaaliaikakäyttöjärjestelmän päälle.

Projektin tuloksia arvioidaan sekä tavoitteiden saavuttamisen kannalta, että asiakkailta ja myyntiosastolta saadun palautteen perusteella. Laitteen kehittäminen ensimmäisistä suunnittelupalavereista valmiiseen ohjelmistoversioon saakka kesti 9 kuukautta, ja karakterisointimittauksissa todettiin 1~ms mittaustarkkuus 150~FPS kuvataajuuteen asti.
\selectlanguage{english}

\newpage
\pdfbookmark{Abstract}{Abstract}
\chapter*{ABSTRACT}
\begin{spacing}{1.0}
\textsf{TAMPERE UNIVERSITY OF TECHNOLOGY}\\
\textsf{Master's Degree Programme in Signal Processing and Communications Technology}\\
{\bf \textsf{PETTERI AIMONEN: Design of an embedded system for video performance measurements}}\\
\textsf{Master of Science Thesis, \total{totalpages} pages, no appendix pages}\\
\textsf{February 2014}\\
\textsf{Major: Digital and Computer Systems}\\
\textsf{Examiners: Prof. Timo D. Hämäläinen, Dr. Erno Salminen}\\
\textsf{Keywords: video playback performance, frame rate, user experience, embedded system}\\
\end{spacing}

\noindent 

This master's thesis describes the design process of a measurement instrument for measuring the video playback performance. The purpose of the instrument is to aid in optimizing the video playback quality of devices such as tablets, smartphones and televisions. In particular, the instrument measures the frame rate and number of missing frames using a sensor attached to the display.

The aspect that sets this instrument apart from common ways of measuring display frame rates is that it operates outside the video playback device. This means that no modifications are required to the device being tested, and all effects that may occur in e.g. display hardware are accurately measured. In this way it allows more complete analysis of the device behaviour, and is also suitable for testing competitor's devices.

To implement the measurement instrument, a custom hardware platform based around the STM32F407 microcontroller is designed. In order to adapt to the rapidly changing needs and focuses of the market sector, the hardware is designed with maximal extensibility to allow easy attachment of new kinds of sensors.

The signal processing required for the sensor signals is implemented entirely in software, in order to allow future measurement tasks to use different algorithms. This places requirements on real-time performance on the hardware and software, and the NuttX real-time operating system is chosen as a basis for the firmware development.

A software architecture composed of signal processing libraries, low-level device drivers and GUI user interface is described. The architecture is designed to allow easy reuse of components to implement several measurement tasks.

Finally, the success of the project is evaluated both on basis of meeting the set goals and based on feedback received from the pilot customers and sales team. The development of the instrument took 9 months from the initial planning meetings to the first official software version. Characterization measurements have shown the instrument to measure up to 150~FPS frame rates at 1~ms resolution.

\newpage
\pdfbookmark{Preface}{Preface}
\chapter*{PREFACE}

The purpose of this thesis is to describe the high-level choices and process involved in the design of an embedded measurement instrument. Due to trade secrets, the signal processing algorithms used are not described in detail, while their development was a significant portion of the work in this project.

This thesis was done for OptoFidelity Oy, a test automation and machine vision company based in Tampere, Finland. Selling world-wide, OptoFidelity has sales relationships with many of the leading companies in the mobile device market, and is constantly looking for new opportunities to aid in their customer's research and development process. The instrument described in this thesis forms a part of their product offering for measuring video playback performance.

I would like to thank OptoFidelity for providing this interesting and challenging topic, and especially Kimmo Jokinen for his encouragement and highly useful feedback during the project. The sales team also helped by providing insight into the market demands, and by arranging demos and test uses with pilot customers. Finally, I would like to thank my family for support during the stressful year that this project and thesis took to complete.

\newpage
\pdfbookmark{Table of contents}{Table of contents}
\tableofcontents
%\newpage
%\listoffigures
%\listoftables
\newpage
\pdfbookmark{Terms and symbols}{Terms and symbols}
\renewcommand{\glossaryname}{Terms and symbols}
\printglossaries

\addglos{DPI}{Dots Per Inch, a measurement unit for the pixel density on a display}
\addglos{FPS}{Frames Per Second, a measurement unit for the rate of individual images in video content}
\addglos{RAM}{Random Access Memory, a type of microprocessor memory that is used for temporary storage of data that is being processed}
\addglos{IC}{Integrated Circuit, an electronic circuit that has been implemented on a single microchip}
\addglos{MOSFET}{Metal Oxide Semiconductor Field Effect Transistor, a type of transistor, used to control the flow of electrical current}
\addglos{RTC}{Real Time Clock, a clock circuit that keeps track of the current time and date}
\addglos{LDO}{Low Drop-Out, a term for voltage regulators that need only a small (usually 0.1--0.5~V) voltage difference to operate}
\addglos{SMPS}{Switching Mode Power Supply, a class of power supplies that can be designed to raise or lower a voltage efficiently by rapidly switching it on and off}
\addglos{SD}{Secure Digital, a standardized form factor and interface for memory cards}
\addglos{SPI}{Serial Peripheral Interface, a type of digital interface which uses three wires for serial communications}
\addglos{I2C}{Inter-Integrated Circuit, a type of digital interface which uses two wires and pull-up resistors for serial communications}
\addglos{GPIO}{General Purpose Input Output, a term for microcontroller pins that can be directly controlled by software to perform either digital input and output}
\addglos{RGB}{Red Green Blue, the combination of three colors in a computer display which can produce most of the colors perceived by human eye}
\addglos{LED}{Light Emitting Diode, a semiconductor device that emits light when a current flows through it}
\addglos{USART}{Universal Synchronous Asynchronous Receiver/Transmitter, a digital circuit that can both receive and transmit data using a synchronous or an asynchronous serial protocol}
\addglos{DAC}{Digital to Analog Converter, a circuit that converts digital signals to analog voltages}
\addglos{API}{Application Programming Interface, a documented interface that can be used by software applications to communicate with each other}
\addglos{EEPROM}{Electrically Erasable Programmable Read Only Memory, a memory circuit that allows permanent storage of data, but can be erased and rewritten when necessary}
\addglos{RTOS}{Real Time Operating System, a class of operating systems that is especially designed to allow fast reaction to external events and predictable timing of operations}
\addglos{HAL}{Hardware Abstraction Layer, a component in an operating system that supports several kinds of hardware and provides a common interface for applications to use}
\addglos{POSIX}{Portable Operating System Interface, a family of IEEE standards specifying an API for operating systems, aiming for compatibility between various platforms}
\addglos{MCU}{MicroController Unit, another term for microcontroller}
\addglos{Microcontroller}{An integrated circuit that combines a microprocessor with memory and other peripherals on the same microchip}
\addglos{OS}{Operating System, a software platform that provides services such as task scheduling, which make it easier to implement applications}
\addglos{DMA}{Direct Memory Access, a hardware unit that can autonomously perform data transfer tasks to and from memory, freeing the main processor to execute other tasks}

\newpage
\renewcommand{\chaptermark}[1]{\markboth{\thechapter. \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{}{}}
\lhead{\fancyplain{}{\leftmark}}

% Tästä alkaa varsinainen teksti
\pagenumbering{arabic}

\include{introduction}
\include{startingpoint}
\include{hardware}
\include{software}
\include{results}
\include{summary}

% lähdeluettelo
\newpage
\renewcommand{\bibname}{References} 

\bibliographystyle{jpabib}
\begingroup
% \raggedright
\bibliography{lahteet}
\endgroup
\addcontentsline{toc}{chapter}{References} % Lisää tämäkin sisällysluetteloon

\appendix
% \chapter{Liitteitä}

\glsaddall

\end{document}

