LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ examples: Cont Acq&Graph Voltage-To File (Binary) >> How to change sample rate and continue?

I am trying to use Cont Acq&Graph Voltage-To File (Binary) from the DAQ examples. I need to alternate the sample rate, however, based on a condition linked to one of my DAQ channels (slow down sampling when data isn't very interesting, speed up when data is interesting). I can successfully exit the acquision loop when the condition result changes and change the sample rate, but when I go back to the acquistion loop, it rewrites over the data that was already there. I've looked into configuring the write file to start at the end of the file (as opposed to starting at the marker with the default value), but this seems to distort the data acquired from my DAQ card. I've also tried abstaining from closing the file, reopening the file, and putting a header on it, when I exit the loop to change the sample rate (so I just set the DAQ tasks and skip the file subroutines). But then I get an error which tells me the GPIB controller is required to have control... blah, blah. Which I don't understand at all, considering that I'm not even using my GPIB. Attatched is my code. Help!
0 Kudos
Message 1 of 8
(4,254 Views)
Hello.
Some comments: you are trying to record data to a file at different adquisition sample rate, and that could be a problem when precessing back the data, since you have no reference or timing.
The binary recording you are using is a kind of data logger, that is quite critical if you change data input on the fly.
My suggestion is: use a I16 write vi in append mode to record the binary data whitout timing reference.
Use waveform record vi to write data if you want to read it back with timestamp and dT.
Shoul you want to use the write method, you will have to carefully study hig level write vis to see how to manage change of data.

Hope it helps
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 2 of 8
(4,247 Views)
Take a look at attached vi. It is a way of using data logging changing adquisition speed
Cheers
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 3 of 8
(4,241 Views)
Thanks for the response. I think you are right about the binary file write. It seems that I need a header, which contains the sampling rate, in order to read a binary file. Because I can only have one sampling rate in this header, it converts from discreet to continuous with this rate in mind, and the data sampled at a different rate with be distorted. We plan on including a signal from a function generator (with appropriate frequency) as one of our channels to deduce our timing. The write to I16.vi works well, i've noticed. The only problem is that I'm having trouble converting the data from unscaled to scaled data (the main vi for this also seems to require a header). I just need to find the appropriate amplitude calculation, but it doesn't seem to be clear from looking at the block diagram. Any suggestions? Also, I'm using LabVIEW 7.0, and that subroutine wouldn't function. Have a 7.0 compatible version?

-clay
0 Kudos
Message 4 of 8
(4,234 Views)
Hello,

I saved the previous attached VI for LabVIEW 7.0. Does this work for you?

Regards,
Sean C.
0 Kudos
Message 5 of 8
(4,217 Views)
Hi
If using read binary I16, yo can write directly using I16 write. No need to scale.
Now, about digitizing at 2 speeds ang get coherenten data.
If want to write binary instead of waveform, you can use a way similar tothis one:
1.-Te digitized data is recorded in a temporary file
2.-During the adquisition process, keep track of speed changes and associate speed and position of record in file as an index for recuperation (example: build a table using I from while loop and dig speed ). All this info builds up the header. At the end, the temporary file is appended to the header file an data is ready to be recovered.
3.- Other option: on every read, add a character to your data and record as dataloggger data.( see labview example about datalogger). You can timestamp every read.

Hope it helps
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 6 of 8
(4,207 Views)
Why wouldn't I need to scale? I need double precision numbers, eventually. But if I write scaled data to an I16 file, it rounds all of my data. I actually found the appropriate scaling factor. The problem is that it's not very accurate. Here's what I dug up:

unscaled value / (2^16) * (Vmax-Vmin)

Have any idea why this doesn't result in accuracy?
0 Kudos
Message 7 of 8
(4,193 Views)
Hi

see attached doc
and this thread:http://forums.ni.com/ni/board/message?board.id=250&message.id=2854&requireLogin=False

Post back explaining what data type you want to read and save

Cheers
Alipio
---------------------------------------------------------
"Qod natura non dat, Salmantica non praestat"
---------------------------------------------------------
0 Kudos
Message 8 of 8
(4,183 Views)