Blood pressure measurement (2)

i got new trouble with reading analog value in my BPM

i want take a max value from my filter then i using this code

void peak()
  {
    #define offset 500
    #define zero 480
    #define Rsys 0.50
    
    BPmap = 0;
    int speed = 0;
    analogWrite(motorPin, speed);
    analogWrite(Valve, 674);   
    filterValue = analogRead(BP);
    
    
    int i = 0;
    int j = 0;
    
  
    for (i=0;i<40;i++)
      {
	raw[i] = 0;	
	filter[i] = 0;
        maxfil[i] = 0;
      }
    
    if (filterValue > offset)
    {
      overthresh = 1;
      if (filterValue-zero > filter[count])
     {
       filter[i] = filterValue - zero;
       raw[i] = sensorValue;
       if (filter[i] > filmax)
       {
         filmax = filter[i]; // find max filter value per aray
       }
       
       Serial.println(filmax);
       //delay(500);            
     }      
    }

full code(still not fix :slightly_frowning_face: )

const int motorPin = 5;
const int BPraw = A0;
const int BP = A2;
const int Valve = 8;
int BPsys;

int count;
int overthresh;
int BPmap;

int sensorValue = 0;
int filterValue = 0;
int maxfil[40];
int filmin = 1023;
int filmax = 0;

int raw[40];
int filter[40];


void setup()
  {
    Serial.begin(9600);
    pinMode(motorPin, OUTPUT);
    pinMode(Valve, OUTPUT);
    
  }

void loop()
  {
    standby();
    fillCuff();
    peak();
    
    
  }

void standby()
  {
  }

  
void fillCuff()
  {
    int speed = 220;
    analogWrite(motorPin, speed);
    analogWrite(Valve, 674);
    
    while(sensorValue < 700) 
      {
        sensorValue = analogRead(BPraw);
        Serial.println(sensorValue);
        //delay(50);        
      }
    
    analogWrite(motorPin, 0);          
      
  }

void peak()
  {
    #define offset 500
    #define zero 480
    #define Rsys 0.50
    
    BPmap = 0;
    int speed = 0;
    analogWrite(motorPin, speed);
    analogWrite(Valve, 674);   
    filterValue = analogRead(BP);
    
    
    int i = 0;
    int j = 0;
    
  
    for (i=0;i<40;i++)
      {
	raw[i] = 0;	
	filter[i] = 0;
        maxfil[i] = 0;
      }
    
    if (filterValue > offset)
    {
      overthresh = 1;
      if (filterValue-zero > filter[count])
     {
       filter[i] = filterValue - zero;
       raw[i] = sensorValue;
       if (filter[i] > filmax)
       {
         filmax = filter[i];
       }
       
       Serial.println(filmax);
       //delay(500);            
     }      
    }
    if (overthresh == 1)
    {
      overthresh = 0;
      count++;
    }   
    for (i=1; i<15 ; i++)
   {
    if (filter[i] > BPmap)
    {
      BPmap = filter[i];
      j = i;
      //Serial.println(BPmap);
    }
   }
    
    for (i=j; i>0; i--) 
   {
     if ((filter[i-1] <= Rsys*BPmap) & (filter[i] > Rsys*BPmap))
     {
       BPsys = (raw[i-1] - ((Rsys*BPmap - filter[i-1])/(filter[i] - filter[i-1])) * (raw[i-1] - raw[i]));
       //Serial.println(BPsys);
      // delay(2000);
       
     }
   }
  }

but at filmax, any value to read if my cuff get pressure. i just want to take max value from that filter per 1 aray.

tell me if i got wrong code, still beginner:(
im using https://www.arduino.cc/en/Tutorial/Calibration to find max value

For the more experienced readers

  • if you find errors please let me know so I can correct them.
  • if you just prefer to do things differently, may I request that you write your own Lessons in another Thread

thank you

value per filter aray.PNG

What does the code you posted ACTUALLY do?

im trying to find max value in analogRead my filter
then i try to make this

if (filter[i] > filmax)
       {
         filmax = filter[i]; // find max filter value per aray
       }

but i dont get max value from filter aray
anythere wrong from my code ?

thank you

but i dont get max value from filter aray

Quit beating around the bush. What do you get? How do you KNOW that it is not the maximum value IN THE ARRAY?

because when the cuff is under pressure or pulse of the arm will be out value up and down like a sinus , and I want to get the peak value of the pressure. when viewed from the serial monitor arduino lot of value out of each pulse such as those in the picture 90 , 100 , 111 , 120 , 100 , 80 , 70. I just want to take the maximum value that occurs each pulse in order to determine where the highest rate for value MAP .

sorry if I really beating around the bush

thanks sir for ur advice

value per filter aray.PNG

So, what ARE you getting for the maximum value?