DAQmxWrite​AnalogF64(​) - array & number of samples

I plan to use DAQmxWriteAnalogF64() to output AO to my device.  This is part of the code that generate the AO:
// DAQmx Configure Code
DAQmxErrChk (DAQmxCreateTask ("",&taskHandle) );
DAQmxErrChk (DAQmxCreateAOVoltageChan (taskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Vol​ts,NULL) );
DAQmxErrChk (DAQmxCfgSampClkTiming (taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_C​ontSamps,1000) );
DAQmxErrChk (DAQmxRegisterDoneEvent (taskHandle,0,DoneCallback,NULL) );
// DAQmx Write Code
DAQmxErrChk (DAQmxWriteAnalogF64 (taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,d​ata,NULL,NULL) );
// DAQmx Start Code
DAQmxErrChk (DAQmxStartTask(taskHandle));
Questions:
1. DAQmxCfgSampClkTiming() specifies a number of 1000 samples with a rate of 1000 samples/second.  dataLayout is DAQmx_Val_ContSamps, which is generate samples until task is stopped.  Does this mean that the input array that I pass into DAQmxWriteAnalogF64() must have a size of 1000?  This is single channel.
2. Say if I use a total of 4 channels, each has 1000 samples, then my input array must have a size of 4000, while my sampling rate remains at 1000 samples/second, correct?

Hello hn_sofec,
In regards to your doubt:
No,  the input array that you pass into DAQmxWriteAnalogF64() does not necesarily have to have the same value than the number of the sample rate. The number of samples is just the number of samples that compose the waveform that you want to generate. Then, the sample rate, will determine how fast will you transfer to the output buffer those samples. For example, for an array of 100 samples (lets say that those 100 samples represents a complete period of a sine wave), and configuring a sample rate of 1000 S/s, it would take 0.1 s to generate the first complete period of the sinewave (array of 100 samples). After1 second you would have generated 10 complete periods of the sinewave.
I suggest you to review more examples in order to understand better how the functions work. I share you one here:
"NI-DAQmx: Continuous Multi-Channel Analog Output Example in CVI"
http://www.ni.com/example/25867/en/
Hope this helps. Best regards!
Daniel C.

