Design of the intelligent energy-saving cardiotachometer based on Mbed

: In order to deal with the shortcomings of a photoelectric mode cardiotachometer, such as wasting energy and slowly refreshing results, this study mainly focuses on a real-time displayed, portable, low-cost, and energy-saving cardiotachometer. The design is based on the Mbed, which is the core microprocessor, controlled and dispatched by the built-in function. Before filtering and amplifying the electronic signal, the pulse signal is collected by the photoelectronic sensor at the beginning of the whole process of the cardiotachometer. The energy-saving function can be achieved through audio p-type metal oxide semiconductor to switch on and off the light-emitting diode (LED) which is in the sensor. Eventually, the real-time ratio of the heartbeats and the waveforms can be displayed on the two 8 × 8 LED modules at the same time with overall energy-saving of about 50%. This design can be applied in many fields focusing on long battery life and portable, especially as a part of a wearable device.


Introduction
About 2 million people die because of cerebrovascular disease (CVD) each year, which is the most critical reason of death among all kinds of diseases and with the highest cost to cure [1]. The morbidity of CVD is increasing year by year and the patients are becoming younger. The reason for this phenomenon is that the CVD takes place abruptly with severe symptoms and is hard to detect, let alone prevent.
Nowadays, in most of the hospitals, there are un-carriable or un-wearable cardiotachometers. The un-carriable ones could be used to monitor the heartbeat, but they are inconvenient in daily life. As for wearable ones, they are used much, easily operated, and accessible [2].
The wearable ones are categorised into piezoelectric type and photoelectric type based on the rule of the working of the sensor. The piezoelectric type ones usually use a kind of film with high sensitivity, but low accuracy and high complexity. Photoelectric type ones are sensitive but expensive [3], time-consuming, and energy consuming.
This design uses photoelectric pattern, but using the Mbed as a processor, taking full advantage of the interrupt in function which is the inherent function of Mbed. This impulse meter, consisting of a quick dispatch, control, computation, cardiotachometer, and waveform real-time display, solves the real-time display problem, which is the shortcoming of products on the market. Its accuracy is as high as 98%. Using the high-frequency signal provided by Mbed controls the p-type metal oxide semiconductor (PMOS), establishing the energy-saving control circuit, realising energy saving ∼50%, and solving the current products' consumption problem in the market. The design satisfies the public expectation to observing and detecting of heart rate and its waveform so that they can understand the condition of the body more comprehensively and concretely, so as to make it have certain promotion value [4][5][6].

System design
A heart has a cardiac systolic and diastolic function, and it is like a pump that puts oxygen and other nourishment to all parts of the body. That is the reason why the input oxygen density in tissue is different from that of the output; thus, the absorption for light is also distinct. Also, the input and output each time corresponds to one beat. The design uses the difference in the rate of oxygen in the human's biological tissue at one pulse beat to measure the heartbeat. As there are abundant blood vessels in fingers, fingers are selected as the experimental object [2], which is easy to operate.
To make the meter have better performance and show the result timely and accurately. The whole system is divided into five modules: signal generation, filter and amplifier, controlling and scheduling, energy saving, and display. Fig. 1 shows the block diagram of the whole system. The Mbed is controlling and scheduling to finish all parts cooperation.

Hardware design
2.2.1 Signal produce: With the help of photoelectric sensor TCRT1010 [7], the heartbeat signal can be gotten by putting the finger on it. This sensor is composed of two parts -a light-emitting diode (LED) and a bipolar junction transistor (BJT). The structure is like shown in Fig. 2. A resistor is serial to the BJT. The light density through finger differs when a heartbeat appears. The higher light density, the higher the current through the fixed resistor, so that the voltage change of the resistor corresponds to the heartbeat. Therefore, the heartbeat signal is transferred to the electrical signal. According to the datasheet of the optical sensor, the LED needs a resistor to restrict the current through it. Moreover, based on the V-I relationship of the BJT, which is shown in Fig. 3, the resistance could be obtained. According to the datasheet, the operation state should be in the linear region and the current through the LED is bigger, the changing of the current to the voltage of a BJT is more significant. Therefore, the electrical output result would be more obvious and easily acquired. After some experiments, the current through the LED is about 37 mA. The circuit for signal producing is like shown in Fig. 4.

Filter and amplifier:
In a natural environment, there are a number of noising signals, such as TV, mobile phone, and alternating current lamps. These signals would distract the heartbeat signal. Therefore, restrictions of these signals are important to make a good performance. In general, the heartbeat is 60-80 times per minute, which corresponds to 1-1.3 Hz. Taking running and some special conditions, such as scare into consideration, the range of the filter is selected to be 0.1-13 Hz. After several times of calculation and experiments, the times of amplifying is 30 to fit the range of analog digital converter (ADC) in Mbed. The circuit is like shown in Fig. 5. The design adopts a passive high pass filter and an active low pass filter which are used to reduce the noise and to amplify the expected signal [8]. The formula of the cut-off frequency is In this experiment, j is an imaginary number, ω is angular velocity, R is the resistance of the resistor, and C is the capacitance. 1 µF capacitance and 820 kΩ resistor are selected to work as a high pass filter and 22 μF capacitance and 470 kΩ resistor work as a low pass filter, which compose a bandwidth filter to reduce the noise effect. As an active filter, it also has the function as an amplifier. The formula to calculate its times is This result is based on the experimental output of the optical sensor and the range of the ADC of Mbed.

