Acquiring signal using DAQmx 6221

I'm new to using DAQ. I need some pointers on how to go about the following
issue. I want to acquire a sine wave through DAQmx (PCI 6221). I need to
acquire the signal at a particular rate and store it as a binary and ASCII
file. Also I want to know how to output a signal through DAQmx. Could you
please give some pointers and example VIs if any?
Thanks,
Sukanya

Go to Help>Find Examples. Then expand Hardware Input and Output>DAQmx. Also look at Getting Started With DAQmx.

Similar Messages

  • Where to put data processing routine when acquiring data using DAQmx

    I have a program that is aquiring data using the DAQmx Acquire N Samples mechanism with automatic reset and a data handler callback routine. DAQmx acquires N samples (usually 1024) from the board, calls the handler to do something with it, and then resets to get the next batch of data. The program acquires a number of lines of data, say 512 lines of N points each, with one callback call per line. Triggering is done by a hardware trigger at the start of each line of data. So far so good.
    The issue is that the time that it can spend in the callback is limited, or else the callback is not finished when the next batch of data is ready to be transferd from the DAQmx buffers and processed. There is a substantial amount of analysis to be done after the entire frame has been acquired, and it ends up taking far longer than the time between lines; so where to put the processing? The data acquisition is started from a control callback callback that exits back to the idle loop after it starts the data acquisition process, so there is no code waiting to execute, to return to, when the data acquisition is finished.
    I could try to put the data analysis routine into an idle-time routine and trigger it with a semaphore, or I could put it into a timer control callback with, say, a 10 millisecond repetition rate and poll a flag, setting the flag when all of the data has been acquired. Any suggestions would be appreciated.

    I would recommend using Thread Safe Queues. Your acquisition callback can place items in the TSQ and then you can process the data in a separate thread. TSQs are nice because they allow you to install a callback function to run for certain events. Most importantly, you can install a callback for the Items in Queue or Queue Size Changed event which will run the callback if a certain number of items are in the queue. This lets you take advantage of multithreading in a simple and safe way using a standard Producer/Consumer architecture. However, you may still run into problems with this architecture if your acquisition thread is running much faster than the consumer thread. You could eventually overflow the queue. In that case, your only options are to either get a faster system, slow down the acquisition or do the data handling post process.
    National Instruments
    Product Support Engineer

  • How do you take into account a differential signal using daqmx?

    I created a channel using 2 separate voltage sources. However, both of these voltage sources are differentials across other channels on the DAQ board. Is there a way to set my physical channels as something like "differential w/ channel xxx"?
    Solved!
    Go to Solution.

    Yes, you should be all set.  Here's a good read on wiring considerations:  http://www.ni.com/white-paper/3344/en/
    Using LabVIEW: 7.1.1, 8.5.1 & 2013

  • Why is it that when I saved the waveform of my acquired signal into a wav file, the output waveform of my saved file turn out to be different from my input signal?

    Hi all,
    I am currently doing a heart sound analyzer project. I acquired signal using NI USB 6008 continuosly. My program is able to saved the acquired signal into a wave file. But when I browse open the saved file, the output waveform did not look the same as the acquired input signal and also the sound of the heartbeat captured cannot be heard from the loud speaker though I have saved the file as a wav file. I am not sure if the method i use to save the acquired data as a wav file is correct.  I have attach the print screen of the differences of the output I have notice and the program I have created. I would be glad if anyone here is able to troubleshoot my program.
    Thanks. 
    Attachments:
    heart sound analyzer.zip ‏257 KB

    Hi Brett Burger,
    Thanks for your reply. For your information, I have set the sampling rate as 10000 as for the sound format, I have set the bits per sample as 16 bit, the rate as 11025 and the sound quality as mono. I tried using your method by changing the sampling rate as 8K but still my program encounter the same problem.
    I wish to also create a button that is able to generate a preformatted report that contains VI documentation, data the VI returns, and report properties, such as the author, company, and number of pages only when I click on the button.  I have created this in my program, but I am not sure why is it not working. Can you help troubleshoot my program. Or do you have any samples to provide me. Hope to hear from you soon.
    Many thanks.
    Regards,
    min
    Attachments:
    Heart Sounds1.vi ‏971 KB

  • Using two daqmx create channel to acquire signals in random

    Hi
    I am trying to acquire signals from PXI 4472 with two DAQmx create channels. The channel selection is random. For eg. first create channel i have ch. 0, 2, 4, and 6 and the other create channel is Ch. 1,3,5 and 7. This I can do, but the problem is that I need to write the acquired data in seperate files for each channels and that too in sequential order. How can I do that. I know i need to use the loop but how will I will select the channels from two different task.
    Thanx in advance
    Nitin

    Ok, here was my idea, I am not sure if it will work for you or not after looking at your VI. 
    You can use some of your subVIS that you made to make the path different for each file.  But what I had in mind for the channels was what I did in the vi i attached.  You can just repeat the process for each of the channels and you would know that they were saved correctly.  You could also feed in the iteration number of the main VI while loop to have the binary files change sequentially (ie, data1, data2, etc).
    Again, this may not be a route you want to take, you may have other ideas. 
    Ill try to work on it some more later, but I have to get back to work for now
    Kenny
    Kenny
    Attachments:
    pxi subvi idea.vi ‏31 KB

  • When does a clock signal appear on a RTSI bus using DAQmx for a PCI NI-4472 DSA?

    Hello,
    I am trying to synchronize several PCI NI-4472 DSA boards over a RTSI cable using MATLAB. I have read that with DAQmx it is not necessary to use DAQmxExportSignal to put the clock signal on a RTSI line provided that the RTSI cable is registered in MAX and that the DSA cards are listed as being connected to the RTSI device. Apparently, the DAQmx drivers are supposed to route the clock signal between the cards as required….
    So I have done the above and see in MAX, in the device routes tab for Dev1, that
    /Dev1/ai/SampleClock uses RTSI6
    /Dev1/ai/SampleClockTimebase uses RTSI8
    Right now I am monitoring the RTSI lines on an oscilloscope in the hopes of detecting a clock signal on one of the three boards in the system while one board (the eventual master) is acquiring data using the Test Panels in MAX. I am getting nothing on the ‘scope (may be monitoring the wrong line – have just posted a request for RTSI pinouts for this DSA) and am wondering under what circumstances is the clock present on the RTSI bus.
    My real problem is that MATLAB R14SP3 does not yet support a master card in a synchronization application but, oddly enough, seems to allow one to setup slave cards. I would like to continue using the MATLAB data acquisition toolbox to manage the DSA cards and the application and would rather avoid using calls the DAQmx dll library. (It's not clear how to integrate the functionality of the data acquisition toolbox with direct calls to the DAQmx library.) So I am looking for a workaround to get the clock signal on the RTSI bus so that I may try out the slaves.
    Thanks,
    Sebulba

    Hi
    Both ports of a two port CAN board are handled by one processor and they use the same memory for alocating the necessary queues.
    But, both ports if connected to different CAN buses have their own handle, own queues and error handling. That means if one Bus enters to BUS OFF, the second bus can still communicate. And you can stop and restart communication independently on both ports. Even the ncaction reset works  on a single port at a time.
    DirkW

  • Acquiring AC voltage signal using NI 9206 9205 and cRIO

    Hello.  I am having difficulty accurately acquiring an AC voltage signal using a NI 9206 and cRIO.  I'm attempting to acquire voltage signals from two types of Magnelab Current Transformers: split core and rope.  In Labview, I first populate an array of size 2,500 with the sensor signal (DIFF mode), then compute the RMS of the array.  For the split core CTs, I am able to accurately acquire the correct voltage reading (verified by measuring the corresponding amp on the line using a Fluke 434 Power Analyzer.  For the rope CT, however, using the same array/RMS method, I am unable to accurately acquire the correct voltage reading.  Measuring the amp on the line using the Fluke 434 PA, the correct voltage from the rope CT should be 0.05v.  Using the 9206 (DIFF mode), the RMS from the array gives a voltage reading of 0.071.  Now the interesting part is when I measure the line voltage using two different True RMS DMMs, I get two different readings.  One multi-meter, a Klein CL2000, reads the correct voltage at 0.05v.  Another multi-meter, a Fluke 189, reads incorrectly at 0.071, the same as I get using LabView and the NI 9206.  I suppose the question is how is the Klein interpreting the signal differently than the Fluke 189 and the NI 9206 via LabView.  One difference between the split-core and rope CTs is that the rope CTs require an external power supply 12-30v AC or DC.  I am providing them with 12v DC.  I have tried multiple voltages in both AC and DC and still get the same incorrect reading.  I'm quite certain it is not a power supply issue, although perhaps the integrator in the rope is creating a unique signal.  Any ideas?  I appreciate any input.
    Thanks,
    J.Grant
    Solved!
    Go to Solution.

    AK2DM:
    Update - solution found
    While the Butterworth low-pass filter sort of worked, it was NOT the solution.  I spent some time analyzing the rope CT signals by sampling at a very high rate.  The AC signal coming off the rope CTs is triangular NOT sinusoidal.  The RMS function in LabView assumes a sinusoidal waveform and essentially calculates the RMS as the average of voltage peaks (for each cycle) / sq.rt (2).  Since the AC voltage single emanating from a regular split-core CT is basically sinusoidal, the LabView RMS of the signal gives an accurate reading of the voltage signal.  Unable to find a RMS function in LabView for a triangular AC voltage signal, I ended up developing my own custom triangular RMS function in LabView.  My function analyzes the signal by finding the peak of every cycle within the signal, takes the average of these peaks, then divides this average peak by sq.rt (3).  see this link for formulas:
    http://www.optics.arizona.edu/nofziger/OPTI%20380B/Lab%201/AVG%20and%20RMS%20Values%20of%20Periodic%...
    Using the triangular method, I am able to accurately acquire the signal off the rope CTs. 
    Thanks for your help!

  • How to create multiple physical channels using DAQmx?

    Hi, I am new to Labview.
    Can anyone please help me on how to create multiple physical channels? I am following the LabVIEW examples in the NI example finder but they are only for acquiring signals from one channel.
    Actually, I am using the channels of an SCXI 1520 to measure voltage signals. And one more thing, in the NI Example Finder, they are sample codes there for setting the filter in SCXI 114x.
    Will this example work with an SCXI 1520, too?
    Thanks!

    There are many ways to read multiple channels in LabVIEW. First, if you look at that example that lets you set the filter setting on the 114x and you click on the 'Physical Channel Listbox' then click 'Browse' you can see that you can select multiple channels. After you select the channels and hit 'Ok' it will build a multiple channel string. This is one way to read multiple channels.
    Next, you can create a 'Task' in Measurement and Automation Explorer(MAX). When you create this task select all the channels that you need to read then back in LabVIEW simply select a 'DAQmx Task Name Constant' Select the task you just created and wire that to an Input of your first DAQ VI. If you do this you do not need to have a 'DAQmx Create Physical Channel' VI or create
    Task because it is already created in MAX.
    When looking at example VIs you can tell if a multi-channel read is acceptable by looking at the 'DAQmx Read' and if it says NChan that means it will do a multichannel read. There are tons of example programs that will display the multichannel read capabilities.
    This example may not work for the 1520 because the properties that are set could possibly be specific to the 142x. When using the 1520 though it is very likely that the properties will be very similar if not exact. You will simply put a DAQmx Channel property node on your block diagram and then look for the Lowpass filter settings properties that will most likely be in the same location. Now another way todo this without using a property node would be in MAX when you create a task set the filter settings from the Device tab in the task configure window.
    Let me know if you need anymore help with reguards to this issue! Have a great day!
    Allan S.
    National Instrument
    s
    Applications Engineering

  • Aquiring a signal using a PCI 6251

    Hello,
         I am trying to write a program that aquires a signal from a device connected to a PCI 6251. The device attached to the PCI is an esophageal lead and it is suppose to read a sine wave being sent through the body. Then I want to filter the signal and send it to a buffer. I do not have a good programming background, and I do not know if I can use LabView Signal Express or a function with in LabView 8.2 to aquire the signal. Any suggestions as to what I should do? Thank you.

    Hi yed1920,
    There are a few ways to acquire the sine wave. You can use a single DAQmx Acquire Step in LabVIEW SignalExpress and this will allow you to configure the acquistion and view the incoming data. You can check out some examples using DAQmx in LabVIEW SignalExpress which are found at C:\Program Files\National Instruments\SignalExpress\Examples\DAQmx on a Windows system. The LabVIEW SignalExpress Help and the LabVIEW SignalExpress Getting Started Guide which are installed with the program may also give you some direction.
    If you choose to use LabVIEW, there are examples which can help you get started. The Example Finder can be accessed through the Help menu. The DAQmx examples can be found browsing by task under Hardware Input and Output » DAQmx. You can check out the NI-DAQmx Help file or the articles found on this page to learn more about certain functions in detail.
    Regards,
    Kent
    Applications Engineer
    Digital Multimeter Home

  • Simultaneous tasks using DAQmx functions

    Hi all,
     Is there any example of DAQmx PCI-6251 on Labwindows in which Multithreading is used.
    Basically i want to acquire and generate Analog signals from PCI-6251 by using Multithreading.
    In which one Thread is for Acquiring the analog signals and the other thread is for generating
    the analog signals after performing some calculations on the samples of the Acquired Signals.
    So it means i dont want to Acquire and Generate analog signals Simultaneously but there must be a
    "Little Delay" between the two Threads.
    Any help on this topic will be Greatly appreciated.
    Regards    

    Actually, this is entirely possible.  The primary difficulty is sharing data between your two threads.  The easiest way to accomplish this in LabWindows/CVI is with a thread safe queue.
    I admittedly don't write much DAQ code, so it likely won't meet your specific needs, but I've attached a simple example of doing what you've asked about.  I create two threads, one for reading and one for writing.  Each thread creates a task, and then loops while reading or writing until told to stop.  They share data through a thread safe queue.
    Let me know if you have any questions regarding the sample -
    NickB
    National Instruments
    Attachments:
    DAQMTProcessing.zip ‏7 KB

  • Using DAQmx with RTDs

    I am trying to acquire signal from 3 RTDs using a NI 9217.  I can get them to work fine using DAQ Express. However, I am trying to avoid using Express VIs, because this is a small part of a much more complex system. Whenever I try to run the VI, I get Error 200077which says that I selected an external excitation source instead of choosing an internal source. I changed the setting to be internal. However, I still get the same error regardless.  How do I correct this?
    Attachments:
    Daqmx test.vi ‏80 KB

    Hi,
    In your VI it doesn't seem like you have specified the current excitation source.

  • How do I acquire signal few seconds before triggering

    Hello guys,
    I am working on impact test and I want to acquire signal few seconds before trigger starts. How do I configure my DAQ assistant to do that?
    Thanks.
    Solved!
    Go to Solution.

    Well usually you configure your DAQ device (Which one do you use?) to continiously capture data into a ringbuffer and set the triggerposition to 20%-50% (related to the number of samples you want to read). After the trigger is set the start of your data will be set by the driver. 
    All this is done by the DAQmx or scope driver. Just set the samplerate, number of samples, trigger and position of trigger.
    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 ǝɥʇ'

  • I am trying to log data from 4 voltage input signal using labview, but when i use DAQ assistant i am able to log data from one signal at a time only.

    I am trying to log data from 4 voltage input signal using labview, but when i use DAQ assiatant i am able to log data from one signal at a time only.I am trying to get all 4 input data to logged in a single file againt time. I am new to Labview, I need to sample this data within a couple of days can someone help please.

    Naveen
    Check out the info in the Analog Input section of the document linked below.  (Ignore the part about Global Channels.)  In Figure 5, notice that you can select multiple channels while holding <Ctrl> or <Shift>.
    Developer Zone Tutorial: NI-DAQmx Express VI Tutorial
    Kyle B  |  Product Support Engineer  |  ni.com/support

  • Multiple inputs and outputs using DAQmx VIs

    Hello,
    I am fairly new with the LabView programming language.  I have a few training books that I have been reading, and I have been following online tutorials and reading the forums.  However, I have come to a problem where I don’t see a clear solution.  I am using LabView 2009 (9.0f3) and DAQmx VIs.
    I am using a NI 9172 chassis PLC, with two 9201 AI cards, 9217 AI RTD card, 9472 DO card, 9263 AO card, and two 9237 AI Bridge cards.
    I am reading eight analog inputs with the 9201 cards, two analog RTD inputs with the 9217 card, three digital outputs with the 9472 card, three analog outputs with the 9263, and eight analog inputs with the 9237 cards.
    I wrote a simple program to test one digital output task, two of the analog output tasks, and a single analog input task.  I put all of them in the same while loop, and it worked perfectly.  However, when I add analog input tasks to the same loop, I get an error 200022.    So I tested each sensor individually by changing the channel before each run.  I searched error 200022 and found that this is because I cannot start another analog input task until the previous one ends.  With this said, I don’t know how to acquire an analog voltage in the same task as an analog RTD voltage.  Both inputs take different constants in the start task DAQmx icon.
    Attached is my test program.  It is titled “Test All”. This is the program I used to test the various sensors.  I tested the input sensors one at a time, and it worked fine.  A few tasks are written just to test functionality, and will be added to later.  The data is only displayed on the screen.  I will add triggers and data write to disk functions later.  This program works now, but if I add more analog inputs, it will generate the 200022 error.
    Can someone show me how to correctly write the code for multiple inputs and outputs using DAQmx?  All training materials and tutorials I can find all show a single input or single output, not multiples of each.  Thanks for looking.
    -Randy
    Attachments:
    TestAll-NI.vi ‏32 KB

    Hi RandyC,
    The Knowledge Base article Using Different Types of DAQmx Global Channels in the Same Task goes into a little more depth of what Bryan is talking about, and it also includes some example code to help show what to do.
    Hope that helps,

  • How do I configure a counter to generate pulses using DAQmx?

    How do I configure a counter to generate pulses using DAQmx?
    Is says in the DAQmx C reference help
    "CtrnInternalOutput—The signal at this internal terminal is where the pulsed or toggled output of the counter appears. The output of a counter pulses or toggles when the counter reaches terminal count. When counting down, the counter reaches terminal count when the count reaches zero. When counting up, the counter reaches terminal count when the counter rolls over. To configure the counter to toggle or generate pulses, use the Export Signal function/VI with Counter Output Event as the signal name."
    I've tried this but can't get it to work, I may have the parameters wrong or something. The DAQmxExportSignal() function is very unintuitive to me. Here is my counter config code...
    int ret = 0;
    ret = DAQmxCreateTask("",&task_);
    errorMsg(ret);
    if (ret != 0)
    throw ret;
    // Configure the counter
    ret = DAQmxCreateCOPulseChanTicks( task_, "Dev1/ctr0", "", "/Dev1/PFI8", DAQmx_Val_Low, 0, divider, divider );
    errorMsg(ret);
    ret = DAQmxCfgImplicitTiming( task_, DAQmx_Val_ContSamps, 1000 );
    errorMsg(ret);
    // Change to pulse mode
    ret = DAQmxExportSignal( task_, DAQmx_Val_CounterOutputEvent, "/Dev1/Ctr0InternalOutput" );
    errorMsg(ret);
    // Start the counter
    ret = DAQmxStartTask(task_);
    errorMsg(ret);
    The above code works fine, in toggle mode, if I just comment out the DAQmxExportSignal() part.
    HELP!!!
    Stefan

    The problem is due to the DAQmxExportSignal call.  By default, when you create a counter output pulse train task, the driver will automatically set the output of the counter to toggle when the count for each high ticks and low ticks expire.  The driver also automatically routes the signal present at Ctr0InternalOutput terminal (the output of the counter internal to the device) to the Ctr0Out terminal (the I/O pin available externally).  Using the line
     ret = DAQmxExportSignal( task_, DAQmx_Val_CounterOutputEvent, "/Dev1/Ctr0InternalOutput" );
    will tell the driver to tristate the Ctr0Out terminal and not output the signal to the external I/O pin.  Using the DAQmxExportSignal function is generally only useful if you want to route the signal to some other terminal internal to the board without having the output show up on the external connector, route the signal to some other external pin other than the default pin, or if you want to have the output show up at multiple locations. 
    If you want to change the output behavior from toggle to pulse, you need to use the DAQmxSetExportedCtrOutEventOutputBehavior function.  However, this is generally only useful if all you care about are edges (not the duty cycle of the pulse train), and you want to generate higher frequency signals.  For example, with a 20 MHz timebase as the source of your counter, you can only generate a 5 MHz pulse train by default.  This is because the minimum value for the low and high ticks parameter is 2 (20 MHz / 4 = 5 MHz).  By changing the output behavior form toggle to pulse, you can generate a pulse train at 10 MHz since the output is now pulsing instead of toggling.  However, the width of each pulse is not programmable so you will no longer have a 50% duty cycle signal.  I don't remember exactly what the width of each pulse is, but I believe it's in the neighborhood of 50 - 100 nanoseconds in width.  I hope this information helps.

Maybe you are looking for