Timing features with DAQmx

This is my first big labview programming endeavor and I am ready for the DAQ portion of the program.
I created the following code to acquire X-seconds of data @ sample rate. And display elapsed time and % fill bar.
I want the Channel indicators to refresh as data is acquired, so I setup DAQmx to acquire 1 sample in a timed while loop.
I set up the flat sequence structures so I could measure the actual test duration.
As is shown a 5 second test takes 5.057 sec’s.
100s=100.205
Eventually the time will be significant, and I’m worried when I start sampling more than 1 channel the time will be compounded.
Any suggestions for code improvement?
Attachments:
RECORD.png ‏151 KB

Just a few observations (#1 is really the most important takeaway):
1.  Running your loop at 500 Hz (or beyond?) isn't what you really want.  Assuming you do want to sample at this rate, you'd be much better off using the N Samples variant of DAQmx Read.  N should be whatever makes your loop run at a reasonable rate (5-10 Hz should be plenty for the purposes of updating the few front panel indicators).  For example, at a 500 Hz sample rate, reading 100 samples per loop would make the loop run 5x per second.
1b.  With this change made, you'll find that the read now returns a 1D array of values that you will need to insert into a single longer 1D array.  It is optimal to pre-allocate this longer array rather than appending to it on every loop iteration (i.e. Initialize the longer array to the correct size outside the loop and use the Replace Array Subset inside the loop).
2.  You may take out the wait function--its purpose is to keep the loop from running unchecked and consuming CPU.  The DAQmx Read call blocks until data is available and already does this for you.  At best, the wait is redundant (if it is less than or equal to the time that the DAQmx Read blocks, it does nothing).  At worst, the wait will lead to a buffer overflow (if it prevents the read from executing at the speed it needs to).
3.  This probably won't even be noticeable, but... if possible use the front panel terminals themselves when updating indicators inside your loop (right now you are using value property nodes which forces an immediate redraw).  If not, use local variables instead of the value property nodes.
4.  You could pull some of the math outside your loop (division is pretty expensive) but it won't make any noticeable difference once your loop is running at a reasonable rate.
5.  This won't affect performance at all, but I found this portion of the block diagram's wiring to be very confusing:
Also, usually I try to create a DAQ task exactly one time in a program if possible (during an initialization routine)--here it looks like you're creating it every time you want to start recording.  If you create the task once and then start/stop it as necessary you'll shave some ms off of your benchmark (quite possibly not worth the trouble though, depending on what the rest of your applicaiton looks like).
Best Regards,
John Passiak

Similar Messages

  • Internal clock timed aquisition with DAQmx

    Hello,
    Im have just begun using DAQmx and have little experience with DAQ Hardware. I have a requirement to do data aquisition across ~10 analog channels at 1kHz. I have looked at the DAQmx examples (specifically 'Cont Aqc&Chart Samples - Int Clk') and as I understand, one can do a 1kHz aquisition using the internal clock? What kind of determinism is expected using the internal clock? I have my loop running with a 20ms wait, reading 100 samples at 1kHZ. Is this adequate?
    Secondly, can you do a triggered stop on analog reads (just as you can do a triggered start?).
    Thanks,
    David
    Im using a PCI-6221 card with LV 7.1, DAQmx 7.3.0.

    The determinism of the board clocking in your data is extremely good. The determinism of your software (i.e. algorithms, waits, etc) is unknown and you are at the mercy of SW jitter. I think the specs you provided should be adequate, but if you start running into buffer overflow problems you will have to decrease your wait, read more samples, or setup a bigger buffer. If you need true determinism then you should be using LabVIEW Real-Time, but it seems like for this application it would be overkill.
    Stuart

  • US event timing with DaqMX help

    Greetings.  My Labview experience has been largely cFP and cRIO so my DaqMX experience is limited.  I have a program for my PCIe-6353 that will operate like this:
    DO1 high
    wait a period as low as 700 uS
    DO2 and DO 3 high
    wait 700 uS
    DO3 low DO4 high
    Take analog voltage data at 40 kHz
    DO2 low
    DO1 low
    This is all quite simple but I am not sure what architecture to use for the timing.  Any ideas or examples would be helpful and greatly appreciated.  I have been playing with using multiple timed sequences with different offsets but not sure if this is the best way.  I'm spoiled with the FPGA pallette where I can just drop a uS delay and move on.
    Thank you for any input you may have.
    Dave B 
    www.signalg.com

    Hi Dave,
          I think that you would have better luck on the Multifunction DAQ forum.  But to address your issue, there are a couple ways to do that.  First, you could do a Digital Output using a 10kHz clock on your 4 lines.  For this, you could use an example like "Write Dig Chan-Int Clk-Dig Start.vi" found in the NI Example Finder under Hardware Input/Output»DAQmx»Digital Generation.  That example would need to be modified to include the waveform that you've built (either from a waveform constant, or from the Digial Waveform Editor).  
    Is this generally what your timing diagram would look like?:
    Your other option would be to use 4 counters.  Hopefully that gets you started- let me know what you're interested in pursuing.  But again, I would recommend migrating this post to the DAQ forum.  Have a good one!
    aNItaB
    Applications Engineer
    National Instruments
    Digital Multimeters

  • An issue with DAQmx Error messages

    Greetings,
    I'm using a 6602 counter board with DAQmx 7.4, ANSI C API.  A strange issue concerning the errors due to faulty attribute values keeps occuring, that being no error is reported when the (faulty) attribute value is set but only when it is read back afterwards.  Shouldn't the faulty value be reported by the Set function?
    To be specific, I'm creating a period measurement counter input channel with implicit timing, sample mode = finite, then setting the number of samples per channel to 0 (bear with me, I know the 0 value makes no sense here, the point is how the errors are being reported so that they can be handled in a reliable and consistent way).  While DAQmxSetSampQuantSampPerChan(taskHandle, 0) does not produce an error, calling DAQmxGetSampQuantSampPerChan(taskHandle, &SampPerChan) for verification on the very next line returns Error -200077 : "Requested value is not a supported value for this property".  So, my question is why the error is reported by the Getter instead of the Setter?  Is this normal behavior (if so why?) or is something amiss here?
    Jeff

    This is the expected behavior. Validating attributes is tricky when attributes are dependent upon other attributes. There are two main approaches that can be taken by NI-DAQmx.
    One, when every attribute is set, NI-DAQmx could verify the value of that attribute in the context of the task (i.e., in the context of all other attributes). This is problematic for at least a couple of reasons. One, validating the task after every attribute is set is time consuming and not efficient. Two, validating the task after every attribute is set requires that customers set attributes in a specific order such that dependent attributes are set after their dependencies. This would dramatically decrease the usability of NI-DAQmx. In fact, if attributes are mutually dependent, this approach is impossible.
    The second approach is that NI-DAQmx doesn't verify the task until it is forced to do so. Starting a task forces it to be validated. Querying an attribute also forces the task to be verified since the value of an attribute may be dependent upon the value of another attribute.
    As you've noticed, we've taken the second approach with NI-DAQmx. This approach leads to a more efficient execution as well as allow customers to set attributes in an arbitrary order. If you want to force the task to be verified in order to check for errors, you can do so explicitly at the desired time. However, the need to check attributes for errors is most often needed when the application is under development and the NI-DAQmx error reporting features makes it easy to determine which attribute has been set to an invalid value even when that error is not reported immediately.
    Now, in reality, the way NI-DAQmx handles attributes is a bit more complicated than what I just described. Since some attributes are not dependent on other attributes or, since some attribute values can never be valid regardless of the values of other attributes, these attributes are verified when they are set and errors are returned immediately. We refer to this as coarse attribute verification. For example, if you set the sample rate to 100 MHz on an E-Series device you will immediately get an error.
    Hope this helps clarify the behavior.
    geoff
    Geoffrey Schmit
    Fermi National Accelerator Laborary

  • Error -200141 when doing buffered events with DAQmx and PCI-6602

    When doing buffered events with DAQmx and PCI-6602 I get error 200141 - Data was overwritten before it could be read by the system.
    This error is generated ONLY with random inputs >200/sec.
    My setup is :
    DAQmxCreateCIVCountEdges(taskhandle,"Dev1/ctr3"....
    DAQmxCG+FGSampClkTiming(taskhandle,"/Dev1/FPI35",...
    DAQmxSetCICountEgdesChan(taskhandlem,"", "/Dev1/80MHZTimeBase")
    DAQmxSetChanAttribute(taskhandlw,",",DAQmx_CI_DataXferMech,DAQmx_Val_DMA,0);
    Can somebody help ?

    i'm getting the same Error-200141, while reading semiperiods. (Meas_Buffered semiperiod continous)
    while loop ex.rate seems to be pulsewidth*no.Samples to read. in my case PW=60ms
    Input buffer size measured with Property node= 10000
    why this error happens?? i cant use any mode other than implicit timing for semi-period measurement right??
    more info: all the ai channels are used ~ 16 differencial.
    i found one solution which is _ reinitializing the whole task if an error occur. is this the right way??
    Kudos always welcome for helpful posts
    Attachments:
    Counter_1_Meas Buffered Semi-Period-Continuous_main_lv09.vi ‏34 KB
    SemiPeriod_Reconnect Counter on Error.vi ‏35 KB

  • Problem with DAQmx and Real Time PCI-7041/6040E.

    Problem with DAQmx and Real Time PCI-7041/6040E.
    I have a problem with the Real Time card PCI-7041/6040E, I think it is properly installed because my software run with the traditional NI-DAQ. When I try to use the new DAQmx to acquire one signal, Labview doesn't see any device for de DAQ card 6040E.
    Information, I work on Windows XP and LabView v7.0.0 (NIDAQ RT v7.0.0, NI-Serial RT v2.5.2, NI-VISA v3.0.1 and NI-Watchdog v2.0.0).
    Could Labview RT run with new DAQmx ?
    What can I do to use DAQmx with PCI-7041/6040E?
    Thanks for your help !

    Hello,
    I refer to your posts because i am using the PCI 7041/6040E card as
    well but without any success to make it work. The problem I have
    already described in the following thread:
    http://forums.ni.com/ni/board/message?board.id=170&message.id=120198
    Would be nice if you had a look on it, maybe you can help me. BTW, the
    thread starts with a problem of someone else, the difficulties I
    encountered are to be found a little bit to the bottom of the thread's
    page.
    Thank you!
    Dirk Völlger
    Darmstadt
    Message Edited by ratschnowski on 07-28-2005 07:14 AM

  • Problem with DAQMX on a 6025E !!

    Problem with DAQMX on a 6025E
    I work on a DAQ 6025E and I can't use the example "Write Dig Port.vi" and all others example on digital output with DAQMX. There isn't any hardware failure because the same installation functions correctly with the traditional DAQ. I want to use these channel parameters: Dev1/port2.
    I already tested to make a reset device and use "line or port configuring vi" but without successes.
    Thanks for your help!
    Attachments:
    Write_Dig_Port.vi ‏48 KB

    I took a look at the example you attached and it looks fine. Here are a few things to try out BEFORE running the example from MAX:
    1) Remove any SCXI, SCC, and accessories from the configuration in MAX so that no DIO lines are reserved for communication.
    2) Reset the driver to work in DAQmx mode for your board. To do this, first right-click the "Traditional DAQ Devices" and say "Reset Driver" and then right-click your 6025E under DAQmx Devices and say "Reset Driver" again. This should enable the driver for DAQmx.
    3) In MAX, under DAQmx Devices, run the test panel and make sure you can read/write all the DIO lines there first. If that works fine you should be able to run the example.
    Remember that the port names for the 6025E are Port 0, Port 2, Port
    3, and Port 4 (no Port 1).
    Good Luck!!!
    Sincerely,
    Brooks Bailey
    Application Engineering
    National Instruments

  • I have a late 2011 model MacBook Pro running Mountain Lion.  I love the AirPlay mirroring feature with Apple TV...BUT, how do I mirror with TVs that don't have Apple TV?  I used to run a cable from my mini display port to the HDMI input of a TV.

    I have a late 2011 model MacBook Pro running Mountain Lion.  I love the AirPlay mirroring feature with Apple TV...BUT, how do I mirror with TVs that don't have Apple TV?  I used to run a cable from my mini display port to the HDMI input of a TV.  This feature seems to be lost in the Mountain Lion upgrade.  Did Apple feel that once Mountain Lion came out that EVERYONE would have Apple TV?  There are no settings in System Preferences/Display like there used to be...only for AirPlay Mirroring.

    Running a cable to the HDMI port is still supported. (and still works on mine).
    If the Arrangement tab in System Preferences > Displays isn't present then it doesn't recognize the physical connection.  Double check all cables.  If that doesn't work try a PRAM reset:
    http://support.apple.com/kb/ht1379

  • Im not satasfied with 6.0 i miss youtube and some apps are slower, facebook wants premission to access my contacts, and how do i use apple tv feature with out mirroring?

    Im not satasfied with 6.0, i miss youtube, some apps are slower, facebook wants premission to access my contacts, and how do i use apple tv feature with out mirroring?

    That is awesome, works perfectly.
    I'll get it worked into my main script. Is this Action Manager code, and not just regular Javascript from the Scripting Dictionary? I can't tell the difference. I'll see whether or not it's actually faster than Applescript.
    Thanks. I know Scripting Listener records a bunch of stuff, but it's pretty amazing to me that playing back this line does the same thing that playing back the 1,011 lines Scripting Listener puts out.
    Thanks.

  • Error occurred in deployment step 'Add Solution': A feature with ID '' has already been installed in this farm. Use the force attribute to explicitly re-install the feature.

    Hi I am getting the error
    Error occurred in deployment step 'Add Solution': A feature with ID 10495515-2482-41fd-98eb-3c87f739f54b has already been installed in this farm.  Use the force attribute to explicitly re-install the feature.
    when trying to deploy web parts
    question 1 - how do i use the force attribute when deploying from visual studio
    question 2 - am i deplying it to the right place, if i deply it to the
    url:port that points to my central admin tool it deploys but i cant seem to see it in any of my webs in my site collection, if i deploy it to the
    url:port that points to my site collection I get this error.
    im new to all this by the way :)
    thanks in advance

    If you are deploying from Visual Studio then please follow this post:
    http://sharepointfordeveloper.blogspot.com/2014/03/solved-visual-studio-issue-error.html
    Open the visual Studio and navigate to the feature XML file and add the bellow attribute.
    AlwaysForceInstall="TRUE"
    The <FeatureName>.Template.Xml output would be some think link this.
    <?xml
    version="1.0"
    encoding="utf-8"
    ?><Feature
    xmlns="http://schemas.microsoft.com/sharepoint/"
    AlwaysForceInstall="TRUE"></Feature>

  • Can read TEDS in MAX but not with DAQmx VIs

    Hi,
    I have a cdaq 9181 with a 9234 accelerometer module.  I have 3 teds equipped accelerometers connected to ai0, ai1, and ai2 repectively.  In MAX, when I reserve the chassis I can read all three teds, no errors.  When I do the same thing in labview (ie reserve the chassis, create a daqmx task, associate teds data with each physical channel, all with daqmx VIs) I can only read two out of three teds.  The third one throws a "no teds sensor detected" error.  This code has been in use for about four months now, though I just rewrote the calling VIs, and hasn't displayed this problem.  I've attached a snippet of the task building VI for reference.
    Any ideas what's going on?
    Thanks.
    Using LV2012 and MAX 5.3.1 running on Windows 7 32 bit.
    CLAD
    Attachments:
    Build Daq Task Snippet.png ‏58 KB

    Nope.  That's a delete from array, length 1, index 3.
    In any case, I eliminated that block since the string array wired to the for loop controls how many devices the VI attempts to configure.  Same result, verified it was trying to configure ai2.  Here's the updated snippet:
    CLAD
    Attachments:
    Build Daq Task Snippet v2.png ‏54 KB

  • SCXI 1001, SCXI-1102 and SCXI-1303 not working correctly with DAQmx

    I have recently upgraded from Labview 6.5 to Labview 8.2 and now my SCXI 1001 with a SCXI 1102 and SCXI 1303 terminal block no longer reads the correct voltage.  Using the old version of labview thermocouple measurements are correct at 0.5mV; however using the new version of labview and DAQmx the thermocouples are reading 5V.  Everything is installed correctly as it still works with the older version of Labview, is there something that needs to be reset or change so that teh SCXI will function properly with DAQmx?

    Hello ilabtech,
    From my understanding you are using an SCXI 1001 chassis with an SCXI 1102 and 1303 terminal block to perform thermocouple measurements.  You are upgrading to LabVIEW 8.2 and DAQmx.  I am assuming you were using LabVIEW 6.1 since there isn’t a LabVIEW 6.5.  You mentioned that are able to get a correct reading of 0.5 mV with LabVIEW 6.1 but you see a rail of 5V with LabVIEW 8.2 and DAQmx. 
    My first suggestion is that you ensure that the SCXI is set at the appropriate range and for the correct thermocouple type.  You can also configure these settings in MAX as detailed on page 27 of the SCXI 1102 User Manual and Specifications Guide. 
    My second suggestion is for you to start off using an example program to see if you see the same error.  When you are in a LabVIEW 8.2 VI you can go to Help>>Find Examples to open the NI Example Finder.  You then choose Hardware Input and Output>>DAQmx>>Analog Measurements>>Temperature>> Cont. Acq Thermocouple Samples-Int CLK.vi.   This example program is supported by your hardware and is a good resource to use to troubleshoot.
    If these suggestions aren't helpful please answer the following questions in your reply.
    1.        I would like to know what range you have set the SCXI 1102 to read. 
    2.       What version of DAQmx are you using?  You can find the version my opening Measurement and Automation explorer (MAX), expanding the “Software “and clicking on NI-DAQmx.
    3.       What operating system are you using?
    4.  Does your Traditional DAQ program work in LabVIEW 8.2?
    Regards,
    Ima
    Applications Engineer
    National Instruments
    LabVIEW Introduction Course - Six Hours
    Getting Started with NI-DAQmx

  • Pulse Generation application with DAQmx and a PXI-6624 module?

    What is the best implementation method for the following pulse generation application
    using LabVIEW, DAQmx and a PXI-6624 counter\timer module?
    I have two rising edge trigger signals (Trigger-1 and Trigger-2).
    There is ample spacing between each trigger. They never occur at the same time.
    I need to generate a single pulse (fixed width, variable delay) whenever Trigger-1 occurs and
    a finite pulse train (fixed width, variable delay, N-pulses) whenever Trigger-2 occurs.
    However, the output must appear on one counter output because this composite signal
    will be used as a trigger source for another PXI module in the rack.
    With DAQmx and a TIO counter\timer can I use both the GATE (for Trigger-1) and
    AUX (for Trigger-2) at the same time on the same counter to gate out the desired pulses?
    Trigger-1 would be wired to the GATE of CTR0. One Trigger-1 event would generate one pulse on the output of CTR0.
    Trigger-2 would be wired to the GATE of CTR1 and the output of CTR1 would be routed to the AUX input of CTR0.
    One Trigger-2 event at the GATE of CTR1 would generate multiple pulses on output of CTR0.
    Would DAQmx and the PXI-6624 TIO support this implementation?
    What is the best way to accomplish the task at hand.
    Thank You.
    Best Regards,
    Scooby

    Hi Scooby,
    I have looked into the application you have described and I see a potential problem with what you describe.  In DAQmx, it is not possible to call the counters of the same DAQ device in the same task, so you cannot have the finite pulse train generation and the single pulse generation tasks running at the same time.  What you can do, since you mention the triggers will not occur at the same time, is to stop one counter task while you are triggering another.  The way I would suggest you merge the outputs is with a two input Or logic gate to avoid damaging your counters.  Your signals will effectively be added together by this logic gate.   I do not see any way to merge the outputs internal to the DAQ device. 
    Please let me know if I can be of additional assistance.
    Laura

  • How to configure a continuous pulse generation that doesn't end after the VI exits with DAQmx?

    Hi,
    I'm just learning the DAQmx and I have run into a problem.
    With the legacy DAQ API I could configure a counter to create continuous pulses and
    when I needed change the freq or duty cycle, I would just call the the configuration function
    again. The pulses were generated even after I closed LV, so it was all in the hardware.
    Now, with DAQmx api, it seems that this is not possible. I read a forum post saying that
    LV will end the pulse generation after the VI exits. Is there a workaround for this?
    I could ofcourse create a LV thread for this, but I liked the old one better
    It was simpler and I didn't need to worry about threads so much.
    All LV operations are going to be inside a DLL that is called from outside of LV, so I can't
    use LV threads in a simple way, e.g. putting things inside a while loop. Just that you'll
    know why I wan't to avoid using the threads.
    Thanks.

    It is possible to achieve this behavior using the DAQmx API by using the DAQmx Create Task VI to explicitly create the task (rather than relying on DAQmx Create Channel to do it implicitly) and setting the AutoCleanup attribute to False.  This method prevents LabVIEW from automatically clearing the task when your VI (or the function you'll be exporting to your C .dll) finishes executing.  The disadvantage is that you might accidentally "leak" a task if you're not careful.  In order to stop the pulse generation on command, you can either reset the device or somehow store the task name you created and come back later to call DAQmx Stop and/or Clear Task.
    Here's how you would start the generation:
    ...and how you could come back and stop it later, using the task name you created:
    Hopefully this helps-
    Message Edited by Tom W [DE] on 11-16-2007 07:54 AM
    Tom W
    National Instruments
    Attachments:
    autoCleanup.JPG ‏17 KB
    clearTask.JPG ‏4 KB

  • How to generate sequence of pulse trains with DAQmx?

    I need to generate a sequence of pulse trains with DAQmx (the card I have is a PXI-6229 card). As an example:
    - 10'000 pulses at 20kHz every 5 seconds with an initial offset of 2 seconds (let's say 10 pulse trains in total).
    If I use the CreateVirtualChannel.vi in "CO pulse ticks" mode, I can only specificy offset, high ticks and low ticks, but not that the sequence of pulses should be repeated after some time. 
    Now I thought that I could solve this problem if it were possible to multiply two counter outputs: the first counter would generate the pulses (continuously) whereas the second one would switch between low and high on a slower timescale in order to gate the first counter, thereby providing an initial offset and the "off" phases between the pulse trains.
    Is it somehow possible to multiply two outputs with DAQmx and the card I have? Or is there another solution to the problem?
    Thanks a lot in advance for any hints!

    Hi dlanger,
    what you want to do requires a little bit more work. 
    First look at the example "Gen Dig Pulse Train-Continuous.vi" from the LV example finder.
    This example generates a continuous* pulse train. As you see, you need a sample clock VI for setting the sample mode. 
    * NOTE: Generating a finite pulse train with a M-series card requires 2 counter.
    With a pause trigger (DAQmx trigger property node) you can gate the output of that counter.
    Now you have to generate a gate-signal with the the 2nd counter. That means, only if  Ctr1-out is high Ctr0-out outputs the 20 kHz-signal. 
    Maybe you have to adjust the times in my example a bit. 
    Unfortunately there is just one "small" problem: "let's say 10 pulse trains in total" 
    This is not possible, because a 3rd counter would be necessary (*). 
    As a workaround you can modify the while-loop that both tasks are cleared after 50s. This is not brilliant, but should work fine for you. 
    A more sophisticated way is to perform a correlated DIO. So you can generate custom pattern for multiple outputs. 
    A good example can you find here: 
    Retrigger and Repeat Finite Digital Pulse Train in LabVIEW
    http://decibel.ni.com/content/docs/DOC-8473 
    or here:  
    Generating More Than 2 Pulse Trains Using CompactDAQ
    http://decibel.ni.com/content/docs/DOC-2167 
    Hope this helps.
    With best wishes,
    Ralf N. 
    Attachments:
    Gen Gated Dig Pulse Train-Continuous.vi ‏38 KB

Maybe you are looking for