From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

problem setting sampling rate

I've been developing a program that outputs either a constant DC voltage or an AC waveform (with or without a DC offset) until a release is triggered and the voltage goes to some constant DC value. This part of the program has been working very well by itself. However, I wanted to add a detection channel so that I can measure the current across our device while the voltages are applied. This is fairly well too, except that the sampling rate is off.

For sampling rates <1kHz, I get an error message that the clock rate specified is less than the minimum conversion rate of the ADC, and the data is spaced out with clusters of 0's. This wouldn't be a problem, since we'll always be using a sampling rate >1kHz, except that for sampling rates >1 kHz the actual data collection occurs at ~260 Hz (regardless of the input value for the sampling rate.

I've tried changing the samples per channel to adjust the buffer size on the DAQmx Timing, but with no change in the result.

The output source should be able to keep up with signals up to 1 MHz, so I do not think that is the problem.

It may be how I have wired the VI. I should mention that the AC output from the LabView board is fine up to 4 MS/s, which makes me think it's probably not the computer. (We're using an S-series board.)

Any suggestions? Images of the block diagram are attached.

Thanks,
Michelle
Download All
0 Kudos
Message 1 of 12
(3,017 Views)
Hey Michelle.

So if I am understanding your problem correctly, no matter what value you set the Sample Rate control, it only samples at 260 Hz? How are you determining that this is the actual rate the data is being sampled? Also, what model S-Series board do you have?

I would suggest using the Test Panels in MAX or a simple example program to verify the results. This way we can determine if this a problem with the programming or with the card itself.
Regards,

Chris Delvizis
National Instruments
0 Kudos
Message 2 of 12
(2,987 Views)

Hi Chris,

I'm determining the sampling rate by applying a constant DC signal for 30 s followed by dropping the DC signal to ground. Based on the number of points I get for this 30 s before the signal goes to ground, I estimate that the sampling rate is ~260 Hz.

We have the PCI-6110 board.

Could you give me some more specifics about how I could use the Test Panels to determine whether the board or the programming is the cause of the problem?

Thanks,

Michelle

0 Kudos
Message 3 of 12
(2,977 Views)
Michelle,

Your acuisition code seems to be correct. I am not convinced that you are correctly calculating your sampling rate. What is the sampling rate that you have set for the input? What is the number of samples you are receiving in this 30 sec time period? I have attached a link below on calculating your actual sample rate.

Also, the number if samples that are displayed in the waveform graph will only be the number of samples in the buffer. If you want to view the full history then try using a waveform chart.

You can view the Test Panels in the Measurement and Automation Explorer by right-clicking on your device and going to Test Panels. From there you can see if you get similiar results.

How Is the Actual Scan Rate Determined When I Specify the Scan Rate for My Data Acquisition?
http://digital.ni.com/public.nsf/allkb/5782F1B396474BAF86256A1D00572D6E?OpenDocument
Regards,

Chris Delvizis
National Instruments
0 Kudos
Message 4 of 12
(2,960 Views)

Hi Chris,

I've tried a range of sampling rates from 100 Hz to 10 kHz. For rates <1 kHz, I get the error message described in my first post. For 1 kHz or more, I've been calculating the actual sampling rate using the data in from the "Write to Spreadsheet" vi, not the waveform graph. In the spreadsheet, I always get ~7740 points for the 30 s signal, regardless of whether the sampling rate I've set is 1 kHz, 5 kHz, or 10 kHz.

Perhaps LabView is sampling at the correct rate, but writing to the spreadsheet file more slowly. Is it possible to check/change this?

I opened the Test Panels and recorded some data, but I can't figure out how to get the actual sampling rate from the waveform graph. Is there a way to get this data in a chart so that I can see the number of points actually recorded?

Thanks again for your help,

Michelle

0 Kudos
Message 5 of 12
(2,942 Views)
Michelle,

I did some tests and it looks the problem is in fact with the Write to Spreadsheet VI. Instead try using the Export Waveforms to Spreadsheet File VI. You can find this under Programming » Waveform » Wfm File I/O. This should save all of your points along with timing data.

Also, to put the data in a chart you can use a Waveform Chart rather than a Waveform Graph on your front panel. You can then wire the data to the chart on your block diagram.
Regards,

Chris Delvizis
National Instruments
0 Kudos
Message 6 of 12
(2,911 Views)

Hi Chris,

It looks like that was the problem. I rewired the VI to use the Export Waveform to Spreadsheet VI and a waveform chart instead of the Write to Spreadsheet VI and the graph. It's now sampling correctly. For example, I've posted the results of a 100 Hz waveform sampled at 1 kHz.

Now I'm just having one small problem that's more of an annoyance than anything... The time data doesn't include any decimal points after the seconds place. I've tried changing this by opening the front panel for the Export Waveform to Spreadsheet VI and adjusting the format and precision of the time data, but it doesn't seem to change what's recorded in the file. I'm including a screen snap that shows how I've rewired the VI as well as the menu for the format and precision for the Export Waveform to Spreasheet VI so you can see what settings I've been changing.

If you or anyone else has any suggestions on how to get it to show some decimal points in the time readout, that'd be really convenient. If not, I can always generate the time column now that I know the VI is sampling at the correct rate.

Thanks for your help,
Michelle

Download All
0 Kudos
Message 7 of 12
(2,871 Views)
What version of LabVIEW are you using. In 8.5, the Export Waveform to Spreadsheet records 6 decimal places. I think there was a bug in the subVI Waveform Time to Date Time String. Your image shows nothing about a format change that would make any difference to this. Open the subVI and modify the format string for the Format Date/time String function.
0 Kudos
Message 8 of 12
(2,859 Views)

Thanks Dennis. We are using Version 8.2, and that worked very well.

OK, I think this is my last question... Within the Waveform Time to Date Time String SubVI or in another part of the VI, is it possible to have the absolute time (which is what is currently recorded) converted to a relative time (starting at t0 = 0.000 s and counting up).

Just trying to fine tune this now so that data processing will be faster. It's definitely working well as is.

Thanks again for all the help,

Michelle

0 Kudos
Message 9 of 12
(2,838 Views)

Yes, you can do this as well. I normally just use the Write to Spreadsheet File but you can modify the Export Waveforms by doing somethinkg like is shown below. Instead of the functions Get Waveform Time Array and Waveform Time to Date Time String, this code will generate a series of relative times starting at 00:00:00. Note that this works on 8.5 and there may be some slight differences in the creation of the time string with your version. I don't have 8.2 so I can't test it. Also, since you are changing the functionality of the Export Waveform function, be sure to save it with a new name and in a new location.



Message Edited by Dennis Knutson on 02-21-2008 01:00 PM
0 Kudos
Message 10 of 12
(2,833 Views)