Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

NI9263 analog signal generation problem

I am using the NI9263 module to generate an analog signal. I'm particularly interested in generating a sin wave at ferequencies 1Hz and below.


The major problem that I am having so far is being able to output a signal with frequency less than 1 Hz. When I set the frequency to less than 1Hz the output sin wave cuts off and starts over before it has time to complete the full cycle.

How do I tweak my program such that I can output a sin wave with frequency < 1hz.



0 Kudos
Message 1 of 7

The function generator vi that you are using has an input called sampling info.  You are currently using the default of 1000 samples at 1000 samples per second so it only generates one second worth of data before you repeat it.


Message 2 of 7



You need to configure a sample clock to ensure that your analog output updates predictably.  Additionally, you will want to load your waveform into the buffer and only start the task once.  In your current VI, you are creating your channel each time the while loop iterates, which means that the analog output task will start each time the loop runs.  This means you cannot predict when the analog output will start each time.  You need to do something similar to the following:




In terms of creating the signal you want, I'll expand on what MarkGrot said.  When you create a waveform you specify a sampling frequency and a number of samples.  You also specify the frequency of the signal.  You can mess around with different combinations of sampling frequency, number of samples, and waveform frequency to achieve what you want.  For example, if you wanted to generate a 0.5 Hz signal, you could set the following inputs into the waveform vi:


Frequency: 0.5

Fs: 1000

# of Samples: 2000


This would generate 2 seconds worth of data (2000 S / 1000 S/s = 2 s) which would correspond to one cycle of the sine wave and repeat over and over again.  Because we are actually generating this on hardware, there is a limit to the # of samples we can put in the output buffer.  I'm not sure what chassis or sleeve you are using with the 9263, but just for example if you are using a 9174 you are limited to a buffer size of 8191 samples.


I'd also recommend checking out the example called "Cont Gen Voltage Wfm-Int"  in the NI Example Finder.


I hope this helps clear things up.


Jon S


Applications Engineer
National Instruments
Message 3 of 7



I am using a NI 9263 analog output module in a cRIO 9076 chassis. I need to output two sine voltages with frequencies 10 kHz and 11 kHz (or 9.5 and 10 kHz or something similar, but at least 10 kHz). Amplitude needs to be around 4 V for both.


Using the Sine Generator example that uses the FPGA express VI to generate a sine, I arrive at two signals with the right frequency of around 10 kHz each, however, they are both rectangular waveforms. I tried also a simple-as-possible example with the same result.


My other strategy is to wroie a single sine period into a buffer array of fixed size (like 50) on the target which is then repeatedly written into the analog output node inside a while loop. I have attached an example, for two waveforms.


In principle this works fine. However there is a problem: If I use between 10 and 20 samples per period I arrive at two waveforms with the desired frequency, but the waveforms are not smooth enough (to few steps, undersampled). If Increase the number of samles to 40 or more I get nice sinuses, but their frequencies are too low. Even if I set the while loop rate accordingly. This indicates to me that while the update rate of the analog output is not fully used the while loop rate reaches an upper limit for some reason. For instance, for a 10 kHz sine and for an array size of 50, the loop rate needs to be 500 kHz, but the actual while loop speed is lower.


Another thing: when I only generate a single sine wave and update a single output node only, the output frequency I can achieve is twice as high. In other words, when I manage to have a single sine wave analog signal at 10 kHz and I add second analog output node into the while loop (as in the figure), the resulting sine waves will have a frequency of around only 5 kHz each.


Does anyone have any idea?


Thank you


0 Kudos
Message 4 of 7

Hi Manuel,


Please try to do this using an approach similar to the one outlined by Jonathan above. Based on your code, it looks like you're writing one value to the analog output for each iteration of the loop. This is using software timing, which is not as accurate or fast as using hardware timing. Jonathan's snippet makes use of the DAQmx Timing VI, which uses hardware timing.


You can wire a generated sine waveform to the DAQmx Write VI for it to output to the analog channel. 



Alternatively, you can look at an example I found in LabVIEW's example finder. To get it in LabVIEW, navigate to Help > Find Examples > Browse > Hardware Input and Output > DAQmx > Analog Output > "Voltage - Continuous". It should be very similar to what it sounds like you want to accomplish.





Andrew T.
"His job is to shed light, and not to master" - Robert Hunter
0 Kudos
Message 5 of 7

Dear a_clucker,


thank you for the hint.

When I try using the DAQmx there are no physical channels found. When I manually insert Mod4/AO0 it says wrong identifier or something similar. The C modules are not listed in the MAX either. Having done some research I believe that the latter is supposed to be like this when a cRio is used (I use 9076 chassis).

I found an example ( and tried the "", but it could not find any C module of my cRio.


Before I would go through the hazzle of finding the reason why DAQmx does not see the C modules I made some further tests with the above code. I found that the while loop speed is limited by the analog output or input node it is reading from or writing to. It seems the limiting factor is not the loop speed or the controller, but the C module itself. For instance, when I write to a NI9381 which has nominal 20 kS/s update rate the while loop speed is max. around 40 kHz (ca. 40 MHz/1100 ticks), while when writing to the NI9263, which has nominal 100 kS/s update rate according to the data sheet, the max. while loop speed is ca. 200 kHz. (40 MHz/200 ticks).


That suggests to me that using DAQmx won't change anything because the NI9263 cannot be updated faster than 200 kHz. So I'm about to accept that I cannot get a smooth 10 kHz sine with the NI9263, unless anyone else has done it. It's a pretty standard task. Isn't there any other way? I haven't seen faster AO C modules from NI. Thanl you!

0 Kudos
Message 6 of 7



Sounds like you've done some good research. Unfortunately, we don't offer any c-series modules that give greater than 100kS/s. You're going to be pushing the limits regardless at that generation rate. That's 10 points per period of the sine wave. The limitation will certainly be the module. The fastest way to generate would be to just use the FPGA. There is a sine wave VI for the FPGA that you can plug directly into the analog output of the module. That will remove speed as as issue on the software side. 


If you need something faster than 100kS/s, than you will likely need to go to one of our PXI or R-series devices. 

0 Kudos
Message 7 of 7