The development and validation of electronic devices, requires to perform a series of tests organized to solicit inputs and outputs with signals very similar to those of the real world. In recent years, hardware in the loop (HIL) [
1,
2,
3,
4] methodologies have been added to traditional testing technologies. These are based on the joint simulation of a physical model with a real device through appropriate interfaces [
4,
5]. The idea is to have a model of the real world or part of it that is simulated in real time by appropriate hardware simulators that interact with the system under test through analog or digital peripherals. These methodologies, born mainly for the aerospace and power electronics sector, are also extending to other electronic devices, especially for critical applications. Think for example of medical therapy devices that must interact with a person or part of a person [
6,
7,
8]. During the development and validation phase of medical devices, the patient cannot be involved in the design process for several reasons including the fact that the pathology to be resolved must be induced in the patient just when the device is being tested, which is not easy to implement. Having a model that allows to simulate the desired pathologies when and how you want is of great support to the developer of the biomedical device control system. The original contribution of this paper is (in
Figure 1 the main architecture of the paper is shown) to create a framework for the automatic testing of biomedical devices that must interact with the human heart (pacemakers, ECG analyzers, etc.) and be able to implement different models of heart. The method presented here, of the hardware in the loop to simulate a biological mechanism such as the human heart, is effective and innovative. In fact, it allows the close-to-reality reproduction of various conditions, without the involvement of the human being. The result is a powerful simulator, which is easy to utilize and user friendly, that, at the same time, is able to replay various situations, both physiological and pathological, thanks to the possibility of variation of the parameters in the simulation. The advantages of this in the clinical field are, due to the safety of this method; the ability to reproduce human functions without the involvement of humans and animals, the possibility of repeating the trial an infinite amount of times, the excellent cost–result compromise and the immediacy of real-time simulations that allows the reproduction of many conditions in a short amount of time. We started implementing several heart models taken from literature, as realistically as possible, on which some pathologies can be reproduced. Most of the models considered are based on oscillators that act as variable speed biomechanical pumps, such as those largely discussed in [
9,
10,
11,
12,
13,
14]. In this paper we decided to show only one of this based on implementation of a set equations originally developped by E. Ryzhii and M. Ryzhii in [
14] and rearranged to be implemented in a Hardware in the Loop simulator Acting on the parameters of the oscillator it is possible to change the characteristic of the generated signal, enabling the simulation of different heart conditions (it could be controlled to exhibit tachycardia, bradycardia and atrial fibrillation) and also to take into account the variability due to the population characteristics [
15]. The used model [
14] is structured in two different parts: the first one describes the electrical conduction system of the heart, through the sino-atrial node (SN), the atrioventricular node (AV) and the His–Purkinje fibers (HP), the second part is focused on the resulting ECG. The electrical conduction system of the heart is described using the delay differential equations, where the time derivatives at the current time depend on the solution and possibly its derivatives at previous times. In our simulation, we did not use a delayed differential equation, and we instead had a delay in the zeta domain, which is typical of the block implementation inside the HIL simulator. The value of the variables of the equations will determine four currents, that will be added in the equations of the four waves constituting the ECG, that is described using complex ordinary differential equations (ODEs). Then, the parameters were varied to reproduce some cardiac diseases, in particular tachycardia, bradycardia and atrial fibrillation, as well as others. This part of the the model is constituted by an experimental work: an accurate analysis of the individual parameters in the electrical conduction system of the heart is done, to understand how they affect the shape of the ECG . The main findings are used to reproduce atrial fibrillation, tachycardia and bradycardia. The experimental setup has been implemented by means of a HIL simulator, to run both the physiological and pathological condition. The main application of this model is the validation of the pacemakers. Pacemakers normally have sensors to detect events directly in the heart tissue, such as atrial sense and ventricular sense. Using the information from the sensor, the pacemaker decides whether and when to generate a stimulus to the heart [
16,
17]. The test of device is done in physiological and pathological conditions: if the heart is simulated affected by bradycardia, the pacemaker produces the spikes and restores the normal rhythm; otherwise, if the rhythm of the simulated heart is physiological, the pacemaker is silent. This implementation has been proposed by us for the first time and allows the coding of two models (heart and pacemaker), taken from the literature for two real-time simulators, which are then connected and used to test the control algorithms present in the pacemaker. This last step allows one to verify the effectiveness of the model and to show a concrete application: in fact, the test of a pacemaker before its use is a crucial step that must be carried out for the safety of the patient and, thanks to the use of a HIL simulator, both safety and speed can be assured. The adopted model of the pacemaker, implemented on an embedded system (
Figure 1), becomes an integrant part of the HIL framework. In this way, it is possible to create a system heart and pacemaker combination, presented for the first time, that can be tested under many different conditions, and effectively test the functionality and safety of an invasive tool such as this pacemaker. This paper is original as it proposes a model that can demonstrate the effectiveness of the HIL simulator and the innovation and the benefits that its use would bring to the biomedical sector.