LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Having problem with different sampling rates

I am attempting to write a VI that will take raw data from a (ultrasonic) height measuring device. I want to input the data into a spreadsheet of time against the values as the height changes.However, when I look at the spreadsheet,it has the time values (the process was run for 15 sec in the example) and 300 samples, but the height value stops at about 213 samples, is there some way

1) I could sync the sampling?
2) or at least get the total number height values to match the time?

I have attached the vi.  and the sample output .It was done in 7.1


I would also like to be able to 'zero' the  value of the height so that I can get a displacement (after presetting a high value and low value) but that is secondary.
any help would be appreciated.

Download All
0 Kudos
Message 1 of 7
(3,234 Views)
Hi engr2b,

Thanks for posting to the NI Discussion Forum. I cleaned up your code quite a bit and posted it back below. Could you please comment your code so that we know what it's intended to do? I also added some edits (explained below) that I believe accomplish your goal.

What it appears you are doing is getting your height data from a Serial Port Read and also generating Time data on each iteration of the loop. If there are more iterations of your while loop than there are elements of height data, you will experience the difference in number of elements which you have witnessed. This timing data does not necessarily correspond correctly with your height data anyway. Your height measuring device should have some sort of sampling rate. If you know the sampling rate, you can use that information to build a waveform (shown in attached VI) and write to a measurement file. Keep in mind that the t0 is acquired from the system clock on the first iteration of the loop and is not provided by the instrument.

If you want to "zero" the value of your height, you can acquire the current height that you want to "zero" at, and then once you acquire all of your data, subtract that "zero" data from the array. I hope this helps!
0 Kudos
Message 2 of 7
(3,209 Views)
Hello Mike

Thanks for the quick response. I  ran the VI but the time from the GET TIME/GET SECONDS VI does not show up
on the spreadsheet ( see below) nor does it output any time values.

Just for your reference, I add the time table so that I could compare the time between the countdown value and the time to check see if the
process is in sync.It is just for monitoring for now.

This is what the VI does, it takes serial input from the ultrasonic distance measuring device (used to measure height). The device is homemade
and seems to pulse at 14 samples per second. One inputs the countdown value in the VI and runs it to get the data and corresponding time which
is then stored in the excel readable file. At the end of the countdown, a tone is generated.
Later on, I will have  sequence to 'zero' value so that I can have an inital minimum and maximum displacement (calibration) before running the data aquistion sequence so
that the time values will correspond with displacement.
For now, I am just concerned with the getting the time and height values to match.

The VI  you seems much better than what I had but it does not produce send time (in seconds) to the spreadsheet. anyway this could be sorted? Thanks in advance for your help.
I have attached the updated VI with comments and a sample of the spreadsheet output.
0 Kudos
Message 3 of 7
(3,200 Views)
attachments
Download All
0 Kudos
Message 4 of 7
(3,197 Views)
Hi engr2b,

Thanks for your reply. First, I noticed that you specified dt as 0.014. Keep in mind that this is not the same as 14 samples per second that you specified in your post. The dt is closer to 0.0714. As seen in the spreadsheet you attached, the VI does in fact produce time data. The X_Value column in the .xls file you attached contains the time data. The t0 is contained in the Date/Time of the first header. If you want to write the date/time in seconds for each data point, you can use the Set Waveform Attribute for the Relative Time attribute. See the LabVIEW Help for more information on the Set Waveform Attribute VI.

The downfall of this is that it writes the date/time in seconds and not a date/time string to the measurement file. If you want to write the Date/Time string to the text file, I recommend taking a look at the Write to Text File.vi example found in the Example Finder. This is probably closer to what you want. I hope this helps!


Message Edited by lion-o on 01-17-2008 01:50 PM
0 Kudos
Message 5 of 7
(3,177 Views)
Hello Mike

Thanks for your reply.sorry I could not reply sooner, my cable was down.You are right on the dt. I changed it and added afew things to the  VI. I have used the number of samples and dt to give me a relative time frame( see .xls outputs below).
I have also developed the VI further to include another Input through a DAQ board. The goal of the VI is to aquire the height data and the data from the DAQ board, put them in one spreadsheet which will then be further analysed.
However, I have to new road blocks. I would like the VI to beep sequantially every 1/3 of the time input time until the countdown gets to zero. e.g, if input time is 6 secs, a tone will be generated at t=6,t=4,t=2 and t=0.I have the t=0 sorted. I tired the time delay vi, but is slowed down the VI, is there another way of implementing this?
2. I need to 'zero' the height value, so that I can get inital low zero and inital maximum height ( calibrate the height) and then run the test over the that range and record the displacement values to the spreadsheet.The storing of values is done, but I have not been able to crack the 'zeroing/tare' issue I have tried to get examples using the loop back VI to get a tare value, but they are all implemented in 8.0 of heigher. Is there a simple way to using the loopback to store the 'zeroing' value.

I have attached the updated VI and an example of the current .xls output. The first column is the time,second is height, the voltages are from the DAQ

If you can give me direction on those two issues, it would be greatly appreciated.Thanks again for your help, it is really appreciated.
Download All
0 Kudos
Message 6 of 7
(3,144 Views)
Hi engr2b,

1) You already have your VI set up to grab the time on each iteration and you're comparing it to the start time of the loop. You can simply perform the necessary math to see if the time has elapsed at least 33%, 67%, or 100% of the time that is specified to run for. These comparisons can then trigger the beep. Since your comparison will be true for every succesive iteration of the loop, you can use the First Call? function to only beep once for each condition. I've attached an example below that demonstrates this. I added a 250 mS delay so that you can visually see the LEDs change. Also make sure to set the Number of Sec control.

2)As I mentioned before you can have your code grab the height data from your device before the execution of your loop begins and use this default value to subtract from all your height data acquired in your loop. My included my version in an edit to your VI.

Both of my implementations are merely hacks to your existing code. It's very likely that more eloquent solutions exist and I encourage you to see what you can come up with as well. I hope this helps!


Message Edited by lion-o on 01-23-2008 07:19 PM
Download All
0 Kudos
Message 7 of 7
(3,112 Views)