PulseSensor_Amped_Processing_Visualizer icon indicating copy to clipboard operation
PulseSensor_Amped_Processing_Visualizer copied to clipboard

Not displaying BPM and IBI

Open VeiTheOne opened this issue 1 year ago • 9 comments

It says in the code that it's TODO for next project. Has anyone done this second project?

Plus, how can I have it show the BPM and IBI? I am using the Phidget VINT hub if that's a factor.

VeiTheOne avatar Mar 24 '23 16:03 VeiTheOne

@VeiTheOne Please provide more information to help troubleshoot your question. What exactly in the code is not functioning as expected? What other code are you using with the code in this repo? What hardware board are you using? Etc.?

biomurph avatar Mar 24 '23 17:03 biomurph

I am using Phidget's VINT Hub as the board. The Graph visualizer works fine, and I have been trying to get it to display the BPM. The code works, there's just nothing to get the BPM. And I'm using the code listed here.

Here's my current code, which is unchanged.

import com.phidget22.*;


VoltageRatioInput heartSensor;
Scrollbar scaleBar;

PFont font;
PFont portsFont;

//Holds heartbeat data
float [] pulses;      
float [] scaledPulses;   

float zoom;
color eggshell = color(255, 253, 248);

//Sizing of windows
int PulseWindowWidth = 490;
int PulseWindowHeight = 512;
int BPMWindowWidth = 180;
int BPMWindowHeight = 340;

void setup() {
  size(700, 600);
  frameRate(100);
  font = loadFont("Arial-BoldMT-24.vlw");
  textFont(font);
  textAlign(CENTER);
  rectMode(CENTER);
  ellipseMode(CENTER);

  //Create scroll bar for zooming
  scaleBar = new Scrollbar (400, 575, 180, 12, 0.0, 1.0);
  
  pulses = new float[PulseWindowWidth];
  scaledPulses = new float[PulseWindowWidth];
  
  //Default zoom
  zoom = 0.75;                               

  //Drawing
  resetDataTraces();
  background(0);
  drawDataWindows();
  drawHeart();
  fill(eggshell);

  //Phidgets initialize 
  try {
    //Create
    heartSensor = new VoltageRatioInput();
    //Address
    heartSensor.setHubPort(0);
    heartSensor.setIsHubPortDevice(true);
    //Open
    heartSensor.open(1000);
    //Set data interval to minimum | This will increase the data rate from the sensor, and make your graph more responsive
    heartSensor.setDataInterval(heartSensor.getMinDataInterval());
  }
  catch(Exception e) {
    e.printStackTrace();
  }
}

void drawDataWindows() {
  noStroke();
  fill(eggshell);
  rect(255, height/2, PulseWindowWidth, PulseWindowHeight);
  rect(600, 385, BPMWindowWidth, BPMWindowHeight);  
}

void drawHeart() {
  fill(250, 0, 0);
  stroke(250, 0, 0);
  smooth();
  bezier(width-100, 50, width-20, -20, width, 140, width-100, 150);
  bezier(width-100, 50, width-190, -20, width-200, 140, width-100, 150);
  strokeWeight(1);
}

void drawPulseWaveform() {
  float pulseVal = 0;
  try {
    pulseVal = (float)heartSensor.getVoltageRatio();
  }
  catch(Exception e) {
    e.printStackTrace();
  }
  
  pulses[pulses.length-1] = ((pulseVal - 0.5)* 512);   //pulseVal is between 0 and 1. Center and scale up to fit window.
  zoom = scaleBar.getPos();  
  for (int i = 0; i < pulses.length-1; i++) {
      pulses[i] = pulses[i+1];                         // shifting all raw datapoints one pixel left
      scaledPulses[i] = pulses[i] * -zoom + height/2;  // adjust the raw data to the selected scale
  }
  stroke(250, 0, 0);                               
  noFill();
  beginShape();                                  
  for (int x = 1; x < scaledPulses.length-1; x++) {
    vertex(x+10, scaledPulses[x]);                    //draw a line connecting the data points
  }
  endShape();
}

void draw() {
  background(0);
  noStroke();
  drawDataWindows();
  drawPulseWaveform();
  drawHeart();
  
  fill(eggshell);
  text("Pulse Sensor Amped Visualizer - Phidgets", 245, 30);
  text("IBI",600,585); // TODO for next project
  text("BPM",600,200); // TODO for next project
  text("Pulse Window Scale " + nf(zoom, 1, 2), 150, 585);

  //Manage scroll bar
  scaleBar.update (mouseX, mouseY);
  scaleBar.display();
}

void resetDataTraces() {
  for (int i=0; i<pulses.length; i++) {
    pulses[i] = height/2;
  }
}

VeiTheOne avatar Mar 24 '23 18:03 VeiTheOne

@VeiTheOne That is not the code that is in this repo. I don't have experience with Phidget.

You may need to ask the source of that code about your problems.

biomurph avatar Mar 24 '23 18:03 biomurph

Well, I’m just trying to get a bpm calculation working for an upcoming competition. Thanks tho. Sent from Mail for Windows From: Joel MurphySent: Friday, March 24, 2023 2:50 PMTo: WorldFamousElectronics/PulseSensor_Amped_Processing_VisualizerCc: Vei The One; MentionSubject: Re: [WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer] Not displaying BPM and IBI (Issue ***@***.*** is not the code that is in this repo.I don't have experience with Phidget.You may need to ask the source of that code about your problems.—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***> Virus-free.www.avast.com

VeiTheOne avatar Mar 25 '23 01:03 VeiTheOne

Ok, Email looks like shit.

Well, I’m just trying to get a bpm calculation working for an upcoming competition. Thanks tho.

VeiTheOne avatar Mar 25 '23 01:03 VeiTheOne

You may need to ask the source of that code about your problems.

And they don't have an issues page.

VeiTheOne avatar Mar 25 '23 14:03 VeiTheOne

You may need to ask the source of that code about your problems.

And they don't have an issues page.

Dang. Is there any community around it? A forum or anything?

Our PulseSensor Arduino library does all the work to find the heartbeat in the signal and derive BPM and IBI. What are you using for heartbeat detection? What hardware? Or are you simulating?

biomurph avatar Mar 25 '23 15:03 biomurph

We got 3 pulse sensors from Phidgets. And I can't seem to find it. We were able to display the raw voltage, but none of us have yet to figure out how to get it to display the BPM. What's worse is that they said on the Phidgets page says "Stay tuned for part two." of the project. There has never been updates since, and that's where I'm stuck at, sadly.

I'm using a VINT HUB0001_0 from Phidgets as the "board".

VeiTheOne avatar Mar 25 '23 19:03 VeiTheOne

Interesting. Looks like a lot of engineering for some simple interfacing.

It would take some ramping up for us to make PulseSensor compatible with Phidgets. Give me a bit of time to investigate how their tech works.

biomurph avatar Mar 26 '23 15:03 biomurph