Coder Social home page Coder Social logo

Comments (9)

biomurph avatar biomurph commented on August 29, 2024

@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.?

from pulsesensor_amped_processing_visualizer.

VeiTheOne avatar VeiTheOne commented on August 29, 2024

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;
  }
}

from pulsesensor_amped_processing_visualizer.

biomurph avatar biomurph commented on August 29, 2024

@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.

from pulsesensor_amped_processing_visualizer.

VeiTheOne avatar VeiTheOne commented on August 29, 2024

from pulsesensor_amped_processing_visualizer.

VeiTheOne avatar VeiTheOne commented on August 29, 2024

Ok, Email looks like shit.

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

from pulsesensor_amped_processing_visualizer.

VeiTheOne avatar VeiTheOne commented on August 29, 2024

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

And they don't have an issues page.

from pulsesensor_amped_processing_visualizer.

biomurph avatar biomurph commented on August 29, 2024

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?

from pulsesensor_amped_processing_visualizer.

VeiTheOne avatar VeiTheOne commented on August 29, 2024

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".

from pulsesensor_amped_processing_visualizer.

biomurph avatar biomurph commented on August 29, 2024

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.

from pulsesensor_amped_processing_visualizer.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.