LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Counting number of inputs

i have an input variable, aquired by using bitin.vi, and have translated into an interger. - ie 1 for input r 0 for no input. is there a way of counting the number of inputs in a given time?
im building a heart rate monitor, and need the inputs of pulses to be counted to calculate the bpm.
any help on getting the value to add up in 10 seconds would be greatfully appreciated.
0 Kudos
Message 1 of 8
(3,977 Views)
Perhaps put it into a while loop and check to see if the variable is 1 or 0 and increment a count when it equals 1, then you could terminate the while loop after 10 seconds.
Somthing like
(just brainstorming syntax isnt right i know)
while(time != 10 seconds)
{
if(variable = 1)
count = count + 1
else
count = count
}


0 Kudos
Message 2 of 8
(3,968 Views)
Hi,
but what, if the loop is faster than the 1- pulse, i.e. the input is 1 for longer than one loopcount. Then you need something like

buffer = variable
while(time != 10 seconds)
{
if ((variable != buffer) && (variable == 1)
   count = count + 1
else
   count = count

buffer = variable
}


to count only the rising edges of the pulse

so long,
Dave
Greets, Dave
0 Kudos
Message 3 of 8
(3,960 Views)
thankyou, im doing in labview not c, so im not really sure how to do the count.
what i have been trying is to use a while loop, and i have been told to use shift registers. i will try and add a pic of it.  but im assuming the shift registers, after they have taken a value in, will do something (in this case output to a number on the frnt pannel, and then return with the same number - assuming the pulse has been recieved?
 
sorry if i dont make sense 😞 lol
0 Kudos
Message 4 of 8
(3,955 Views)

sorry i mean labview with the vi,

i will put a pic of it up in bit as i dont have the file on my pc, just on my laptop 😞

thanks

😄

0 Kudos
Message 5 of 8
(3,954 Views)
True dave, i just threw a quick VI together im not exactly sure what the OPs setup is like but i just used a button to simulate the input, i clicked it pretty fast i think if it was a heart beat going that fast it would explode lol. ( 62 beats in 10 seconds i would be bad i assume lol)
I just used the elapsed time VI for the 10 second loop termination, probably a better way to do this but just what i thought off the top of my head,



Message Edited by Ix on 04-26-2006 10:43 AM

0 Kudos
Message 6 of 8
(3,953 Views)
Why make it so complicated?  This is much simpler:




I am not familiar with "bitin.vi".  Are your pulses coming in one at a time?  In an array?  In a waveform?  If they are coming in one at a time, you can use a case structure and a shift register similar to the picture above.  If they are in an array, and the only values are 0 and 1, you can just sum the array over the time range you are interested in, and that will give you the number of pulses (look on the Numeric palette).  If you have a waveform, you can get the Y array from the waveform components and sum that array.  If you want all the pulses in the waveform, leave out the Get Waveform Subset part.



Message Edited by jasonhill on 04-26-2006 12:56 PM

Download All
Message 7 of 8
(3,938 Views)
Thanks peeps for your help on this one!
in the end i used the summation block provided in labview, which takes in the boolean pulse and adds up over a time period set by the loop it is in, and seems to work wonders. i have now got a complete temperature and pulse bpm reader, which saves to spreadsheet.
 
That case statement seems to work but not for me as the time delays cause it to miss sample the pulse, maybe my delays needed tweeking a bit, but oh well.
If you wanna see the final vi then i will post it here, but i cant just yet as the assignment is not due in yet 🙂 so pees may copy (tho i doubt many will be smart enough to ask on the official forums for help heehee but then again 🙂
tc peeps and reply if u wanna see it (i can post it to you later on in the week.)
 
thanks again.
nat 🙂
0 Kudos
Message 8 of 8
(3,915 Views)