Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using 2 Pulse Sensors: 1 Pulse Sensor has a bigger reading than the other #71

Open
Camerutttt opened this issue Apr 20, 2018 · 18 comments

Comments

@Camerutttt
Copy link

Camerutttt commented Apr 20, 2018

Hi, 1 of my Pulse Sensor outputs a higher reading as compared to the other pulse sensor. Why is that so? Here is the graph from the Serial Plotter: https://imgur.com/UXpDaQv
I am currently using the 5V pin and then connected to a breadboard column. Both pulse sensor is powered from that column. This applies to the ground as well. Should I use the digital pins instead to power the pulse sensor like how it is done in the example?
Here is the code during the measurement:

while ((millis() - measureTime) < 10000)
    {

      FastLED.show();
      if ((millis() - ledMeasureTime) > 50)
      {
        cylon();
        ledMeasureTime = millis();
      }

      currentSignal1 = analogRead(sensor1);
      Serial.print(currentSignal1);
      Serial.print(F(" , "));
      if ((currentSignal1 > 550) && (prevSignal1 < 550))
      {
        pulseTime1[pulseTime1Size] = millis();
        pulseTime1Size++;
      }

      currentSignal2 = analogRead(sensor2);
      Serial.println(currentSignal2);
      if ((currentSignal2 > 530) && (prevSignal2 < 530))
      {
        pulseTime2[pulseTime2Size] = millis();
        pulseTime2Size++;
      }

      prevSignal1 = currentSignal1;
      prevSignal2 = currentSignal2;
      //Serial.println("test");
      delay(5);
    }

Let me know if you want me to put the entire code.
x-post from: https://www.reddit.com/r/arduino/comments/8dk9q5/using_2_pulse_sensors_1_pulse_sensor_has_a_bigger/ and https://arduino.stackexchange.com/questions/51997/using-2-pulse-sensors-1-pulse-sensor-has-a-bigger-reading-than-the-other

@biomurph
Copy link
Contributor

Where are you placing the sensors? Fingertips? If you swap the position of the Pulse Sensors, do you get the same result? You are separating the two readings with Try just using a space, although I doubt that will change anything.

Can you send a photo of your Pulse Sensors? I want to verify they are made by us. There are many clones out there.

@Camerutttt
Copy link
Author

@biomurph

Where are you placing the sensors? Fingertips?

Yes, I just rest my fingertips on both sensors (Not using the velcro strap)

If you swap the position of the Pulse Sensors, do you get the same result?

Originally sensor1 is connected to A0 and sensor2 is connected to A1. After swapping the analog pins (sensor1 -> A1 and sensor2 -> A0), the 2nd sensor still read a smaller reading as compared to the 1st. This is the result: https://imgur.com/a/g7HMe3N

You are separating the two readings with Try just using a space, although I doubt that will change anything.

Tried it and it didnt work.

Can you send a photo of your Pulse Sensors? I want to verify they are made by us. There are many clones out there.

Here you go: https://imgur.com/a/BeXsvub

@Camerutttt
Copy link
Author

@biomurph I tried it with a 3rd sensor and the reading is the same as the 2nd sensor.

@biomurph
Copy link
Contributor

Please also try to leave the pulse sensors in A0and A1, and switch fingers. It could be that your circulation differs between hands. Totally possible

@Camerutttt
Copy link
Author

@biomurph tried swapping hands and its the same. It is always the 1st sensor which gives a bigger reading, never the 2nd sensor.

@Camerutttt
Copy link
Author

@biomurph
Is it possible to increase the amplitude somehow? What if I connect the pulse sensor's 5V and GND pin to an external power supply instead of using the arduino's 5V and GND ports?

@biomurph
Copy link
Contributor

biomurph commented May 9, 2018

@Camerutttt OK, that is strange. Here are a few thoughts.
First, using a separate power supply would not make a difference. The Pulse Sensor only draws ~4mA.
You could try to run them at 3V3, and see if that makes a difference. You would need to add the line
AnalogReference(EXTERNAL);
to the setup loop.

When we have the Pulse Sensor manufactured, the reels of LEDs we use are marked with a bin number that designates the brightness of the LEDs on the reel. Kingbright guarantees a range of brightness, and measures each reel after it comes out of their machines. Our manufacturer checks the bin in order to ensure that the resistor that we use to control LED current is correct for the brightness of the LED.

