Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

How to convert Voltage to frequency in software

Status
Not open for further replies.

electro98221

New Member
Hi,

I have a heart pulse monitor connected to a wireless transmitter and the receiver connected serially to a computer. At the output I have series of voltage values which I need to convert to a frequency so that I can calculate the heart rate. Does anyone have any ideas? Btw I need to perform voltage to frequency calculation using c code.

Many thanks.
 
I'm assuming you mean pulses of voltage.
The easy but more costly way to do this would be with a premade computer occiliscope, or maybe just a frequency monitor device, if you go that route there are many of them in different grades, with different features.
The cheaper, but maybe far more troublesome depending on your expierence route, is to use a programmable microcontroller, program it to record the pulse rate, and set up an interface with the pc via serial or usb port. I or someone else here can expand on these methods more, but we'd need to know a bit more about your project, skills, and budget.
 
I am using a infra red method to detect the heart pulse. If I connect the output of the sensor to an osciloscope, I get a fairly good waveform of the pulses. The microcontroller on the transmitter samples the sensor output and transmits the adc values. Tha adc values are then received and sent to the computer via serial port. I have been able to read and convert the adc values to volatges in matlab. Now I need to calculate the frequency from the voltage values. My signal proceesing skills are a bit limited, someone mentioned that I could define a vco(voltage controlled oscillator) and use that to calculate the frequency but unfortunately they didnt elaborate. So essentially I need an algorithm which can give me the frequency of the heart pulses in Hz.
 
I am using a infra red method to detect the heart pulse. If I connect the output of the sensor to an osciloscope, I get a fairly good waveform of the pulses. The microcontroller on the transmitter samples the sensor output and transmits the adc values. Tha adc values are then received and sent to the computer via serial port. I have been able to read and convert the adc values to volatges in matlab. Now I need to calculate the frequency from the voltage values. My signal proceesing skills are a bit limited, someone mentioned that I could define a vco(voltage controlled oscillator) and use that to calculate the frequency but unfortunately they didnt elaborate. So essentially I need an algorithm which can give me the frequency of the heart pulses in Hz.

hi,
When you say 'frequency' of the pulses do really mean the time periods between the individual pulses of a heart beat waveform?

Assuming you could convert the adc voltage to a 'freq', what would be the purpose of that.??
 
Last edited:
well, thats an area I have little experience in, but it seems like the conversion factor to use would depend on the device. Does it have a manual, or a datasheet which tells you what the conversion factor, or equation as the case may be, is for this device?
 
Thanks for the replies. Here is a link to a pic of the oscilloscope output:
**broken link removed**
That is the waveform I am sampling. This is an older result, I have managed to make the waveform much smoother and stop it from saturating.The 1.346Hz corresponds to about 80 beats per minute. The reason I need to convert it to frequency is so that I can monitor the heart rate and perform certain automatic actions if the heart rate goes above/below certain values. I have tried a very basic method of finding the time between two peak voltage values to get the period but this is not very accurate.
 
Have a look here...**broken link removed**

A complete system although its wired....
 
Thanks for the replies. Here is a link to a pic of the oscilloscope output:
**broken link removed**
That is the waveform I am sampling. This is an older result, I have managed to make the waveform much smoother and stop it from saturating.The 1.346Hz corresponds to about 80 beats per minute. The reason I need to convert it to frequency is so that I can monitor the heart rate and perform certain automatic actions if the heart rate goes above/below certain values. I have tried a very basic method of finding the time between two peak voltage values to get the period but this is not very accurate.

hi,
Unless I am missing a point, how will converting the individual heart beat adc values into a frequency give the heart rate.???
 
Multiplying the frequency by 60 will give the number of beats per minute. If I can try and explain it in another way. If we assume that instead of a pulse monitor there is a signal generator connected to the transmitter. The signal generator is producing 1.3Hz sinusoid for example. The sinewave is sampled using a microcontroller and the adc values are transmitted. At the receiver it is simple to re-create the waveform, I simply have to plot the voltages. But, I want to be able to obtain the value 1.3Hz from the voltage values.
 
You need to write code that will extact the period between successive peaks. Typically, the signal is low-pass (digitally) filtered first, and then differentiated, working from the sampled data as stored in an array in your computer. The sign of the slope of the differentiated wave reverses at the peaks. This algorithm is well known, well documented and I sure you can find lots of discussion on the Web.
 
Last edited:
Thanks for the help. I remembered that I could also use matlabs FFT function to find the frequency but there is a lot of spectral leakage when the input frequency is non integer. I could use a softer window to remove the leakage but I think the method Mike suggested might be simpler to implement. Thanks again.
 
Look up "auto-correlation algorithms" in the context of sampled data. Another algorithm starts with a synthetic piece-wise-linear idealized heart-beat signal that you do a running convolution against your sampled waveform. When the idealized pulse best aligns with the sampled pulse, the convolution is strongest; other times is is weak. You just say "found pulse when convolution > threshold". That locates the peaks. The sampling index is the "time" ordinate.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top