LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ write DAQ read synchronisation

Solved!
Go to solution

Hi,

I want to create the Low Pass Filter Tester with TestStand. I want to generate sine wave with frequency form 1 to 1k Hz and read amplitude before and after the filter. First of all I have to ensure synchronisation between DAQ read and DAQ write[ http://i79.photobucket.com/albums/j122/thor_tory/1_zpsab4a4c00.png~original ]. I already used a bit modified examplary sine wave generator to analog output VI and read from analog input VI. I put them as subVIs into one VI and then called it in TestStand although the read apmlitude was in many cases not even close to the generated amplitude (like the read was performed too soon). I put all subvis one by one, I also tried flat sequence structure but it was not ok because it stopped in first stage while generating sine wave.

Have you any idea how to make synchronisation between generating signal and acquiring amplitude? And what to match it to given frequency (value of frequency is increased in TestStand)?

Michał

0 Kudos
Message 1 of 18
(3,767 Views)

Hi Michal,


My suggestion is to start from the following example https://decibel.ni.com/content/docs/DOC-8023

 

Later, you should make the generation and acquisition finite, so that the execution of this VI will stop and return back to TestStand and just have to add a subVI that will process the waveforms acquired in LabVIEW. You can add another subVI in the same VI with acquisition, no need to pass the waveform data to TestStand and back to LabVIEW.

 

Best regards,

IR

0 Kudos
Message 2 of 18
(3,715 Views)

Thanks for showing me that example, I have somehow problems finding it myself :S What is the difference in using that built in clock?like in this example:https://decibel.ni.com/content/docs/DOC-26326

Having set the acquisition finite I get an error:

Possible reason(s):

Attempted to read a sample beyond the final sample acquired. The acquisition has stopped, therefore the sample specified by the combination of position and offset will never be available.

Specify a position and offset which selects a sample up to, but not beyond, the final sample acquired. The final sample acquired can be determined by querying the total samples acquired after an acquisition has stopped.

Attempted to Read Sample: 50
Property: RelativeTo
Corresponding Value: Current Read Position
Property: Offset
Corresponding Value: 0

Task Name: _unnamedTask<4F>

 I've been changing all the values but I keep on getting that error. Is there any way to make everything dependent on the frequency of generated signal(I know it is:) )? I mean like sine wave f = 100Hz

 so the f_sampling = f * 2.5 (to prevent aliasing), same thing with samples to read, does the amount of them have to be the same for every channel?

 

Michał

 

0 Kudos
Message 3 of 18
(3,682 Views)

Hi Michal,

 

Firstly, as the error states, that you are trying to read the samples that are not being yet acquired. If you have a finite acquisition, you should adapt the examples to acqurie finite number of samples.

You can do that by removing the while structure and use it either in a For loop or simply specifying the total number of samples you want to acquire.


Secondly, you are right with the Nyquist theorem, you should sample at least twice faster than the maximum frequency.  Why do you want the generation and acquisition to be dependent with every frequency you output?  Is it possible to go with the following case scenario:calculate the sampling acquisition and generation with the maximum frequency possible? 

 

I recommend you to have a look in the following manual, there are chapters that explains how the Analog Input and Output work on X Series boards.

Also, I found a very nice white paper that explains the synchronization between AI and AO.http://www.ni.com/white-paper/3615/en/

 

Best regards,

IR

 

 

0 Kudos
Message 4 of 18
(3,677 Views)

(...)

Secondly, you are right with the Nyquist theorem, you should sample at least twice faster than the maximum frequency.  Why do you want the generation and acquisition to be dependent with every frequency you output?  Is it possible to go with the following case scenario:calculate the sampling acquisition and generation with the maximum frequency possible? 

(...)


What I want to do is to change the input frequency of the sine wave, that will be done in TestStand sequence and passed as a parameter to the VI. I want to be certain that for each given frequency I will obtain true value of the amplitude of the signal. So I'll be able to gather the data before and after the filter for frequency in range 1 Hz - 1 kHz with step 10 Hz and plot its frequency response.

While talking about removing loop did you mean to remove it entirely, it does not touch the generation of the sine wave?

Michał

0 Kudos
Message 5 of 18
(3,668 Views)

Hi,

 

Let me see if I understand correctly:

 You want to pass data from TestStand to LabVIEW as f1, f2 and you will do a sweep between the two frequencies (f1,f2)?

Or, you want to have a stept that for any give frequency you will generate a finite amount of samples and the VI will return the amplitude and the frequency measured and you will call this step "n" times from TestStand and at the end of n steps you will plot the result?
Basically, for "n"step as frequency sweep you can do it at once in LabVIEW or you can do n times the same step with different frequencies.


How do you want to build it?

 

Best regards,

IR

 

 

 

0 Kudos
Message 6 of 18
(3,664 Views)
I want to pass only frequency of the signal to be generated. After the vi is executed I want the amplitude before and after the filter to be sent to testand and in testand I will increase the value containing frequency and call vi again up to the set max frequency eg. 1kHz

Michał
0 Kudos
Message 7 of 18
(3,656 Views)
Second option you typed is that what I want to accomplish. As soon as I get home I'll make simple graph or put the screen from TestStand. For now most of things seem towork apart from DAQ read/write 😉
Michał
0 Kudos
Message 8 of 18
(3,652 Views)

Hi Michal,

 

Please do not duplicate forums posts, I have also found that you posted the same question http://forums.ni.com/t5/LabVIEW/DAQ-signal-generation-and-read/m-p/2645433#M789588

 

Also, to answer your question:

 

In order to make an example from continuous to finite, you have to change the constant at the Timing VI but also to remove the while loop.

Please use the following tutorial http://www.ni.com/white-paper/3615/en/ it is very well described how can you sychronize AI and AO.


Basically, in the figure2, you have the complete flow of application needed, the only thing you have to change is the frequency of the sinewave.

 

Best regards,

IR

0 Kudos
Message 9 of 18
(3,643 Views)

Ion, 
Sorry for doubling the topics but I thought that none would answer.. Perhaps I formulated the topic incorrectly and then You came with help. 

Thanks for almost ready program. It seems to solve the problem. I'll test it on university as soon as I can. Then I'll let know, here. Should I worry about the samples per channel in DAQmx Timing block or it will always generate the full period of sine? At home I simulate the card and it is always same wave(A=10V; some frequency) and full period is read. I tried to follow: http://www.ni.com/white-paper/3698/en/#toc3 in order to simulate different signal but it says like the card is busy (while the data is 'generated' in signal express). It looks like I will have to wait till then.

 

Michał

0 Kudos
Message 10 of 18
(3,613 Views)