Introduction: Cardio Data Logger

About: Retired Electronic Engineer, 'reborn' circuit designer after working life in Technical and General Management

Although nowadays many portable devices (smartbands, smartwatches, smartphones,...) are available that can detect the Heart Rate (HR) and perform trace analysis, chest strap belts-based systems (like the one in the upper part of thr picture) are still widespread and used, but lacking the possibility to record and export the trace of the measurements.

In my previous Instructable Cardiosim I've presented a chest strap belt (Cardio) simulator explaining that one of my next steps was to develop a heart rate data logger. I'm now ready to present it in this Instructable. The function of this portable unit is to receive the HR signal sent by a chest strap belt (or the Cardiosim simulator) during a traning session (workout/cycling/running,...) and to record the trace on a SD card, in order to perform an after-training performance analysis (see details in the last chapter).

The unit is powered by a rechargeable battery system, including charging circuit and DC boost regulator.

From my "warehouse" of unused material I fished out a a suitable plastic case (135mm x 45mm x 20mm) and adapted to it the layout of the circuit to fit together, making a working prototype that fulfills my needs (but whose realization leaves room for improvement :-))

Step 1: Brief Description

Please refer to Step 1 of the Cardiosim Instructable for a quick introduction about the LFMC (Low Frequency Magnetic Communication) technology used by this kind of devices.

My first intention was to use the Sparkfun RMCM01 module as receiver interface, but this product is no longer available (let alone that it was anyway quite expensive).

However, looking on the WEB, I found this interesting Tutorial, which shows some alternative solutions to replace the RMCM01. I chose the 3rd option ("Peter Borst Design", thanks Peter!), achieving an excellent result using the same L/C components of the Cardiosim, however connected here as parallel resonant tank. The detected signal is amplified, "cleaned", decoded and forwarded to an Arduino Pro Mini microcontroller. The program validates the received pulses, measures the heart rate (or better the interval between two successive pulses) and stores all measured intervals in an ASCII text file (one line per valid pulse, 16 characters each including interval, timestamp and LF/CR) in the microSD card. Assuming an average HR of 80bpm, an hour recording needs only (4800 text lines x 16 characters) = 76800 / 1024 = 75kBytes, therefore even a cheap 1GB SD card offers plenty of recording capacity.

During the recording you can insert marker lines to divide the trace and evaluate separately different session phases.

Step 2: LiPo Power Supply - Schematics, Parts & Assembly

The Power Supply occupies the bottom of the case. Except for the trimpot no component exceeds 7 mm height, which gives room to mount the HR receiver and microcontroller circuit above the power supply.

I used the following parts:

  • 3.7V LiPo battery (any phone battery can be recycled, reduced capacity is not an issue here)
  • USB TP4056 charging module, I bought it here
  • SX1308 DC boost converter, I bought it here
  • Small prototyping board 40 x 30 mm
  • Cable with JST connector 2,54mm 2 pin, like this one
  • (optional) JST connector 2mm 2 pin, like this one
  • (optional) Cable with JST connector 2mm 2 pin, like this one

The use of last two items depends on the battery you will use and the way you intend to connect it to the charger module. I suggest the 2mm JST connector because many batteries are delivered with already attached cable and 2mm plug, any other solution is adequate as long as it allows an easy replacement of the battery if needed. In any case, be careful to avoid short circuits between the battery poles during the assembly.

The TP4056 module is powered from a micro USB port and is designed for charging rechargeable lithium batteries using the constant-current / constant-voltage (CC/CV) charging method. In addition to safely charging a lithium battery the module also provides necessary protection required by lithium batteries.

The SX1308 is a high efficiency DC/DC Step Up Adjustable Converter that keeps the output voltage constant at +5V with a minimum input voltage of 3V, thus allowing the complete exploitation of the battery capacity. Adjust the output voltage with the trimpot at +5V before connecting the microcontroller circuit!

The total consumption of the Data Logger is around 20mA, thus even a used battery with a residual capacity of 200mAh (< 20% of the initial capacity of a new phone battery) will allow 10 hours recording. The only drawback is that the SX1308 quiescent current is around 2mA, so you better disconnect the battery if you don't use the Data Logger for a long time.

