Determine Velocity from a acclerometer

Hi,
Im trying to develop a device that can measure the respiration rate of a pt, but Im having trouble accurately determine the point when the chest is rissing or falling.
Im using a Tinkerkit T00002X acclerometer to try and do so was wondeering is it possible to accurately determine the velocity from this or would using a gyroscope as well help.

This is my unfinshed code:

#include <TinkerKit.h>
#include <LiquidCrystal.h>
#include <timer.h>
#include <arduino-timer.h>

int counter = 0;
static unsigned long currentime;
static unsigned long timer;
static unsigned long timerdone;
int pol[10];
int avgacc ;
float velocity = 0;
int counter2 = 0;
  int x ;
  int y ;
  int z ;
  int r ;
  int trigger = 0;
TKAccelerometer acl(I0, I1, I2); // Creates a acclerometer object
LiquidCrystal lcd = LiquidCrystal(12, 11, 5, 4, 3, 2); // Creates a Lcd object 

void setup() 
{
    lcd.begin(16, 2);
    Serial.begin(9600);
    noInterrupts();
    TCCR1A = 0;
    TCCR1B = 0;
    TCNT1 = 0;
    TCCR1B |= (1 << WGM12);
    TCCR1B |= (1 << CS11); // prescaler of 8
    OCR1A = 19999;
    TIMSK1 |= (1 << OCIE1A);
    interrupts();
}

  ISR(TIMER1_COMPA_vect)         
{
 x = acl.readX() - 484;
 y = acl.readY() - 470;
 z = acl.readZ() - 561;
  r = sqrt((x * x) + (y * y) + (z * z));
  //Serial.print(r);
    // Serial.print("   ");
  if (counter == 10)
    {
        avgacc = avgacc/10;
        trigger = 1;
     // Serial.print(avgacc);
    // Serial.print(" \n");
        counter = 0;
    }
    else
    {
      avgacc = avgacc + r; 
      counter = counter + 1;
     }        
}

  void loop() 
   {
    if (trigger == 1)
    {
      velocity = velocity + (y) * 0.1;
      pol[0] = avgacc;
         for (int i = 9; i >= 1; i--)
          {
           pol[i] = pol[i - 1];
        //Serial.print(pol[i]);
        //Serial.print(" ");
           }
        //Serial.print(pol[0]);
      Serial.print(avgacc);
       //Serial.print("     ");
      Serial.print(" \n");    
       if(pol[6] > pol[7] && counter2 == 0)
        {
          delay(100);
          counter2 = 1;
         //  Serial.print("test");
          //  Serial.print("\n");
          }
        if(counter2 == 1 && pol[5] < pol[6] )
        {
          Serial.print("test");
          Serial.print("  ");
          counter2 = 0;
          }
    trigger = 0;
    avgacc = 0;
    counter = 0;
    }   
  }

With a hobby grade module, no.

For monitoring respiration you might want to look at the millimeter wavelength radar modules that SeedStudio.com recently brought to market one app they identify is respiration monitoring. One drawback is they cost about 10 times more than an accelerometer but the user won't have to wear any sensor, plus you won't have to concern yourself with the drift of the less than nav-grade accelerometer.

hot wire anemometer will do the thing.

Well you can integrate the readings to give a velocity signal, but this will drift over time quite substatially due to the nature of these devices - you could then high-pass filter the signal to remove the drift, it might work. You'd need to keep a careful eye on phase issues doing this, perhaps a Bessel filter would be needed. Even a Bessel filter will have some delay though.

Another approach is build a drift estimator so it can be subtracted off.

Is there some reason not to use any of the devices currently on the market?

This DIY Arduino project is pretty simple, and is claimed to work: https://create.arduino.cc/projecthub/marco-polo-sauza-aguirre/breathing-sensor-1-respiration-sensor-1b18de

For a uni project need to make it myself

You will need to base your program on a breathing cycle. How will your accelerometer determine the beginning of a cycle and the end of a cycle?

It will sit on the chest or just below the pectral of the pt

But your Arduino doesn't know that and your program will not know that, so how will your program know when a breathing cycle begins and ends, based only on the accelerometer readings?

I plan on measuring when the accleration in the chest is at the greatest value, that is when the ches is rising or falling

I guess you don't care if the acceleration is + or -, then. Just ignore the sign and integrate to get velocity.

My current problem is that when I intergrate I get a drift issue the velocity continuoly increases and I am unaware of how to solve this

How long is your integration time? Should begin fresh each inhale and each exhale.

Im currently just using accleration and the values between each one seeing if that is sufficet and if I dont actually have to intergrate at all, but If I do I was planning to intergrte between every value I esseentially take a reading every 0.1 seconds

"For nasal breathing, the maximum propagation distance and derived velocity were 0.6 m and 1.4 m/s, respectively. The maximum 2-D area of dissemination and derived expansion rate were 0.11 m2 and 0.16 m2/s, respectively. Similarly, for mouth breathing, the maximum propagation distance and derived velocity were 0.8 m and 1.3 m/s, respectively. " Airflow Dynamics of Human Jets: Sneezing and Breathing - Potential Sources of Infectious Aerosols (plos.org) and that's for a sneeze.

Now to find a hobby grade thingy that can do the measurement.

ETA, An interesting write up on using the hot wire, Experimental measurement of breath exit velocity and expirated bloodstain patterns produced under different exhalation mechanisms - PubMed (nih.gov).

Good info for the hot wire technique.
human biology - What is the inlet/outlet speed of air going in/out of our mouth during inhalation/exhalation - Biology Stack Exchange,

1 Like

The op is measuring the velocity of the sternum movement, not the air velocity.

Got it. Thanks.

A while ago I was reclining in my recliner and checked my breathing. Mouth breathing cause almost no chest movement. Nose breathing was a lot of chest movement. Strange how that works.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.