Similar Messages

  • How to build a array with high sampling rates 1K

    Hi All:
    Now I am trying to develop a project with CRio.
    But I am not sure how to build a array with high sampling rates signal, like >1K. (Sigle-point data)
    Before, I would like to use "Build Arrary" and "Shift Register" to build a arrary, but I found it is not working for high sampling rates.
    Is there anyother good way to build a data arrary for high sampling rates??
    Thanks
    Attachments:
    Building_Array_high_rates.JPG ‏120 KB

    Can't give a sample of the FPGA right now but here is a sample bit of RT code I recently used. I am acquiring data at 51,200 samples every second. I put the data in a FIFO on the FPGA side, then I read from that FIFO on the RT side and insert the data into a pre-initialized array using "Replace Array subset" NOT "Insert into array". I keep a count of the data I have read/inserted, and once I am at 51,200 samples, I know I have 1 full second of data. At this point, I add it to a queue which sends it to another loop to be processed. Also, I don't use the new index terminal in my subVI because I know I am always adding 6400 elements so I can just multiply my counter by 6400, but if you use the method described further down below , you will want to use the "new index" to return a value because you may not always read the same number of elements using that method.
    The reason I use a timeout of 0 and a wait until next ms multiple is because if you use a timeout wired to the FIFO read node, it spins a loop in the background that polls for data, which rails your processor. Depending on what type of acquisition you are doing, you can also use the method of reading 0 elements, then using the "elements remaining" variable, to wire up another node as is shown below. This was not an option for me because of my programs architecture and needing chunks of 1 second data. Had I used this method it would have overcomplicated things if I read more elements then I had available in my 51,200 buffer.
    Let me knwo if you have more qeustions
    CLA, LabVIEW Versions 2010-2013
    Attachments:
    RT.PNG ‏36 KB
    FIFO read.PNG ‏4 KB

  • Pulse train generation fails with certain values for "number of samples"

    I'm generating a retriggerable analog output signal, and so I'm using a counter as the sample clock (see: Retriggerable AI Using Retriggerable Counter). I am finding that, above a certain number of samples, and only for certain values of the number of samples, the counter task gives me error -200305, "Desired finite pulse train generation is not possibe." The error crops up only when actually starting the task.
    The analog signal that I'm trying to generate will be about 800 kHz, so my counter is set to run at the same frequency. I find that the counter task works fine if the number of samples to generate is anywhere between zero and 671,088 samples. Setting the number of samples to 671,089 gives the error above, as does 671,090 samples and so on. However, using 671,096, the counter task works fine. After that, the counter seems to output fine only if the number of samples is divisible by 8.
    The only thing I can think of is that (617088 samples) / (800000 Hz) = 0.839 s. At the internal clock rate of 20 MHz, 0.839 s is 2^24 samples, and it is a 24-bit counter on this hardware. So if it's this internal counter rolling over, that's fine and I can work around that. But if that's the case, what I don't understand is why increasing the number of samples in increments of 8 samples still works.
    The hardware is a PXI-6733 board, running with LabView 7.1.1 and NI-DAQmx 8.1.

    Hmmm,  multiples of 50 & 100?  Now I'm puzzled again.
    Here's how to make sense of the 100 kHz timebase idea though, even if it turns out not to be the right explanation.  For a retriggerable finite pulse train, you actually use a pair of counters.  If you were to program it manually, you could set your output counter to generate a continuous pulsetrain at 800 kHz using the internal 20 MHz timebase.  This output counter would also be configured to use the other counter's output as a digital level-based pause trigger.  So the 800 kHz pulsetrain is only output while the other counter's output is, say, high.
    The other counter is configured for retriggerable pulse generation.  The pulse duration or high time should be set for (# pulses) / (800e3 pulses/sec).  This other counter can be configured to use the 100 kHz timebase, so its high time would then have to be an integer multiple of 10 usec.
    So let's see...  An 800 kHz pulsetrain is possible with a 20 MHz timebase (exactly 25 cycles).  A 700 kHz (28 + 4/7 cycles) or 900 kHz (22 + 2/9 cycles) is not.  So when you request those other frequencies, you actually get a near approximation.  I dunno if DAQmx can be queried for the actual value correctly or not -- I recall an early version that reported back whatever freq you had asked for rather than what it actually used.  Queries based on ticks (rather than time or freq) did return what was actually used, as I recall.
    Let's suppose a request for 700 kHz gets truncated to 28 cycles of the 20 MHz timebase making a 1.4 usec period.  Then 50 of those periods becomes 70 usec, which is evenly divisible by the 100 kHz timebase.  Bingo!  (Note: 70 is the least common multiple of 10 and 1.4)
    Now suppose the request for 900 kHz turns into 22 cycles of the 20 MHz timebase, or a 1.1 usec period.  Now it takes 100 of those periods to get to 110 usec, which is also evenly divisible by the 100 kHz timebase.  Bingo again!  (Note: 110 is the lcm of 10 and 1.1).
    Did you follow the method here?  It should help you figure out expected results for various output freqs and #'s of samples.
    -Kevin P.

  • Multiple channels acquisition and Number of samples per channel

    Hi,
    I'm a new labview user and I need some help in trasposing an old traditional NI-DAQ acquisition software in a NI-DAQ-mx one.
    I followed the tutorial (#4342) but I found a problem with Analogue 2D DBL Multiple Channels Multiple Samples DAQmx Read Vi.
    I'm trying to acquire 8 voltage signals from a NI-USB-6341 device. When the Number Of Samples Per Channel I set is below the number of channels (8), the software acquires only a number of channels equal to the number of samples per channel I set.
    Is that a normal behaviour?
    Thank you
    Daniele

    This is my code. The problem is the same with or without the code for the scan backlog indexing.
    Tomorrow I will try with the code from the example.
    Thank you
    Daniele
    Attachments:
    acq code.jpg ‏119 KB

  • How to increase the number of samples in my fft?

    Hi,
    In my Labview environment I receive sampled data of a sinus function where one period consists of 4096 samples. How can I increase or control the number of samples which the fft spectrum is using for calculating its results?
    Best regards
    Jonny

    Hi,
    The sinus signal is generated to have a fixed frequency, but as seen in the figures the fft has a big SNDR. I hope do decrease this with adding the number of samples.
    Thanks
    Attachments:
    power_spec.JPG ‏50 KB
    power_spec_block.JPG ‏9 KB

  • 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 

    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.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Different Counter Outputs with different number of samples

    I´m using an 6602 Timing I/O Board and/or a MIO 6281. For timing control of our measurements I use different counters from both boards triggered by a Digital Out for synchronization. The counters are set to CO Pulse Time, implicit timing, digital triggered and finite sample mode.
    Lets assume I use two Ctr´s from the 6602 board. My problem is when setting the number of samples from only one CTR to another value then the second I´m getting an error. The rest works perfect, I can use different starting delays, low or high times, only different sample amounts don´t work. It´s regardless if I use the Timing I/O or Multi I/O board.
    For example:
    Ctr 0 / 6602 _ _ |     |_ _|     |_ _  --> 2 samples
    Ctr 1 / 6602 _ _ |     |_ _
    Somebody any idea or advice?
    Solved!
    Go to Solution.

    Here is my currently used code, perhalps it helps you understanding the problem. Both are doing the same but one is a bit optimized. Hopefully someone can help.
    Attachments:
    Example_1.png ‏70 KB
    Example_2.png ‏90 KB

  • Best way to acquire and log N number of samples at a specific repetition rate and write to file

    Hello,
    I am interested in acquiring N number of samples (e.g., 10000) at a specific acquistion rate (e.g., 1MHz), and writing this data to file - and repeating this acquisition/logging at a specific repetition rate (e.g., 50Hz).  Pretty straightforward I think, but I am unsure of how to go about doing this in order to maximize the repetition rate.     
    Any insight is appreciated!
    Thanks,
    Vic

    First thing's first: get the acquire and log working.
    Look in the example finder for a simple Analog Input (don't remember the exact name right now).  You will want to configure the task to be Finite Samples.  So you acquire N samples at Fs rate, read the data, and log it to a TDMS file.
    Once you have that working, put it inside of a While loop.  Use a wait inside of the loop to regulate how often you run this task.  You can actually setup the task before this close and close it out after the loop.  Same for the TDMS file.

  • Configurin​g IQ / Number of Samples for USRP2920

    Hello,
    I've been trying to record HF-Signal using the USRP 2920. I got unexpected behavior for some configurations of IQ rate and Number of Samples.
    When setting the IQ to 1M as example and Numbers of Samples to 60984, the recorded file remaind empty even after recording over a long period of time. It looks like for a given IQ there is an appropriate Number of sample applicable.
    Do someone know the trade off to be made between bo parameters?
    thanks for any suggestions
    Solved!
    Go to Solution.

    Hi Bolivar,
    There are a few considerations and facts in my knowledge:
    The number of samples that you specify as input to the fetch VI is the number of samples that will be fetched by your host from the NI-USRP device per fetch call.
    NI-USRP driver (at the host level) will try to acquire these configured number of samples within the timeout specified by you and if it is not able to fetch these from the device you would get a timeout error.
    The maximum communication speed/data rate between the device and the host is governed by the communication medium used between the two.(in this case the ethernet connection 1Gbit per sec).
    Once you call the initiate VI the NI-USRP device starts capturing data.
    So when you configure the timeout, number of samples and the IQ rate of operation following pointers might help.
    Is the amount of data that you want to fetch (number of samples * data width) fetchable within the timeout configured ?
    Are you fetching out samples quickly enough so that the device buffers do not  overflow due to a high IQ rate ?
    That being said. let's say we fix IQ rate at 1M
    Very small sample sizes will result in a lower actual data rate due to the overhead associated with every fetch call might even cause device buffer overflow.
    Very large sample sizes might work if above considerations are made.
    A good sample size for your application might be found by making a small benchmark and calculating the actual time taken by the fetch VI call to execute to get a fixed amount of data at various sample sizes and picking the best sample size for your application. I think multiples of 1024 might work better for sample size.
    I am not sure if this solves your problem.
    Thanks.

  • Number of sample required

    Hi to all the expertise,
    In my labview program 6i, I design a scan rate and number of scans to acquire. Now I want to read 100 samples, which mean on my graph, I want to see 100 samples of waveform. How should I configure it, so that I"m able to achieve this.
    Kindly advise.
    Thanks

    Simple as it
    If it is a finite acq, keep scan rate as 100 samples /sec and number of samples to read as 100 samples
    does this answer your query ?
    if not, get back with more details
    regards
    Dev

  • Maximum number of samples in a waveform

    Does anyone know what the maximum number of samples there can be in a waveform for the pxi 6561?

    Hi Timothy,
    This depends on how much memory is on the 6561 card, for instance if you have the 2 MB memory option this will allow you to generate 2 MSamples and Acquire 2 MSamples. The size of the sample i.e. 8 bit, 10 bit etc. really doesn't matter as the memory quoted is per channel so 16 x 2 MB. Also note that there is separate memory for generation and acquisition so 16 x 2 MB x 2 = 64MB memory total.
    Hope this helps,
    Nick

  • Error:the number of sample must be 0 please help.

    dear genius.
    I searched the same error in this board but I can not understand how can i fix my problem.
    I am just a beginner in LV so I need your help. I made AM modulation and demodulation vi .
    when  I first used "simulated signal" as message signal, noting happened.
    but, I changed simulated signal as "acquire sound", and add a play waveform, after that, problem occured.
    actually, I can not understand about sample number or sampler rate .
    how can i fix my problem?
    and do you know some website to exercise digital communication using usrp and labview for trying ?
    please let me know your idea.
    thanks a lot.
    Solved!
    Go to Solution.
    Attachments:
    error.vi ‏164 KB

    kimjihwan123 wrote:
    thanks kingt of ni 
    thanks again. but can you tell me the differecne between sample rate and sample per second?  (I thoungt it was same)
    First of all Knight of NI is my title.  Crossrulz is my alias.
    Secondly, Sample Rate is the same as Samples Per Second.  But you want to make sure your sample rate and number of samples gathered are the same from both sources.  I would also turn off the Actual Time (or whatever it is called) in the Simulate Signal so  that it just gives you the sine wave instead of using time to generate it.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • What is the effect of output signal with the same sampling frequency but different number of samples?

    Hi,
    I'm using PXI4461 for audio measurement and there is a question about analog output. I'm using the Basic Multitone vi for generating multitone signal. The sampling rate is 200k and my question is how to determine the number of samples. I used an audio analyzer to measure the distortion of the output signal with 200k and 1k points and there are no different except the update rate. What number of samples is suitable for 200k sampling rate?
    Thanks,
    Bill

    The Sampling Rate determines the maximum frequency that you can see (the rate/2 according to Nyquist).
    The number of samples divided by the rate determines how long you will sample. This sample time can only be determined by you. Do you need .1 seconds worth of data, or 1 second? But note that the MINIMUM frequency that you can detect is 1/(Sample Time) or the Sampling Rate/Number of Samples. So if your system has a minimum and maximum frequency specification use that as your guild.
    [email protected]

  • Serial number in sample management

    Dear gurus
    Can I use serial number in sample management to maintain the uniqueness of the sample.
    Kindly help
    Thanks
    MK

    1.In the task list
    a) define the sample drawing procedure.In sample drawing procedure you have to define the type of sample you needed.
    b) in the header below sample drawing procedure ,define the Inspection point based on the sample mgt.
    c)At the char level define the sampling procedure for each char/mic.
    Now activate the serial number profile in the Material master as per normal procedure.
    Make sure that you active the serial number tick in the inspection setup.
    This will create the samples &  you can do the RR ,defect recording as per the serial number & sample mgt.
    I hope this will add some value
    Regards
    Sujit

  • How to test if input is in array + number?

    Hi, I have an array, [0, 1, 2], and also a stored number: 5
    If I ask the user to input a number, how do I make the user continue input until the number is either one of the numbers in the array or the stored number?
    I can do this with a while loop, a for loop, and an if, else loop, but it's too complicated:
                   boolean match = false;
                   DONE: while (match != true) {
                        for (int i =0; i < number; i++) {
                             if (userInput == array[i] || userInput == -1) {
                                  match = true;
                                  break DONE;
                             } else {
                                  match = false;
                        System.err.printf("\nERROR: Input not in array or stored number.\n\n");
                        System.out.printf("Input again:\n    ");
                        userInput = input.nextInt();
                   }Is there an easier method? Could someone point me in the right direction? I'm wondering if it might be faster if I create a new array that includes the original array + the stored number, then test to see if the input is simply in this new array.
    Thanks for any help.
    Edited by: fishy on Feb 23, 2009 11:16 AM

    Hello,
    To check the number against the array, you would have to loop through the entire array checking each element for the input value. A for loop should do the trick:
    private static int checkArray(int [] a, int inputNumber)
    for (i = 0; i < a.length; i++) { 
    if (a[i] == inputNumber)
          return 1;
    return 0;
    }Then you can use a do while for the input:
    do {
       System.out.println("Enter a number: ");
       userInput = sc.nextInt;
    } while ( (checkArray(userInput) == 0) & (number != userInput) ); This should ask the user for input as long as the number they enter is not in the array and it's not the stored number.
    Hope this helps,
    ~Vin

Maybe you are looking for