Because of the small size, both modules need to be fixed using the connection holes both for electrical and mechanical connection with the prototyping board, through short pieces of copper wire. In turn the board is attached to the base of the case with a 3mm x 15mm screw (the length is enough to fasten the microcontroller circuit above with the same screw). The board hosts the JST 2mm connector for the battery (available only in SMD version, but folding the pins vertically you can "turn" it in a PTH version) and all the wirings according the schematics. Just to be sure, I glued the body of the connector to the board achieving a good mechanical seal.

The battery is placed flat in the remaining area of the case bottom, and behind it there is a second 3mm x 15mm screw with a 8mm vertical spacer to avoid contacts between the top of the battery (which is anyway insolated) and the bottom of the upper circuit.

Step 3: HR Receiver and Data Logger - Schematics, Parts & Assembly

The main board consists of:

    • Prototyping board 40mm x 120mm
    • Inductance 39mH, I used BOURNS RLB0913-393K
    • 2 x Capacitor 22nF
    • Capacitor 4.7nF
    • Capacitor 47nF
    • Capacitor 39pF
    • Electolytic Capacitor 10uF/25V
    • Electrolytic Capacitor 1uF/50V
    • 3 x Resistor 10K
    • 2 x Resistor 100K
    • 3 x Resistor 1K
    • 4 x Resistor 220R
    • Resistor 1M
    • Resistor 47K
    • Resistor 22K
    • Trimpot 50K
    • Diode 1N4148
    • LED 3mm Blue
    • 2 x LED 3mm Green
    • LED 3mm Yellow
    • LED 3mm Red
    • Dual Low-Noise JFET-Input Operational Amplifiers TL072P
    • Hex Inverting Schmitt Trrigger 74HC14
    • JST connector 2.54mm 2 Pin, like this one
    • 2 x microswitches, Alcoswitch type
    • Microcontroller Arduino Pro Mini, 16MHz 5V
    • Micro SD card module SPI 5V from DFRobots

    The resonance frequency of the parallel resonant tank composed by L1 and C1 is around 5.4kHz, which matches close enough the 5.3kHz of the magnetic field carrier of the transmitted signal to convert it into a voltage. Remember that, in most of the cases, the carrier is modulated on the base of a simple OOK (On-OFF Keying) format, where each heart pulse switches the carrier "ON" for about 10ms. The detected signal is very weak (tipically a 1mV sinewave at a distance of 60-80cm from the source, provided that the axis of the inductance is properly aligned with the magnetic field), thus it needs to be carefully amplified to avoid interferences and fake detections. The proposed circuit is the result of my best efforts and of hours of testing in different conditions. If you are interested in deepening this aspect - and maybe improving it - take a look at the next step, otherwise you can skip it.

    The following Schmitt Trigger gates perform the digitalization and a peak detection function, restoring the original modulating signal, which is forwarded to the Arduino Pro Mini.

    The Pro Mini microcontroller board is perfect for this project because the crystal on board allows a high precision of the measurements (which are essential under the "medical" point of view, see last step), and at the same time it's free from any other not needed device, which results in a low power consumption. The only drawback is that to load the code you will need an FTDI interface to connect the Pro Mini to the USB port of your computer. The Pro Mini is connected to:

    • Switch S1: start Recording
    • Switch S2: insert Marker
    • Blue LED: flashes when a valid pulse is detected
    • Green LED: Recording started
    • Yellow LED: Marker inserted (short blink) / Timeout (fixed)
    • MicroSD card module (through SPI bus)

    Differently from many SD card modules which operate at 3.3V, The DFRobot module operates at 5V, so no level shifter is needed.

    As for the assembly, you may notice that I've divided the prototyping board in two pieces, connected with two small "bridges" of rigid 1mm copper wire. This has been necessary to elevate the MicroSD card module to a third "construction level" and align it with the recess I've carved on the case, just above the slit for the USB port.
    Furthermore, I carved three recesses on the board itself, one to access the potentiometer of the DC/DC converter, another to access the connector of the serial bus of the Arduino Pro Mini (mounted "face down"), and the third for the inductance.

    Step 4: HR Receiver - Spice Simulation

    Starting from the Peter Borst's design I've mentioned before, my goal was to try to extend the detection range as much as possible, at the same time limiting the sensitivity to interferences and the generation of false pulses.

    I decided to change the original single Op-Amp solution because it has proven to be too sensitive to interferences, probably because the value of the 10M feedback resistor is too high, and to split the overall gain in two stages.

    Both stages have a DC gain G =100, decreasing around 70 @5.4KHz, but with different input impedance to optimize the sensitivity.

    So let's assume that the voltage of the weakest signal generated by the LC tank is 1mV.

    If we transpose the whole receiver circuit in a Spice environement (I use ADIsimPE) replacing the LC parallel circuit with a sine generator with the same voltage and frequency (5.4KHz) and run the simulation, we notice that the output voltage V1 from the 1st amplifier is still a sinewave (due to scale factor the input sinewave is not appreciable), t.i the amplifier is working in the linear zone. But after the second stage, the output voltage V2 shows that we're now reaching the saturation (Vhigh = Vcc-1.5V / Vlow = 1.5V). In fact, the TL07x family is not designed for rail to rail ouput range, but this is enough to exceed with a safe margin both treshold levels of the Schmitt Trigger gate and generate a clean squarewave (V3).

    Step 5: Software

    Because of the high gain of the receiver stage, and despite the peak detector stage acting basically as a low pass filter, the input signal on pin D3 of the Arduino Pro Mini can still be strongly disturbed and needs to be digitally pre-processed through a validity check against false detections. The code ensures that two conditions are met to consider a pulse as valid:

    1. The pulse must last at least 5ms
    2. The minimum acceptable interval between two successive pulses is 100ms (corresponding to 600 bpm, far beyond the limit of a severe tachycardia!)

    Once the pulse is validated, the interval (in ms) from the previous one is measured and stored on the SD card in a file "datalog.txt", together with a timestamp in hh:mm:ss format, where 00:00:00 represents the time of the last reset of the microcontroller. If the SD card is missing, the red LED lights up indicating error.

    A new recording trace can be started/stopped with the Start/Stop switch S1, and will be identified by a ";Start" and ";Stop" marker line respectively at the beginning and at the end of the text file.

    If no pulse is detected for a time longer than 2400 ms (25 bpm), a marker line ";Timeout" is placed in the file and the yellow LED D4 is switched on.

    If the Marker Switch S2 is pressed during recording an additional marker line in the format ";MarkerNumber", with automatic increment of the marker number starting from 0, is written in the file, and the yellow LED flashes shortly.

    Attached the complete Arduino code.

    Step 6: Initial Set-up and Testing

    {"context":{"location":{"href":"https://www.instructables.com/editInstructable/edit/E4N91WXJDYUVMKV","origin":"https://www.instructables.com","protocol":"https:","host":"www.instructables.com","hostname":"www.instructables.com","port":"","pathname":"/editInstructable/edit/E4N91WXJDYUVMKV","search":"","hash":""},"jQuery11240941698885590256":1},"selector":"#editor-Object-64"}

    Step 7: Usage - Medical Signal Analysis

    The form of the enclosure I used is close enough to the one of a smartphone so you can find on the market plenty of accessories to wear it or to mount it on a workout equipment. In particular for the bike I can suggest the universal smartphone mount named "Finn", produced by the Austrian Bike Citizens company. Cheap (€ 15,00) and easy to mount, it is really universal and as you can see in the picture perfect also for the Cardio Data Logger

    The simplest way to use the raw data recorded by the Data Logger is to plot them in a graph using standard PC programs (e.g. Excel). By comparing graphs obtained repeating the same exercise, or analysing the correlation between HR variations and physical efforts, you may optimize the dosage of forces during the activity.

    But of greatest interest is the study of the HR, and in particular of the HR Variablity (HRV), for medical purposes. Unlike an ECG track, the HR trace does not contain direct information about the functioning of the cardiac muscle. However, its analysis from a statstical point of view allows to obtain other information of clinical interest.

    The most comprehensive knowledge source about HRV is the Finnish KUBIOS company. On their site you can find a lot of information about Biomedical Signals and you can download "KUBIOS HRV Standard", a free heart rate variability analysis software for non-commercial research and personal use. This tool not only allows you to plot graphs from a simple text file (you must remove the timestamps) but also to perform statistical and mathematical evaluations (including FFT) and produce an incredibly detailed and valuable report, like the one attached below.

    Rembember that only a specialized physician is able to decide what exams are needed for sports practice at any level, and to assess their outcomes.

    This Instructable has been written with the sole intent to create interest and fun in applying electronics to health care.

    I hope you enjoyed it, comments are welcome!