LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing Data Dynamically to an A/D converter

Solved!
Go to solution

Thank you very much for that detailed explanation!

There are  only two questions left:

1) With Regeneration Off and a defined output buffer, is it still necessary to configure the data transfer from the output buffer to the onboard buffer as mentioned in a previous post? (Data Request Transfer Condition set to empty or less than half full)

2) Why are underflow/overflow errors necessarily a problem? In the ideal case, the VI would produce some samples, wait until enough space is free in the output buffer and then write additional samples (although I am not sure if the DAQmx Wrie writes sample by sample or has to wait until enough space for the whole array/waveform is available). How should I circumvent this polling the free buffer size available? When I do this on my test machine, I get strange values of 2, 4, 97 or whatever, even though I configured my output buffer to 4000 and tried to write waveforms of a size of 1000 samples.

 

Best,

Phage

 

0 Kudos
Message 11 of 16
(1,037 Views)

Hey Phage,

 

1) You can try leaving this property on "Onboard Memory Empty", but this might result in an error. So better set it to "less than half full". Since you are writing to the DAC not that rapidly, this shouldn't be a performance issue.

 

2) Well actually you're right, Just be aware, that if you use a 4000 sample buffer, you will have 4s of signal in your buffer, so the shortest time to change the output to a different state is 4s. If you want to have a more "responsive" output, so making it react faster to your software-commands, you might consider using a big buffer, but only using a part of it. But I think you don't need that, so basically you just need to set your output-buffer to 2xPackageSize and you should have a constant output without delays in it.

 

Best,
Jan Göbel

Staff Applications Engineer

0 Kudos
Message 12 of 16
(1,031 Views)

Hey Jan,

 

thank you for your reply!

 

I wrote a little VI in which I produce a simple function which is then written to the D/A converter (see the VI attached). There is one last problem with the analog wave generation I don't understand. As you see in the attached VI, I used an analog waveform generation based on a function input, which should allow me to control the potential change rate. However, when the sample clock rate of the DAQmx Channel is higher than the sample rate, which is defined for the analog wave, the slope of the waveform increases. To be honest, I am not sure what is supposed to happen when the sample clock runs at a different rate than the sampling rate of the waveform: I thought defining the sampling rate of the waveform just defines the time difference between each sample. Is this also significant for the 't' of the analog waveform generation? And furthermore, what does the higher sample clock rate of the D/A conversion do with a "slower" waveform? I.e. if the sample clock rate is twice the waveform sampling rate, does this mean that each data point is produced twice by the D/A converter?

 

Best wishes,

Phage

0 Kudos
Message 13 of 16
(1,022 Views)

Hi Phage,

 

without having a deeper look at your code I can tell you, that the Waveform-Rate (dt) has no effect on your DAQmx-Output. The Waveform-Datatype is a cluster of 3 Values, a 1D-Array containing the data, a dt-value (samplerate) and a t0-value (start-time). These are all just used in software. Passing a waveform to the write function in your case is exact the same, as passing a 1D-Array of double to it. In both cases the values are outputted with the defined DAQmx Sample Rate.

 

The only thing that might be affected by this is the frequency of the signal you generate, you can use the sampling-info-terminal on the node to define how many samples are generated and what period of time this generated signal should represent. So if you double the Samplingrate on the function generator and then output it with the same DAQmx-Sample-Rate as before, your signal will be half as long.

 

But again, the only thing interesting for DAQmx is the 1D-Array within the Waveform!

 

Best,
Jan Göbel

Staff Applications Engineer

0 Kudos
Message 14 of 16
(1,019 Views)

Thank you again for your explanation, it really helped a lot.

 

Best wishes,

Phage

0 Kudos
Message 15 of 16
(1,002 Views)

Perfect, I hope everything will work now, if you have more trouble during development, just leave another post.

 

Best,
Jan Göbel

Staff Applications Engineer

0 Kudos
Message 16 of 16
(1,000 Views)