978-1-5386-2350-3/18/$31.00 ©2018 European Union Neural Network Testing Framework for Microcontrollers Sorin Zoican, Marius Vochin, Roxana Zoican, Dan Galațchi University POLITEHNICA of Bucharest, Romania sorin@elcom.pub.ro, mvochin@elcom.pub.ro, roxana@elcom.pub.ro, dg@elcom.pub.ro Abstract this paper analyzes and evaluates the performance of neural network testing using microcontrollers. The finite precision of microcontrollers registers and the computation time were considered. The paper illustrates a general framework in which a neural network application can easily integrated. This framework is based on Contiki IoT operating system that ensure support for wireless communication and efficient implementation of processes in a resource constrained system. As a practical example, a human activity recognition system, based on Long Short-Term Memory recurrent neural network, was implemented using a modified evaluation board from Analog Devices, and evaluated. The obtained system accuracy is very good, very close to the accuracy obtained in infinite precision simulation, and the computation time is low enough and the system works in real time. Keywords — neural network, accuracy, finite precision, real time computation, Contiki operating system I. INTRODUCTION Nowadays, neural networks can be implemented on embedded performs for speech recognition, object detection or human activity recognition. The main issues here are low power consumption, numerical representation, memory requirements, and execution time. On the other hand, the embedded system should be able to run all the necessary tasks required by the above mentioned applications: acquire the data sensors, test the neural network, make a decision, and transmit it to a server for monitoring and to take further actions. Is no need that the neural network training to be run on the embedded node, but it is running separately; the neural networks parameters are transmitted to embedded nodes. This paper defines and analyses a framework for using neural networks to implement various embedded applications. We consider the application of neural networks in domain of human activity recognition (HAR) [2]. The recognition of human activities has an important significance in applications referred to road safety, smart surveillance, health monitoring, etc. [1] The entire system is shown in Fig. 1 and Fig. 2. The system has two components: the developing phase and the operating phase. In the developing phase, the necessary sensor data (in the evaluated HAR system we use data from a three-axis accelerometer) are transmitted to an application development server that train a neural network. When the training process is completed, the neural network parameters are transmitted to the wearable devices (assuming that the same neural network model will be tested in the next phase). In the operating phase, the neural network is tested, and a prediction will be made. This prediction is then transmitted to an application server to take a proper action. The application server can monitor several wearable devices. For system implementation one can choose a solution consists of a powerful system on the chip from Analog Devices (consists of ADuCRF101 which integrates an ARM Cortex M3 MCU at 16 MHz clock, and a RF transceiver ADF7024, and ultra-low power triple axis accelerometer sensor ADXL362) as hardware, and AD6LoWPAN (which is the 6LoWPAN - IPv6 over Low-Power Wireless Personal Area Networks, provided by Analog Devices ) with IoT operating system Contiki, as software. The goal of this paper is to implement and evaluate the performance of this framework. As application example we chose a human activity recognition system which use the three axes accelerometer as input data and determine the human activity as: sitting, walking, and running. To make a prediction a Long Short-Term Memory (LSTM) neural network is involved. This type of recurrent neural network has been proved to have good results in sequence classification and their parameters were validated by simulating in MATLAB. All the necessary functions that implement the neural network will be considered and evaluated to see if the entire system can perform in real time using a microcontroller. Considering a wireless node network, in which a very important goal is energy conservation, specific implementation of threads (as starting / stopping radio communication) should be implemented. In such cases, the event-driven model - described by a finite state machine (FSM) is used. To simplify the system development, the threads can be replaced by protothreads, that can be written without having to design state machines [4]. The protothreads are a programming abstraction and they reduce the complexity of implementations of event-triggered systems by performing conditional blocking of event-triggered systems, without the overhead of full multi-threading systems. They are lightweight threads without own stack. This is advantageous in memory constrained systems, where a stack for a thread use a large part of the available memory. Protothreads are based on a low-level mechanism named local continuations that can be set (the CPU are captured) or