Respiratory Rate Measurement

Thread Starter

kalemaxon89

Joined Oct 12, 2022
389
Hi everyone.

I should measure respiratory rate using a bandage that varies in resistance if it is stretched or not. It's tied around the chest and its length vary and change its resistance: let's assume that R increases when you inhale (rib cage widening) and decreases when you exhale (rib cage narrowing).
I converted this resistance variation into the range [0 .. 3V], filtered the signal and then gave it as input to a microcontroller.
My ideas for detecting respiration rate are these two below, I kindly ask you to tell me the pros/cons of both (especially the first one):

(1)
As explained in the figure, I calculate the respiratory rate like this: 1 breath ≈ 1 period ... so "respiratory rate" = number of periods(breaths) per minute
SmartSelect_20231017_173656_Samsung Notes (1).png

(2)
I run the FFT of this signal (Vadc) and choose as "respiratory frequency" the frequency at which the peak (the maximum amplitude) of the FFT is located. I am still not very convinced about this solution because I honestly do not fully understand it yet, however, it seems to me to be a good approach.
 

Jerry-Hat-Trick

Joined Aug 31, 2022
824
Unless the subject is breathing heavily most inhalation and exhalation is from the diaphragm, with little or no movement of the chest wall. If you are doing this for an athlete you should be okay, someone at rest I'd be sceptical. The idea of a band which changes resistance when stretched sounds interesting - I wonder if this is more of a challenge than the electronics. Maybe a slide (fader) potentiometer? Or a custom made variable capacitor with opposing plates moving over each other? I'd be interested to learn how you plan to do this.

FFT does sound a bit like overkill. Zero crossing as suggested by MrChips sounds good. Analog pre-processing so the peak and trough are averaged and variable gain and offset used to spread the signal to cover most of the A/D range would allow for variations between subjects.
 

Thread Starter

kalemaxon89

Joined Oct 12, 2022
389
I would count the number of zero-crossings in 60 seconds and divide the result by 2.
Thanks for the advice!
So if I'm not wrong:

1) I should add an offset to shift down the sinewave signal from [0 .. 3]V to about [-1.5 .. 1.5]V and then (again using hardware) detect the zero crossing of the sinewave.

2) The "zero crossing output signal" consist of pulses, each pulse indicates that the sine wave has crossed zero from positive to negative or vice versa, right? I knew it could be done in several ways, for example: comparator + filter or with an optocoupler or phototransistor. Since I will send these pulses to a GPIO of the microcontroller that will read the state of the GPIO ... what method do you recommend for me to create this "zero corssing circuit"?

The digital part is not a problem, on the analog part I might need some more help!
 

MrChips

Joined Oct 2, 2009
34,817
Zero crossing can be detected in many ways. If you are going to digitize the signal, there is no need to shift the signal. Simply use a threshold value that is mid-way between the min and max value. In software, convert the signal to LO-HI by using a digital comparator in software.
 

Thread Starter

kalemaxon89

Joined Oct 12, 2022
389
I would count the number of zero-crossings in 60 seconds and divide the result by 2.
Unless the subject is breathing heavily most inhalation and exhalation is from the diaphragm, with little or no movement of the chest wall. If you are doing this for an athlete you should be okay, someone at rest I'd be sceptical. The idea of a band which changes resistance when stretched sounds interesting - I wonder if this is more of a challenge than the electronics. Maybe a slide (fader) potentiometer? Or a custom made variable capacitor with opposing plates moving over each other? I'd be interested to learn how you plan to do this.

FFT does sound a bit like overkill. Zero crossing as suggested by MrChips sounds good. Analog pre-processing so the peak and trough are averaged and variable gain and offset used to spread the signal to cover most of the A/D range would allow for variations between subjects.
I tried simulating an optocoupler by getting a spike (blue line) for each elapsed period.
By sending the output signal (blue) to an analog pin set in "read mode" of the microcontroller, I can count via software how many times the pin goes HIGH and determine how many periods have passed.
Respiration rate = number of periods in 60 seconds = number of times GPIO goes HIGH in 60 seconds
(there is no need to divide /2 because there is no zero crossing if you choose to do it that way, its working principle is a little different from the one from a few posts ago)
SmartSelect_20231019_171738_Samsung Notes.png
I randomly chose the frequency of the green sine wave! I also could have put 1k but it does not matter for the purpose of understanding the operation.

Of course theory remains theory, I will see after the physical implementation what happens. Maybe there is the risk that there are too many false positives or that this method is too susceptible to random errors ... we will see!
 

MrChips

Joined Oct 2, 2009
34,817
You can do that and send the digital signal into a GPIO pin as external interrupt on pin change (or rising or falling or both).
Count the number of interrupts in a 60-second duration.
 

Thread Starter

kalemaxon89

Joined Oct 12, 2022
389
Zero crossing can be detected in many ways. If you are going to digitize the signal, there is no need to shift the signal. Simply use a threshold value that is mid-way between the min and max value. In software, convert the signal to LO-HI by using a digital comparator in software.
Do you think using an optocoupler is a bit like overkill for this application? Maybe a simple comparator (LM358) or something else could do the same job and bring less "trouble" (?)
@Jerry-Hat-Trick
 

MrChips

Joined Oct 2, 2009
34,817
Do you think using an optocoupler is a bit like overkill for this application? Maybe a simple comparator (LM358) or something else could do the same job and bring less "trouble" (?)
@Jerry-Hat-Trick
Maybe.
You may not need a comparator. Just feed the analog signal into a GPIO input, after first clamping the signal to GND and Vcc.
Some MCUs already have analog comparator inputs.
 
I still think that your biggest problem in practice is the variation between subjects of the signal offset and peak to peak difference. Apart from that, breathing just with the diaphragm will be a show stopper. It is still a vital sign which is hard to monitor with instrumentation - clinicians still mostly just count when they are at the bedside!

This is why I suggested "Analog pre-processing so the peak and trough are averaged and variable gain and offset used to spread the signal to cover most of the A/D range would allow for variations between subjects". By that I mean, read the signal into the processor, look for the value of peaks and troughs, then adjust the gain and offset, maybe with digital resistors so that the peaks and troughs are roughly equally spaced above and below the centre voltage.

Years ago, before the availability of cheap analog front ends I made a rudimentary SPO2 reader primarily for pulse rate. The attenuation difference of light through subject's fingers is significant, it's a similar problem.

Once you have a reasonable signal read into the processor there are a number of ways you could calculate the respiratory rate and dividing by 2 (shift left) may just be the easiest. One in the processor you can write code to check the consistency rate and trigger an alarm if it changes too rapidly, or stops altogether. And decide how to respond if it misses a breath

I don't think you need an opto-coupler, keep everything low voltage battery driven. I'm looking forward to seeing your results.
 
Last edited:
Top