LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sampling frequency Fs and number of sample #s in a waveform

Hi there,

 

It is probably a stupid question but I am still going to ask it:

 

I do not completely understand why in the "Basic Function Generator.vi"  there is a distinction between the number of samples #s and the sampling frequency Fs..?

What is the purpose to have more or less samples in the generated waveform then specified by the sampling frequency of the signal?

 

I hope this question make sense (or am I missing something obvious)?

 

thanks,

Best,

Renaud 

0 Kudos
Message 1 of 11
(7,159 Views)
The number of samples defines how many cycles of the waveform to generate.
0 Kudos
Message 2 of 11
(7,152 Views)

#s / Fs is the time duration of the output waveform.  The default is one second at 1kHz  Often you want a different length of time in the waveform.


"Should be" isn't "Is" -Jay
0 Kudos
Message 3 of 11
(7,149 Views)

Thanks for those prompt replies.

 

I thought it was like this by playing with those values but I was not sure.

 

I am sending those values to an AO (to a mechanical system that reproduce the sended waveform) and record the signal with an AI. My problem is that when I reduce the number of sample as explained in the previous message, I enhance the number of cycles i.e the time of the signal seen by the AO but it does not seem to apply to the AI... see attached image (Fs = 305000 #s=30500 AO is in white AI is in red)

 

Why does the #s only affect the time of AO and not the one of AI? (the number of cycle is the same though, only the time base is different)

 

Thanks,

Best,

Renaud#s.png

0 Kudos
Message 4 of 11
(7,137 Views)

rihns wrote:

I am sending those values to an AO (to a mechanical system that reproduce the sended waveform) and record the signal with an AI. My problem is that when I reduce the number of sample as explained in the previous message, I enhance the number of cycles i.e the time of the signal seen by the AO but it does not seem to apply to the AI... see attached image (Fs = 305000 #s=30500 AO is in white AI is in red)

 

Why does the #s only affect the time of AO and not the one of AI? (the number of cycle is the same though, only the time base is different)


I think we need to see some code in order to get the full picture of what you are doing.  The number of samples of the AO should have nothing to do with the AI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 11
(7,123 Views)

Yes, this is what I thought...

 

attached is the code, do not hesitate to make as much comment as you can 🙂

 

Thanks,

Best

0 Kudos
Message 6 of 11
(7,113 Views)

You really should have your Fs set to your DAQ sample rate.  You can use Bundle By Name to update the Fs to match rate gx.

 

You should also be using Build Array and Index Array instead of the Combine Signals and Split Signals.  This avoids the super annoying Dynamic Data Type and actually avoids data copies.

 

And as long as your loop rate is decently fast, you shouldn't need to play around with the buffer size of your analog input.  Just leave the number of samples unwired so that you clear the buffer.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 7 of 11
(7,102 Views)

Those DDTs - Get rid of them use buid array and index array:

Capture1.PNGY

You will save yourself a huge headache

 

Timing of the wavforms you generate with the Basic Function Generator vi's is ignored by DAQmx Write.  The task timing is set with DAQmx Configure timing and there is no other way to change the timing.  (Unless you use a DAQ Assistant and select the use wafeform timing box But, I don't recommend it and changing the timing dynamically with a waveform may cause some unexpected results)

 

All of wich then points to the obvious reason that only the AO sees any change from the wavform parameters-  The AI Task has no data dependance on Basic Function Generator.vi


"Should be" isn't "Is" -Jay
0 Kudos
Message 8 of 11
(7,092 Views)

Thanks for those replies (I got rid of the DDTs)!!

 

Crossrulz:

If I remove the options on the buffer I get an error... can this be due to the fact that there is a delay of around 12ms in the signal acquisition (see image)?

Why do I need to have rate(in timing.vi) equals to Fs (in the function generator.vi)? If I try to do rate=Fs my Vi does not work anymore...

 

Jeff:

How do I change the timing.vi to get a writting/aqcuiring signal more than 1sec?

When I change the number of sample #s in the Basic Function Generation it is still changing the number of cycle on the AO and AI(but not the time though)...

 

Thanks,

Best,

Renaud 

0 Kudos
Message 9 of 11
(7,048 Views)

delay.png

0 Kudos
Message 10 of 11
(7,042 Views)