Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Frequency resolution of analog out card

Hi ,
I am using PXIe 6738 analog out card . I m trying to generate different sinusoidal waveform frequencies with the help of this card. I want to generate frequency in the resolution of 1 Hz for example - 5001Hz , 5002Hz , 5003Hz , Etc. 
I m using create task function of NI max .  giving three inputs to the software mentioned below .
1, Generation mode- Continuous ( always fixed)
2.Samples to write
3. Rate (Hz)
4. Terminal Configuration - RSE
 
I am able to achieve a resolution of 2.5 Hz with no. of samples per cycle =10 . Formula used to calculate sampling frequency is as follows
sampling frequency = Generated frequency * no. of samples / cycle
 
Please suggest how to do it .
 
0 Kudos
Message 1 of 9
(2,962 Views)

First: have a look at the specs and the manual.

Usually

the DAC samplerate is not arbitary .. (Without digging into the details, I suspect something like 100MHz/n (n something like 100 to ???). You can check the actual used samplerate by reading the 'actual samplerate' property after a commit of the configuration.

the samplerates are limited due to memory transfer

the internal memory is limited

 

So, to create a waveform of a specific periode you need to choose a valid samplerate and fit n periodes into m samples. Sometimes the samplesize is also not arbitary, so m must be a multiple of 2 or 4 ....

 

For such low frequencies and a DMA able PXIe I expect no problems to continously stream the wfrm (save data: use U16 😉 )

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 9
(2,950 Views)

In agreement with Henrik, just offering some thoughts in my own words.

 

You'll end up choosing between a simple but limited solution and a complicated but 

more nearly exact solution.

 

1. A simple solution will want to define 1 cycle of the sinusoid with a sufficient # of points (20 is fairly decent, more is better, depends what the signal's used for).  Then you'll want to set a sample rate that makes that waveform cycle at the desired waveform frequency (such as 5001 Hz).

    There will be quantization effects that will prevent you from landing exactly on many of the frequencies you're aiming for.  You'll often be pretty close, but rarely exact.

    And that's about it, simple but limited.

 

2. One more complicated method will require you to continually calculate and write the next chunk of points to the task while it's running.  This is one way around the quantization effect.  By no longer restricting yourself to define exactly 1 cycle of the sine at a time, you can define 0.997 or 0.9942 of a cycle instead.  That will allow you to generate your exact waveform frequency, but to accomplish it, you have to keep continuously calculating and writing new samples to the task, always starting and ending at different parts of the sine wave, to make a continuous-looking waveform.

 

3. Another more complicated method is to work through the problem in rational approximation that will let you fit N cycles of the waveform into M periods (as Henrik already mentioned) pretty much exactly.  Then you can again write this bigger buffer once only and the task will keep repeating it.  I wrote this up in a thread a *very* long time ago, but happened to add a useful (IMHO) update pretty recently.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 9
(2,941 Views)

@Kevin_Price wrote:

In agreement with Henrik, just offering some thoughts in my own words.

 

You'll end up choosing between a simple but limited solution and a complicated but 

more nearly exact solution.

 

1. A simple solution will want to define 1 cycle of the sinusoid with a sufficient # of points (20 is fairly decent, more is better, depends what the signal's used for).  Then you'll want to set a sample rate that makes that waveform cycle at the desired waveform frequency (such as 5001 Hz).

    There will be quantization effects that will prevent you from landing exactly on many of the frequencies you're aiming for.  You'll often be pretty close, but rarely exact.

    And that's about it, simple but limited.

 

2. One more complicated method will require you to continually calculate and write the next chunk of points to the task while it's running.  This is one way around the quantization effect.  By no longer restricting yourself to define exactly 1 cycle of the sine at a time, you can define 0.997 or 0.9942 of a cycle instead.  That will allow you to generate your exact waveform frequency, but to accomplish it, you have to keep continuously calculating and writing new samples to the task, always starting and ending at different parts of the sine wave, to make a continuous-looking waveform.

 

3. Another more complicated method is to work through the problem in rational approximation that will let you fit N cycles of the waveform into M periods (as Henrik already mentioned) pretty much exactly.  Then you can again write this bigger buffer once only and the task will keep repeating it.  I wrote this up in a thread a *very* long time ago, but happened to add a useful (IMHO) update pretty recently.

 

 

-Kevin P


Thanks Kevin!

 

2. By continuously calculating and writing new samples to the task, do you mean sending samples from PC to the memory of the card in loop? If yes, it will add overhead delay of PC. 

Please suggest if there is any alternate.

 

What I am doing is keeping freq 5000Hz and changing the cycles to 0.999, 0.998, 0.997 ........ What I am getting is 5000 few times and then 5002.5 few times and then 5005 ........

 

 

3. Can you explain it little more how to execute it. I define no. of samples. I can define update rate by selecting the freq to be generated Freq = Fupdate/no. of samples per cycle.

This way no. samples got saved in the memory of the card and it gives output @ Fupdate. This runs in loop.

How to adapt for your method?

0 Kudos
Message 4 of 9
(2,925 Views)

Thanks Henrik!

 

We tried writing samples, defining cycles and update rate(sampling rate).

Fupdate = 50kHz, n = 10

Freq = 50kHz/10 = 5kHz

here x was 100MHz/50kHz = 2000

 

Changing x from 2000 to 2001.

Fupdate = 100MHz/2001 = 49975Hz

Freq = Fupdate/samples = 49975/10 = 4997.5Hz

 

So I am getting 4997.5, 5000, 5002.5, 5005 ......

 

Is there anything I am missing from your method?

0 Kudos
Message 5 of 9
(2,923 Views)

I attached a simple but pretty complete working demo for my approach #3.  I'm going to post the zip file over in the linked thread too since I've linked to that thread several times over the years and future searches are liable to lead more people there.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 6 of 9
(2,912 Views)

Please refer my set up . Can i use this set up to increase the internal time base clock i.e 100Mhz (used to generate sampling rate )  to 200Mhz or 500Mhz or greater . Because as we increase the internal time base clock it will decrease the frequency resolution .Refer link below . I am using PXIe 6738 as my analog out device . I dont know locking range of PLL here 

https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z000000P9HgSAK

Download All
0 Kudos
Message 7 of 9
(2,853 Views)

1.  I'm pretty sure the answer's No.  Most NI DAQ boards I'm familiar with are spec'ed to allow external clock signals that are *slower* than their internal timebase due to things like input circuitry and signal paths.  That's a pretty hand-wavy description, but I'm not an EE.

   For example, page 6 of the specifications refer to a 25 MHz max external "base clock" as compared to the available 100 MHz internal timebase.

 

2. However, this whole thread is about the idea that there are *other* ways to achieve better frequency resolution.  The knowledgebase article you linked makes the common assumption of defining exactly 1 cycle of the AO waveform.  When you take that constraint away, you can achieve very much better frequency resolution.

 

Have you tried the demo code I posted?  Did you read the linked thread?  You *can* get better freq resolution, *not* by using a faster external timebase clock (your board won't support it), but by defining your waveform over the span of a relatively large # of full waveform periods.

 

 

-Kevin P

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 8 of 9
(2,842 Views)

Depending on your continuous updated sample rate, you can always use a continuous updated  AO and generate any frequency within Nyquist ( better use >5 times oversampling ) ....  so one of your cores will not be totally  bored.  😄

 

For frequencies <20kHz  you can use your PC headphone output ... (usually even higher .. but I'm not sure about 'your' PC 😉 )

 

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 9 of 9
(2,830 Views)