The effective design of an embedded emulation device crucially depends on the capability of accurately and efficiently modeling the target energy source. In fact, the accuracy of the model impacts the capability of the emulator to mimic realworld sources, while the computational efficiency of the algorithm that implements the model directly affects the latency of the overall system and the possibility to emulate real time operating conditions.
A highlevel abstraction of the modeling framework is provided in Fig. 1, which schematically represents the main functional blocks and relationships to be taken into account. In particular, the energy source can be summarized by means of the functional dependence of the produced output voltage from several input parameters:

t represents time;

i
_{load} represents the current drained by the load at the given operating point;

x
_{1},x
_{2},⋯x
_{
n
} represent general parameters inherent to the modeled source (e.g., the solar irradiance and ambient temperature for a photovoltaic cell, the state of charge of a battery);

S represents the state of the system.
Modifications of the load impedance, for instance because of dynamic power management policies or, in general, because of different tasks performed by the powered system during its activity, result into changes of the load current. This variation, in turn, affects the output voltage provided by the source according to the functional relationship summarized by the currentvoltage curve. This interplay can be represented by means of a loop through which the load current is fed back as input to the system. The other loop represented in Fig. 1 highlights the possibility of taking into account some form of memory, formalized by means of the state variable S in the diagram. For instance, when emulating a battery, the state of charge of the battery represents the state of the system whose current value clearly depends on the dynamic evolution up to the current time.
The adoption of such a general framework enables in principle to emulate any type of energy source, from batteries to renewable energy scavengers. To exemplify this concept, we introduce in the following some basic features of models which can be accommodated in the architecture of the proposed emulator. Needless to say, this brief excursus is far from being exhaustive. Other models of the same sources could be implemented, and other sources could be modeled within the presented framework, thus making the proposed emulator a flexible tool for system designers to emulate a wide range of different scenarios. However, it is worthwhile to notice that the aim of this work is not a thorough implementation and discussion of different energy source models, rather the description of the emulator architecture, including its experimental validation on specific case studies as provided in Section 5.
3.1 A battery model
Battery modeling is an active research area due to the widespread diffusion of batterypowered devices in several application fields. As a consequence, many possible methodologies and models are available [26]. Again, the exploration of this design space implies the evaluation of the tradeoff between accuracy and computational complexity of the model. To evaluate the performance of the proposed emulator platform we implemented an analytical model suitable for rechargeable batteries of different types [27]. The methodology is based on curve fitting of the V(Q) discharge curve (at constant load) taken from the manufacturer’s datasheet.
The model discriminates between charge and discharge curves and describes them separately to take into account the fact that the IV curve of a battery presents an hysteresis phenomenon. The discharge curve is described by a single equation valid for leadacid, Liion and NiCd/NiMH batteries, while the charge curve is slightly different for each kind of battery. These curves are parameterized by maximum voltage, state of charge, internal resistance, polarization voltage, polarization resistance, instantaneous drawn current, and lowpass filtered current (which models the slow response of the battery to a change in load).
Every parameter but state of charge and current (both unfiltered and filtered^{1}) can be obtained from a typical manufacturer’s datasheet by applying a set of equations on three points of the experimental discharge curve. The state of charge is computed as the drawn current integrated with respect to time. In order to reduce model complexity the authors make several assumptions, namely: battery capacity does not change at different discharge rate (no Peukert effect), no effect of temperature on the model, no memory effect, same parameters for both charge and discharge, constant internal resistance, and negligible self discharge.
This approach results into a model with the following features: (i) parameters can be easily derived (only three points are required) from the battery discharge curve or even from its datasheet; (ii) the computational complexity to evaluate the model is O(1), the most expensive operation being a single floating point exponentiation for the discharge IV curve; (iii) maximum relative error on the IV curve has been estimated to be 10 % in the worst case (state of charge of 0−20 % with highly dynamic load).
3.2 Energy harvesters
A generic energy harvester is typically composed of the following elements: (i) a transducer that transforms some form of energy available from the environment into electrical power; (ii) an energy buffer, used to provide energy storage capabilities to the system; (iii) an input regulator, which provides any signal conditioning (i.e., DCAC, DCDC conversion) required to adjust any mismatch between the operating range of the transducer and that if the buffer; (iv) an output regulator in charge of adapting the signal provided by the energy buffer to the operating range required by the load. Some components can be optionally included/excluded in the scheme described so far, in some cases. For instance, the scavenger could be directly coupled to the load without any buffering or output regulator, depending on the features of the target application.
To provide a more comprehensive view of the wide range of possible sources that can be implemented within the proposed architecture, we introduce in the following two models representative of a wide number of possible energy scavenging sources, namely photovoltaic and thermoelectric cells.
Solar cells exploit the photovoltaic effect (PV) to transform solar energy into electrical energy. The electrical power delivered by a PV panel (an array of interconnected solar cells) depends on several parameters, namely, solar radiance, incidence angle, working temperature, and load impedance. Different production technologies (monocrystalline, polycristalline, and amorphous silicon) result into different IV curves, whose accurate modeling represents an issue to be addressed in order to gain insight about the amount of energy flow produced under different working conditions [28].
A common modeling approach entails the description of a PV module through an equivalent circuit with lumped components, the most commonly adopted being a circuit containing a current generator (accounting for the light generated current), a diode (used to shape the knee of a typical IV characteristic), a series, and a shunt resistor (to account for connection losses). To fully characterize the working points of a cell, the extraction of parameters from these circuit representations is carried on by means of numerical nonlinear methods [28–30]. The computational requirements posed by these numerical models are critical for their implementation on embedded realtime systems. The inherent tradeoff between convergence speed and accuracy of the emulated model is therefore an issue to be explored for the emulation of this type of energy source.
Thermoelectric cells (also known as thermoelectric generators, TEG for short) are devices capable of converting heat (given a thermal gradient across the plates) into electrical energy, exploiting the Seebeck effect. In particular, the voltage generated by a given cell is proportional to the temperature difference Δ
T through a proportionality coefficient S (the Seebeck coefficient). The converse physical process may also be observed, namely, the heat transfer between the two sides of a TEG (Peltier effect). In order to design accurate models for analyzing both transient and steady conditions and encompassing nonlinear electrical and thermal coupled effects, several methods have been proposed, leading to SPICE [31, 32] or Matlab/Simulink models [33, 34]. Other models, describing the interaction of a TEG with heat generated by CPUs (e.g., in a server farm monitoring application), have been derived by regression on the empirical relationship between temperature gradients and TEG output power (when the TEG is coupled to a DCDC boost converter) [35]. Again, the complexity of computing the model output needs to be carefully evaluated, since it may severely affect its applicability in realtime environments and its implementation on embedded platforms. Moreover, circuit models need to take into account a model of the load to be powered, which might be particularly difficult to obtain in certain cases.
3.3 Compositional models
The proposed modeling framework allows to smoothly integrate and compose different building blocks representative of a cascade of devices. Indeed, in some applications, the energy flow provided by a given harvester needs to be properly shaped for compatibility with the load to be powered. For example, voltage limiters or output stage regulators (DCDC converters) could be used to couple a photovoltaic scavenger to an embedded device equipped with integrated circuits requiring to be powered with stable voltage [28]. Another example could be represented by chips used to drive battery recharging according to optimized policies [36]. The composition of the IV curves of each single block into a suitable IV characteristic representative of the whole cascade allows us to emulate modular scavenging systems, providing a twofold benefit: on the one side we extend the emulation process to a wider spectrum of possible power source behaviors, on the other side we decouple and isolate the contribution of each single block (e.g. the photovoltaic cell and the recharge chip are separately characterized and composed) thus enabling to perform significant finegrain emulations.