You could play around with the resistor to see if you can get more out of the LED on the Pulse Sensor that is giving you a smaller signal. The resistor is designated R1 on the PCB, and should have a marking on it telling you what the value is.

@Camerutttt
Copy link
Author

@biomurph When you mentioned playing around with the resistor, do you mean I should replace it with a SMD resistor of another value?

@biomurph
Copy link
Contributor

biomurph commented May 9, 2018

That's what I mean. Is that doable for you?

@Camerutttt
Copy link
Author

Camerutttt commented May 11, 2018

@biomurph Well, I will try. Just found out something very interesting though. The R1 of both pulse sensors are different as seen here: https://imgur.com/a/JjAbCC6. 1 of them is 332 and the other is 222. What should be the correct value then? Also, the op-amp for the 332 sensor is AAJK, while the op-amp for the 222 sensor is AAB2. Is there any difference in the op-amp?

@Camerutttt
Copy link
Author

@biomurph Also, not sure if this is a viable solution, but what if I take the weaker sensor's reading and multiply it by a constant, will it actually help in making it easier to identify the threshold?

@biomurph
Copy link
Contributor

The R1 resistors are different because the LEDs came from different batches. 332 is 3.3K and 222 is 2.2K. if you have the capability, you could rework the R1 on the sensor that is lower signal amplitude.

Yes, you could multiply the lower signal by 2 or 3 to increase amplitude do do that :

First subtract 512 from the raw value. Multiply by n, then add 512 back to the result.
The signal is centered around 1/2 the Voltage.

@Camerutttt
Copy link
Author

@biomurph Alright, so I guess I will have to replace R1 with a lower value to increase the intensity of the LED? I will also try the mathematical method. Basically, I need the pulse to have a big enough amplitude to accurately determine the threshold, since I am trying to find the BPM of 2 people within a timespan of 10s using this method:

  1. Find the time when each "heartbeat" occur in 10s (When the reading crosses the threshold) and store into an array
  2. Find the Interbeat Intervals (Time difference between each "heartbeat") and store into another array
  3. Find the median value from the Interbeat Intervals array
  4. Filter the Interbeat Intervals array by comparing it with the median.
    If a value in the Interbeat Interval array is within 80% of the median, add it into a 3rd array
  5. From the 3rd array, find the average
  6. Find the BPM, BPM = 60000/average (60000 since we are measuring within a timespan of 10s)

Not sure if this is a good method. Also, I am wondering does the amplitude of the pulse differ from person to person? So even if I use a very good sensor (getting high amplitudes for each pulse which allows me to determine a threshold easily), I may still get a weak amplitude when I am measuring a different person?

@biomurph
Copy link
Contributor

What you want to do sounds doable, for sure.

You will find that different people will have different amplitudes as well. This has to do with circulation, melanin, etc. Try it with math first.

@Camerutttt
Copy link
Author

Camerutttt commented May 17, 2018

@biomurph Yeah, since the amplitude are different, I cannot be using the same threshold for different people. How can I find a suitable threshold for each person without manually adjusting it in the code?

Also, what do you think of designing an oximeter looking casing, so that the pressure exerted by the people will be constant.

@biomurph
Copy link
Contributor

Check out this doc
https://github.com/WorldFamousElectronics/PulseSensorPlayground/blob/master/resources/PulseSensor%20Playground%20Tools.md
It lists the tools you can use in your sketch. There is a function call getPulseAmplitude() which returns the difference between the peak and trough of the most recent pulse wave. You can use that to 'tune' the threshold in real time. Note that the Pulse Sensor signal is centered around V/2, or 512 on the ADC (hence my recommendation to do the math if you want to 'amplify' your low signal). By watching the live beats for a while, you can get a good sense of how to use the amplitude value to tune a threshold. Something as simple as
((amplitude / 4)*3)+512
might get you in a good spot to be above noise.

Also, you can use the amplitude value to ignore small signals that might be noise...

@Camerutttt
Copy link
Author

@biomurph Alright thanks a lot. I will look into it. What about an oximeter looking design to house the pulse sensor so that everyone exerts a constant pressure? Since the documentation mentions that "goldilocks" pressure must be exerted, this will allow everyone to exert the same amount of pressure. However, I'm not sure whether the amount of pressure exerted by each person, should be different due to the difference in their blood circulation etc.

@biomurph
Copy link
Contributor

The clip you are talking about is an interesting idea, but it is a different issue. Please bring it up on it's own separate isse thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants