shadowdarkness
Posts: 8
Joined: Sun Sep 13, 2015 9:35 pm

How can I design a signal conditioning unit for the Raspberr

Sat Feb 06, 2016 9:14 pm

So I am taking on a project which involves to develop a heart rate monitor using the raspberry pi. I aim to take the signal using an IR sensor and a photo-diode sensor (like a finger sensor), and have this process using the raspberry pi. I know the Pi doesn't have an ADC. I am thinking to build a signal conditioning unit for the pi as well to treat the oncoming signal, however I am unsure of where to start this. Can anyone help me or give me some advice?

Scraph
Posts: 22
Joined: Fri Feb 05, 2016 1:39 am

Re: How can I design a signal conditioning unit for the Rasp

Sat Feb 06, 2016 9:21 pm

What does the output of your photo-diode or IR sensor look like? That is where we have to start.

You acknowledge not having an ADC ... do you _need_ an ADC? Reading an analogue signal with a GPIO is called `1-bit quantization'. It's not completely inappropriate for some applications to do so.

So, first you need to figure out which exact sensors you are using ... and what their output looks like. Does their voltage range exceed that of the GPIO inputs on the RPi? Are the expected voltages too low to even register on a GPIO input?

shadowdarkness
Posts: 8
Joined: Sun Sep 13, 2015 9:35 pm

Re: How can I design a signal conditioning unit for the Rasp

Sat Feb 06, 2016 9:39 pm

Hi Scraph and thanks for replying

I intend to use a generic Transmitter and Receiver which I bought from ebay and I am using an MCP3008 ADC chip for the pi which I have already interfaced previously. Here are the specs for the sensors:

Transmitter (Tx):
Power: 0.1W.
Maximum Current (Approx): 0.5mA.
Launch Angle (Approx): 45 Deg.
Wavelength: 940nm.
Typical forward voltage drop: 1.1V.
Diameter: 5mm.


Reciever (Rx):
Power: 0.15W.
Maximum Current (Approx): 30mA.
Receiving Angle (Approx): 45 Deg.
Wavelength: 940nm.
Typical forward voltage drop: 1.2V.
Diameter: 5mm.

Scraph
Posts: 22
Joined: Fri Feb 05, 2016 1:39 am

Re: How can I design a signal conditioning unit for the Rasp

Sat Feb 06, 2016 10:05 pm

As you might've guessed, the IR transmitter is the simple part ... it's just like lighting an LED. The IR receiver is a little more difficult.

Look here to reference typical circuits involving an IR receiver ...
http://www.electronicshub.org/ir-sensor/#IR_Receiver

You can start with the simplest possible circuit for it ... it would go like:

+5 source -> IR receiver -> resistor -> ground

From the first schematic on the link I provided ... I'm basically describing the `left-half' of that circuit.

To ensure you'll never exceed the 30mA current rating of the IR receiver, you can't make your resistor any smaller than 166.666 ohms (from Ohms Law, V/I = R; 5V / 30mA).

The input for your ADC would come from between the IR receiver and the resistor. The idea is that when the IR receiver sees IR, it starts to conduct. This current flows through the series resistor and it drops a proportional amount of voltage. This voltage that you read across the resistor is proportional to the current flowing through it ... which is then related to the intensity of IR light that the IR diode is sensing.

This is basically a voltage divider where the IR diode acts as a variable resistor.

You're also going to want a small valued capacitor in parallel with the resistor ... say 1 nF or so ... which is meant to hold sense voltage while the ADC is actually sampling.

Once you get that simple circuit hooked up then you can actually start to take ADC readings ... and we can then figure out if the support circuit is sufficient and what you'll have to do to filter your readings to get the information you want.

shadowdarkness
Posts: 8
Joined: Sun Sep 13, 2015 9:35 pm

Re: How can I design a signal conditioning unit for the Rasp

Sat Feb 06, 2016 10:35 pm

This is very useful information and I really appreciate you helping me. Lets Just say we take this a level up and say we want to use these sensors to detect readings of the heart rate (just a simple recording of your heart reading). How would this be implemented?

Scraph
Posts: 22
Joined: Fri Feb 05, 2016 1:39 am

Re: How can I design a signal conditioning unit for the Rasp

Sat Feb 06, 2016 10:50 pm

That's what my last statement was alluding to...

Assuming you get analog readings from the setup I described that actually contain the heart rate somewhere in there ... you'll need to continuously sample your ADC input and filter it somehow.

You need your sample rate to be at least twice as fast as the shortest duration thing you want to capture ... so however long the `lub' or the `dub' will register on the IR receiver, you need to sample _at_least_ twice as fast as that... but I recommend something like 10 times faster.

Once you're taking samples fast enough, you want to filter the samples to minimize the noise ... filtering can be as simple as averaging every couple samples together.

So, maybe you're taking a sample every 10msec (I'm just making this number up) and your `filter' consists of you taking the average of the last 5 samples. That `average' value is your reading ... then you just have to decide whether the value is above or below a threshold that you decide on ... the threshold will simply mean `For values above this threshold, I'll call it a heart beat' and 'For values below this threshold, I won't call it a heart beat'.

Then you have to a record _what_time_ you call something a heart beat and calculate the time between then and the last time you called a heart beat... that will be how you calculate a single estimate for heart rate.

_then_ you can take those single estimates for heart rate and average them all together... to come up with your determination for heart rate. When you do this averaging, like before, you should use only a certain number of the most recent estimates.

Determining how fast to sample, how many samples to average to detect a heart beat, and how many estimates to average to determine heart rate will just have to be figured out by a little experimentation on your end.

There is `mathematical theory' that can come up with optimal values for those things ... but I'm not going to go into all that.

shadowdarkness
Posts: 8
Joined: Sun Sep 13, 2015 9:35 pm

Re: How can I design a signal conditioning unit for the Rasp

Sun Feb 07, 2016 12:44 pm

I was trying to search for some example circuit layout of connecting and interfacing the RPI with the op amp and with the ADC. I tend to see working examples to get me started. If you also have some links of this, this will be great. I have built the basic circuit so far.

Return to “Other projects”

Who is online

Users browsing this forum: Yahoo [Bot] and 13 guests