Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI-9264. How can i output precise frequency between 48 and 52 Hz

Solved!
Go to solution
Hi. I'm Sorin. I work with Labview 8.6 platform, MAX 4.50f0.
I have a cDAQ NI-9172 and a AO (voltage output) module NI-9264.
Basically, i want to output signal with a variable frequency in a few steps (1 sec.), between 48 and 52 Hz.
It will be something like this: 48 , 48.2 , 48,4 ,,,, 52 Hz.
Before I focus on programm.vi, i went in MAX and test the module. ("Test Panels" TAB).
There i select "Sinewave generation", 3V amplitude, and 50000 Hz rate.
I see that the frequency displayed is rate/1000. OK. 
The problem is when modifing the rate (the frequency generated). I measured frequency F on an Agilent 53181A very  
trusty, and also view signal on osciloscope. 
 
RATE        F meas.
 
47500 47.505
48000 47.961
49000 49.019
49500 49.505
50000 50.000
50500 50.504
51000 51.020
52000 51.950
 
 
1. So, why the signal out has a frequency other than displayed in MAX ? (except for 50 Hz)
I noticed this is happening when the set frequency is not a multiply of 1000.
 
2. What do i have to do (to set) to output a sinewave very smoothly and with precise frequency? (like a stand alone  
generator). I tried "Cont Gen Wfm-Clk.vi" exemple, but the same think is happening regarding waveform, very  
"digitalysed" and not precise except for 40,50,60,70,,,,Hz.
 
Thanks.

 
0 Kudos
Message 1 of 5
(3,421 Views)
Solution
Accepted by topic author dsasorin
You have a 20 MHz timebase that is used to generate the clock rates for the device.  This gives you discrete clock frequencies that can be generated.  For example, you want a 47500 Hz clock rate.  Divide 20 MHz by 47500 Hz, you will get 421.052...  This is not a realizable clock rate.  The software does the best it can so it rounds to the nearest timebase clock cycle of 421.  If you divide 20 MHz by 421, you will get your 47505.938... Hz clock rate.
Randall Pursley
0 Kudos
Message 2 of 5
(3,410 Views)

Thank you Randall. I didn't know the timebase is 20 MHz. Now it's clear.I figured out how it works. 

Anyway, I found a better suited exemple for me in Labview 8.6, which of course i use it and learn from it. I managed to obtain what I was asking for with a little tunning Smiley Wink 

Now i have to focus on my programm with steps, pauses, and so on.

Thank you. 

0 Kudos
Message 3 of 5
(3,408 Views)

I'm just extending the discussion a bit so I can give some context before pointing you to a nifty link.  Basically, I found a good solution to this kind of problem, but it [seems to] need solving only rarely.  I'm not certain it'll be useful to you right now, but there's a possibility.  I'm not very familiar with the CDAQ hardware and my idea is best suited for hardware-clocked buffered AO.

 

Some things to think about:

 

1. The specific analog frequencies (I'm imagining sine waves, but, whatever) you can generate depend on more than *just* the internal timebase of 20 MHz.  They also depend on the # of samples you define per buffer of the waveform.  By choosing a different # of samples per buffer, you'll find that there's a different set of discrete freqs you can generate.

 

2. It starts getting helpful to think about period instead of frequency.  So you can generate samples only at integer multiples of 50 nanosec periods.  Now your next job is to make your AO waveform end at one of those points.

 

3. Here is the key.  Your AO waveform buffer can be defined to hold more than 1 cycle of the waveform!   As an example, suppose you wanted to generate at 300 kHz.  That's a 3.3333333333333... microsec period.  You can't land on that exactly using multiples of 50 nanosec.  But you don't have to stop there -- just define your buffer to hold 3 cycles of the waveform.  That requires 10.0000000 microsec which you *CAN* land on.

 

The general problem is to match one integer # of timebase periods with a different integer # of waveform cycles such that they both land at the same place.  So after all that preamble, let me point you to a solution I shared previously.

 

-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).
Message 4 of 5
(3,397 Views)

Another approach is to disable automatic regeneration of data and continuously feed DAQmx new pieces of the waveform. This way, each piece of the waveform does not need to contain an integral number of periods of the signal. However, this requires you to keep generating new pieces of the waveform, and the beginning of each piece must match up with the end of the previous piece.

 

DAQmx ships with an example demonstrating this: <LabVIEW Dir>\examples\DAQmx\Analog Out\Generate Voltage.llb\Cont Gen Voltage Wfm-Int Clk-Non Regeneration.vi

 

dsasorin, is this the "better suited example" you alluded to in your previous reply?

 

Brad

---
Brad Keryan
NI R&D
0 Kudos
Message 5 of 5
(3,361 Views)