Energy saving:
The most energy-consuming part of the circuit is the LED in TRCT1010. Actually, the signal is not necessary to be used all the time. According to the theory of sampling (Nyquist's theory), the frequency of sampling, which is two times larger than the frequency of the heartbeat is enough, and the system could collect and recognise the complete pulse, so that a PMOS could be controlled by pulse width modulation (PWM) as a switch to turn on and off the LED. A PMOS is put in front of the LED of the sensor with a high-frequency signal from Mbed. In this design, 100 Hz is selected to control. As the PWM which produces high-frequency signal from Mbed does not consume a lot of energy, when the duty ratio 50 is adapted, it could save about half of the energy, comparing with the one without PMOS. The energy circuit is like shown in Fig. 6.

Controlling and scheduling:
The microprocessor used in this design is Mbed from NXP, whose code is LPC1768 and CPU Note that all the numbered pins (p5-p30) can also be used as DigitalIn and DigitalOut interfaces. The function could be used, and the code could be compiled through the Internet, which improves the compatibility of it [9]. The supply voltage is 5 V and the output voltage is 3.3 V. In this design, interrupt in function which could recognise the rising edge of the heartbeat is used. From the heartbeat diagram, the voltage signal changed significantly with a giant slope. That is the reason why this function could be applied. As for ADC, the Mbed could transfer the analogue signal to digital signal based on the sensitivity of the digital lights and transport specific command to the digital lights by SPI to realise the waveform display. PWM controls the PMOS to switch on and off to save energy.
Comparing to the Mbed in the same family, such as LPC11U24, the LPC1768 operates faster and gives the opportunity to timely display. Moreover, the powerful function library makes it fit this design.

Displaying module:
Performing module is composed by Max7221 and 8 × 8 LED. Max7221 is responsible to accept data and drive the digital lights which are shown in Fig. 8. The design uses two performing screens, one for waveform and another for the heartbeat. The structure is shown in Fig. 9. During the operation, the highest voltage Mbed could output is 3.3 V, but the minimum voltage Max7221 could recognise as '1' is 3.5 V; therefore, several buffers are needed to raise the voltage.
The driver Max7221 also has the responsibility of controlling the intension of the light. In this experiment, the lowest light intension is selected in order to reduce consuming energy.

Software design
To realise display heartbeat timely, the design does not adopt the method that is counting the heartbeat in a fixed time and calculating the heartbeat in a minute based on the proportion but adopts measuring instantaneous heart rate (IHR) which means that the time between two heartbeats (period) is measured. After that, the heartbeat per minute is calculated based on the period. Eventually, the heartbeat display could be achieved. Assuming that the heartbeat period is T seconds, the formula of the IHR is Interrupt in function which is the inherent function of Mbed is used to recognise the positive edge as the beginning and next one as the end. This function could execute some commands if the slope of the voltage is bigger than the threshold, which is fit in this experiment, then the former formula (3) is used to calculate the heartbeat in 1 min. If the outcome is abnormal, such as >150 or <40, these outcomes could be automatically filtered out and the screen would show the heartbeat in the last time. The waveform is shown on 8 × 8 LED according to the input voltage. The PWM function could make a square wave with a fixed period and duty cycle. Therefore, if fitting period to the PMOS is selected, the PMOS could on and off in this period with the acquisition the waveform of the heartbeat completely. This method could realise the goal of energy saving and guarantee the accuracy of the result. Figs. 10-13 show the main programme and each subroutine diagram.

Results
The design adopts signal generation, filter, and amplifier, controlling and scheduling, energy saving, and display five modules. The whole cardiotachometer could be in 5 cm × 5 cm scale. After comparing the result of this equipment and the actual heartbeat, the accuracy is ∼98% and the error is ∼±3, shown in Table 1.
Based on the comparison of measuring results and the actual heartbeats in different age groups, the measured ones are close to the actual ones in most cases shown in Fig. 14. So, the measurement of this design is accurate.

Conclusion
After the testing of the cardiotachometer, it can show the waveform and the heartbeat accurately with saving energy 50%, which accomplishes the initial objectives. Therefore, with the characters such as small scale, accurate, saving energy, and timely displaying, it could be widely used in real life. If elders have some heart  disease, they could check their heartbeat any time to know whether there is any problem. With it in the watch or bracelet, it also can record the changing range of the heartbeat and know the health condition and eventually give people some advice to improve their health. Thus, the ratio of the disease might be reduced to some extent. However, in real-life texting, some drawbacks or flaws are found. Different people have different heartbeat intensity, but the recognition of heartbeat is based on its slope. So, if someone's heartbeat is relatively insignificant, the machine may ignore it and get the wrong answer. That would be fixed in a further experiment.
In further design, the heartbeat characteristic in some environment and situation could be taken into consideration, such as facing robber or having disease related to the heart. The alarming function could be used to transfer information to the servicer, realising the Internet of things [10]. There are many products that need the measurement of the heartbeats, which means that the accuracy of the heartbeat is important. Besides, in order to get the amount of results of the heartbeat, the energy consumed should be relatively low. The design is fitting to those two properties. Amount of data could be gotten and used to machine learning. The characteristics of heartbeats can be related to some specific condition. As for lie detector, generally, most people might get nervous when they are lying, leading to the rise of heartbeats dramatically. With applying this design, the fluctuation of heartbeats can be displayed on the two screens. What is more, to some extent, the heartbeats reflect the emotion, such as some specific range of heartbeats correlated to happy or sad. When the experiments increase, the relationship between them could be more observed and the results are more accurate. Their families and the relative officer could recognise the situation the people facing and give them some help [11][12][13][14][15][16].

Acknowledgments
The author would like to thank Kathleen Meehan, a teacher from the University of Glasgow in the United Kingdom, for instructing and also Chenhui Zhu and other students for help.