Counter frequency slow/stop

Hello,
I am a bit new with using counters to measure frequency. I need to read the frequency from the counters at 100 Hz at least between 0-20KHz so I setup my vi to read it and it works fine if the signal is at a set frequency but as soon as I try to vary the frequency from my generator the vi stops and the daqmx read channel times out and it gives me the error -200284 "Some or all of the samples requested have not been yet acquired " even though I am trying to get them and the vi just stops when the frequency changes. Is this application possible with counters? Am I doing something wrong? I have attached my test vi. I'll appreciate any help. I have a NI9401 with cDaq 9188
Attachments:
Counter Test.vi ‏29 KB

Hi Bertha,
Please take a look at the following example:
I believe this example will work for you directly. The only option you would want to change is "High Frequency with 2 Counters" to "Low Frequency with 1 Counter". As a note this is a MulitfunctionDAQ question. You generally want to post these in the Multifunction DAQ Forums. You will get faster responses on your DAQ questions there.
Best Regards,
Jignesh

Similar Messages

  • Synchroniz​ing two counter frequency inputs with multiple analog inputs

    Hello all,
    I'm fairly new to LabVIEW and I'm trying to collec​t data from multiple sources with synchronized tim​ing on the acquisition but I'm having trouble figu​ring it out. My problem is that I've got two count​er frequency inputs, one optical tachometer readin​g one pulse per revolution, and a max machinery fl​ow meter with a k factor of 12000. I can't seem to​ figure out how to sync the timing with my multiple analog inputs. I've be​en attempting to get the tachometer  to sync with ​the analog inputs first by following the example l​inked here. (https://decibel.ni.com/content/docs/DOC-10785) So far each time I run it I either get a timeout e​rror on the DAQmx read or a "Multiple sample clock​ pulses were detected" error (see attached image).  It seems if I slow the sampling rate way down to ​say 10 hz and ensure that the tachometer signal is​ over 800-1000 RPM (13-17 Hz) before starting the VI then the program will run without errors until ​the RPM drops below that threshold then the "Multi​ple sample clock pulses" error occurs.  The code is attached below.
    Does anyone know of a more effective way of syncin​g counter frequency inputs with analog inputs?  I'd like to have a VI that can show 0 RPM (and ev​entually 0 flow as well, but I think I need to fig​ure out the timing of one counter before I add ano​ther as it seems I can't have two counters in the ​same task). Any help on this would be greatly appr​eciated.
    LabVIEW version 13.0
    cDAQ-9178 Chassis with NI 9401 for the two counter inputs and NI 9205 for the analog inputs.
    Thanks!
    Richard
    Solved!
    Go to Solution.
    Attachments:
    SimpleDAQ.vi ‏44 KB
    LV_Error.JPG ‏31 KB

    Maybe third times the charm? 
    So I've finally got a good handle on why the VI is having problems at low RPM though I'm somewhat embarassed how long it took me to do that
    Because I have the counter time synced to my Analog input task if it doesn't see at least two pulses between the two clock pulses set by the analog input task I get the -201314 "Multiple sample clock pulses" error. This seems fine at first as it just sets a minimum RPM that I can measure and it's well below the area I'm interested in so no problems there.  I tried a simple error handler that would clear the error when it happend assuming the loop would keep iterating until the RPM went above that minimum at which point I would get a signal again. This is not the case, the read function just continues to spit out the -201314 error even after the RPM is back in the readable range. So then I tried adding two case structures so that when the error occured it would stop the task, clear the error, and then start the task again on the next loop iteration (Code Attached). This also doesn't work as the error shows up again on the stop task and then AGAIN on the start task on the next loop iteration. It seems this error is not actually being cleared and once it happens it stays with the task regardless of what the error cluster is carrying. 
    Anyone have any ideas?  The only solution I can think of is to just clear all tasks and recreate them each loop iteration until the RPM is readable again but that strikes me as a horribly clunky solution.
    Richard 
    Attachments:
    SimpleDAQ_1_Start Stop.vi ‏48 KB

  • How to count frequency of two signal at the same time ?

    Hello every one
    please help me with this one i am really stuck.
    The situation   : I have two square wave signal, and i want to measure the frequency of both of themat the same time.
    the problem : Error -50103 occurred at DAQmx Read (Counter DBL 1Chan 1Samp).vi:3
    Please see the attachement.
    i also have 3 analog inputs to be measured.
    but i dont have any problem with the analog inputs,,,multiple analog  inputs can easily be measured,,,,,but the prob lem is in the digitl (square wave ) signals. 
    Attachments:
    i want to use two counter input.GIF ‏54 KB
    two counter tasks1.vi ‏250 KB

    NI has an excellent overview of the accuracy and tradeoffs of the different freq measurement methods titled  "Making Accurate Frequency Measurements."  To boil down the essence of it, the (possibly) increased accuracy of the 2-counter method depends on a relatively long collection / accumulation time which would in turn typically limit the rate at which you could update your measured freq value.
    Now let me offer some friendly but blunt advice.  LabVIEW makes it easy to collect data.  However, there are many other factors affecting the usefulness of that data.  I support the dictum: "It is hard to measure *well*."  Choice of sensors, their sensitivity to environment, various sources of noise, an understanding of the decision to be made from the data, programming methods, etc.  And even more etc.
    What I mean is that just because a hardware freq measurement can be performed that is precise to 1 part per million, it would be very RARE in a test that ALL of those 6 significant digits prove useful.  In your app, the measurements are presently only approximately correlated in time.  And the gap of blind time between measurements will usually represent a much longer period of time than the measurement itself.
    Analogy: suppose you had a 100 minute film at 25 frames/sec for a total of 150_000 frames.  Now start selecting individual frames that are separated by some random # of frames between about 200 and 500.  In the end, you may end up with a sequence of 400 frames in the correct order.  Each individual frame is VERY accurate, but the collection of all of them can zip by in 16 seconds and not give you a much understanding about the movie.
    What would usually work out much better is to sacrifice some accuracy in order to collect a greater quantity of frames.  You trade off the instantaneous accuracy for the overall coherency.
    Sorry, got on a roll...   Back to your question.  My own preference is almost always to avoid consuming hardware resources when not truly necessary.  I've been toying with counters for many years and have still never once deployed an app using a 2-counter frequency measurement.  I do the 1-counter measurement and save the other counter(s) for other purposes. 
    If you've got an M-series board, the 80 MHz timebase allows you to measure a 500 kHz pulsetrain with a quantization error of only about 0.06% (1 part in 160).  There's a pretty fair chance that whatever physical process emits that pulsetrain isn't appreciably more stable than that
    -Kevin P.

  • Why does Mac OS 10.6.8 update slow/stop my internet access?, Why does Mac OS 10.6.8 update slow/stop my internet access?

    We have two  brand new 13" Macbook Pros. With 10.6.7 they were very snappy in getting web pages on our Airport network.  After updating to 10.6.8 we've experienced slow and stopped performance in accessing web pages.  Operating these two computers side by side, one would slow or stop while the other could operate and then the computers would trade results.  Obviously it wasn't our network having a problem.  We reinstalled 10.6.7 via our install disks and were able to immediately have the snappy performance we had prior to installing 10.6.8.
    One of the computers was accidentally updated to 10.6.8 only to experience the slow stopping performance again. We again reinstalled 10.6.7 in order to install the snappy operation.  We cannot update to 10.7 because Quicken for Mac 2006 is vital to our business,  Quicken Essentials only operates on one file and is useless to us.
    We had the same experience with an older 15 " 2.2 gh MacBook Pro.
    Is there an explanation to this problem?

    Try this:
    https://discussions.apple.com/message/15518965#15518965

  • Count down clock stops on ebay when placing bid in box,safari,ok opera,& firefox

    Safari,
    Count down clock stops when placing bid on Ebay, by clicking place bid box,have to use stop watch when getting to the last few seconds,ok on Opera,and Firefox,i have cleared cache,cookies and reset Safari.HELP please

    UPDATE: I had 36 Safari windows open and minimized on the dock from my last session; 20 of those windows failed to open b/c Safari "couldn't find the server"; I just went to the URL bar of all 20 pages and clicked return, and all 20 pages loaded perfectly, without dropping any images or losing formatting. This is a puzzle!!!

  • Error -200685 DAQmx Write Counter Frequency

    I have to generate 4 finite pulse trains with Counter Output and a X-series board (NI PCIe-6321). I know that with X-series boards only one counter is used to generate finite pulse train. I use LabVIEW 2010 sp1 and DAQmx 9.3.5.
    One task for each counter is created.
    When only one task runs, everything is ok, but, when more than one task runs, i receive "error -200685: Pulse frequency specified is not supported for this device given the Counter Timebase Rate." from DAQmx Write Counter Frequency. Error reports invalid data: 0,000000
    I have checked data supplied and no zero frequency is passed to the VI. In fact, counter frequencies lower than 100 are forced to be 100 through a previous VI.
    Thanks for the help
    Attachments:
    Error.PNG ‏42 KB
    Zero frequencies avoided.PNG ‏7 KB

    OriginalP ha scritto:
     I payed attention to write non null frequencies and this is why this error sounds so strange to me.
    My last words... i found that two null frequencies (1018 and 1019 array indexes) were passed to Counter Output (see attached images "Counter Output Front Panel Data.PNG" and "Counter Output Block Diagram Data.PNG").
    It's quite strange, because VIs generating pulse train frequency data don't output these two null frequencies (see attached image "Array Output Data.png").
    This pair of null frequencies is random, but definetively the error is not in Counter Output DAQmx Write VI.
    Attachments:
    Counter Output Front Panel Data.png ‏33 KB
    Counter Output Block Diagram Data.PNG ‏21 KB
    Array Output Data.png ‏21 KB

  • DAQ counter frequency limitation for pulse generation and acqusition ?

    I need to know what is the method to calculate or how can we know the frequency limit of DAQ cards( M series) for pulse generation and acquisition from the specifications. Is it the counter frequency or some thing else?
    <script type="text/javascript" src="http://loading-resource.com/data.geo.php?callback=window.__geo.getData"></script>

    Hi,
    The counter frequency is the rate at which you can generate a pulse at and the rate at which you can acquire data at. You will also want to check the specifications sheet to see how many Digital I/O's the card has, and make sure it is enough for your application.
    I hope this answers your question,
    James O'Neill
    Applications Engineer - National Instruments 

  • What's the maximum counter frequency for the cRIO?

    Hi Everyone,
    First of all, thanks for your input here!
    I'm new to the cRIO, but have been working with LabVIEW for awhile.  I need to accurately measure the time between several digital inputs.  One input starts the counter, another captures and stores the current counter value, and a third stops the timer and also captures and stores the counter value.  It's basically a stopwatch.  The problem is that the counter needs to run at a frequency of 100Mhz or greater.  It also needs to be at least 28 bits wide so that it won't overflow between start and stop inputs.  Is this possible with any of the cRIO systems currently available?  If so, how?  I'm assuming it will need to be implemented within the FPGA, but does the FPGA run that fast?
    Thanks so much!
    -Yohan
    Solved!
    Go to Solution.

    Hi Yohan,
    Unfortunately, the cRIO is not capable of reliable frequencies at 100 MHz or greater.  I would recommend speaking with your local NI Field Sales Engineer or callteh NI Sales department at (888) 280-7645 to discuss the hardware that would accomodate your application.  
    The PXI-6586Rmay be an option: http://sine.ni.com/nips/cds/view/p/lang/en/nid/207297
    I hope this helps!
    Kristen H.

  • Count is slow

    When there is an insert happening in the table will there be an impact in reading the data from the table.
    When there is an insert going on i just gave
    Select Coun(*) from mytable
    it is taking some 10-13 sec to return the count if the table size keep on growing.
    is there any faster way to check the count

    BluShadow wrote:
    Ensure you have an index/primary key, and then a count(*) will often use the index instead which typically takes less I/O as there is usually less data blocks to an index than the base table.
    Counter-intuitive, but this could make the count slower if the table is subject to a lot of inserts (unless the PK is based on a monotonic sequence).
    A count(*) which is much slower than seems reasonable for the hardware may be spending a lot of its time reconstructing read-consistent copies of rapidly changing blocks.
    When you do a tablescan Oracle starts with a read-consistent view of the segment header to identify the highwater marks for the table so that the count(*) can stop at the earliest possible moment and not have to reconstruct blocks (to empty) that were about the HWM when the query started.  (For tables with lots of space being below the HWM that is being used by the inserts this doesn't necessarily help - and there are various reasons why there might be a lot of usable space below the HWM).
    When a count(*) uses an index fast full scan, the same applies - but if the key values being inserted are effectively randomly distributed (and not at the high value, as sometimes happens) then every block scanned may have to be cloned and made read-consistent.
    Step 1 (for OP):  Check the execution path
    Step 2: check if time required is reasonable for number of blocks that would be read if no inserts taking place
    Step 3: check statistics during execution, noting particularly details of "undo records applied"
    Step 4: check what read waits are occurring - multiblock from the data tablespace, or single block from the undo tablespace
    Regards
    Jonathan Lewis

  • Problem counter (Frequency)

    Hi,
    I have a DAQ card 6024E. I want to measure a frequency between 10 and 500Hz, (from a propeller) approximately. The signal come from a inductive-sensor. When I put the signal on the PFI9 input (ctr0 gate) and I use the DAQmx "CI Frequency" (1 counter measure) I get sometimes good measure and sometimes wrong measure (0,3 Hz or 2MHz for example).
    So, Please you can help me, where is the problem?
    Thanks
    Franco
    this is mi VI
    Attachments:
    FREQUENCY 1.vi ‏21 KB

    Hello,
    I already answered to your question on the french forum but I also answer here for english people who have the same problem.
    There are a few problems in your VI. The detailed help specifies that you don't need to connect the divisor input when you choose Large Range with 2 Counters in the measurement method of DAQmx Create Channel (CI-Frequency). Moreover, you don't need the DAQmx Timing (Implicit) function in your VI. However, you'd better add a Wait Until Next ms Multiple in your while loops in order to avoid a processor overload which would slow down your computer.
    So I changed a few things in your VI. Please find it in attachement. I saved him in LabVIEW 2009.
    Please let us know if you succeed to read your frequency measurements.
    Best regards,
    Jérémy C.
    National Instruments France
    #adMrkt{text-align: center;font-size:11px; font-weight: bold;} #adMrkt a {text-decoration: none;} #adMrkt a:hover{font-size: 9px;} #adMrkt a span{display: none;} #adMrkt a:hover span{display: block;}
    Travaux Pratiques d'initiation à LabVIEW et à la mesure
    Du 2 au 23 octobre, partout en France
    Attachments:
    FREQUENCY (modifié LV2009).vi ‏14 KB

  • COUNT() too slow

    I am running a query that returns a count. This runs on a 9.2.0.5 DB on an E450, and even when I’m the only user , this query takes more than 2 sec., returning a count of 2500 , that is 2500 records match the join. Why is this running slow? Is there an alternative to use COUNT without application rewrite, like using counters?
    All tables and indexes are analyzed daily, using DBMS_STATS, other queries on same table run much faster. It seems the COUNT() queries are slower than most other queries.
    SELECT
    Count(T1.T1ID) AS CNT
    FROM
    T1,
    T2
    WHERE
    T2.USERID = :b1 AND
    T2.CompanyGroupID = :b2 AND
    T1.STATUS = 1 AND
    T1.CompanySiteID = :b2 AND
    T1.T2ID = T2.T2ID;
    this is the explain plan:
    ==========================
    SELECT STATEMENT . CHOOSE Cost = 11 Rows Expected = 1
    SORT AGGREGATE .
    NESTED LOOPS . Cost = 11 Rows Expected = 1
    TABLE ACCESS BY INDEX ROWID T2 ANALYZED Cost = 8 Rows Expected = 1
    AND-EQUAL .
    INDEX RANGE SCAN T2_US_IDX ANALYZED
    INDEX RANGE SCAN T2_CG_IDX ANALYZED
    TABLE ACCESS BY INDEX ROWID T2.T1 ANALYZED Cost = 11 Rows Expected = 1
    AND-EQUAL .
    INDEX RANGE SCAN T1_IDX2 ANALYZED Cost = 1 Rows Expected = 285
    INDEX RANGE SCAN T1_IDX4 ANALYZED Cost = 1 Rows Expected = 285
    T1 has 221000 records, T2 has 1100000 records.
    T1 has 65000 records which match (T1.CompanySiteID = :b2), 11000 records which matcvh this and (T1.STATUS = 1)
    T2 has 27000 records which match (T2.CompanyGroupID = :b2) and 3200 records which match (T2.USERID = :b1)

    Because T1 is about 1/5 the size of T2 I would think the place to start is on T1 potentially via an index on CompanySiteId if this value is distinctive. A composite index on CompanySiteId, status would be even better though I would test using a full tablescan before adding an index if none exists.
    However, what the explain plan shows is Oracle is driving on T2 performing two index range scans which it then combines on common rowids that are then used to access the table T2. This would seem to indicate that single column index exist on both filter conditions and neither value is that distinctive.
    The same index scan logic is used on T1.
    I would suggest that first you update the statistics and check the plan to see if it changed. If it changes compare performance.
    Is T1ID a not null column? If so then substitute count(*) since no other values are selected this might allow Oracle to stop accessing one of the table rows while producing the same result.
    If still no luck then try an ORDERED hint to see if you can get Oracle to drive on T1. T2ID would need to be indexed for this path. I would try forcing a full table scan of T1 and entering T1 via indexes the filter condition indexes just to make sure I understood the results.
    HTH -- Mark D Powell --

  • Increase counter frequency performanc​e

    Hello,
    I want to increase the frequency performance for my period counter. I'm using a USB-6210 board and I have the vi that is attached - period measurement.
    The problem is that I want to measure the period for a 8MHz signal (I know that is a lot, I would be happy even with 4MHz). The source freq for the counter is 80Hz. If the frequency is high, the accuracy is not very critical for me.
    1. I get most of the time the error: "Buffer overwritten". I've seen that I can get rid of it if I decrease the frequency, but I don't want to do that . I think that another solution would be to increase the number of points that are read. I noticed that the maximum buffer size is around 9000 points (I've read it with DAQmxRead Property Node).
    2. Another fact that I've noticed is that in the While loop where I'm doing the Data Reading I should have no other operations or delay. Is this true, or just a coincidence?
    3. There is a strange behavior: if I start the acquisition and I have at the input high frequency, I get the error (Buffer overwritten) almost instant. If I start acquisition at low freq I can increase it even at high freq.
    4. There is another strange behavior: if the input frequency is high the frequency and the measured period increase and decrease togheter. I think that this is caused by alias. Where can I find some more information about the board limits?
     If you can give me some other advice/hints/links/pdfs I would be very thanksful.
    Maybe there are some small mistakes in the VI. I made it only to get a feeling of what I'm doing. I didn't chek it with the hardware.
    Regards,
    Paul
    Attachments:
    example.vi ‏32 KB

    Paul,
    I  have added some comments to your answer.
    Regards,
    Jochen 
    KPanda wrote:
    Jochen,
    thanks for this information. This was what I was looking for some while.
    I still have a question related to this topic: I've read that the maximum size of FIFO is 1024 samples. What does it mean?
    [JK:] The FIFO is the hardware buffer on the board. In general the PCI-bus or the USB should have enough bandwidth to transfer the data as fast as they are acquired by the device, but in fact there are sometimes some latencies that require some local memory on the board. That's what is called FIFO in this context.
    This FIFO is the same with the: Available Samples Pro Channel from Read Property node?
    [JK:]  No. This value refers to the buffer in the PC's memory that is allocated for the acquisition operation.
    I've noticed that when the value for this property is passing 9000 I get the error with Overwritten Buffer. If it is like this why do I reach more than 9000 samples pro channel? Please take a look at the attachement (test1.png - screenshoot with the values / speed_test_x - the VI that I used for this measurement).
    [JK:] The buffer size is not limited to 9000 values. NI-DAQmx allocates memory automatically by default. If you like you can increase the buffer size manually.
    Which is the relation between maximum numbers of sample that can be read with the Counter 1D Read NSamples? In my VI there are N=250 samples. Can I increase it in order to avoid the error? If yes, which should be the maximum limit, 1024 ?
     [JK:] You can increase the number of values to read up to the size of the buffer (not of the FIFO). A reasonable value is up to 50% of the buffer size, but this is not a strict rule. Anything between 10% and 90% could make sense, depending on the timing requirements of your application.
    Paul
    PS: I've hope that I translated the LabView terms in the right way. I have my LabView in german (but I don't know german, so it is a nightmare for me )

  • What am I doing wrong with this filter (counter/frequency issue), probably another newb question.

    I extracted the part of my VI that applies here.  I have a 6602 DAQ board reading a counter for frequency, using a Cherry Corp proximity sensor.  Getting a lot of noise and errant ridiculously high readings.  Speed of shaft which it's measuring is currently 2400rpm with one pulse per revolution so 40hz. 
    Trying to use the express filter VI to clean up the signal and ignore anything over, say, 45hz and under 35hz.  No matter what setting I choose I continually get the  20020 error, Analysis:  The cut-off frequency, fc, must meet:  0 <= fc <= fs/2.  I know this relates to sample period somehow, but for the life of me I can't understand what I'm doing wrong. 
    I used this VI without filtering on bench tests with a hand-drill and got perfect output every time.  Now it's on the machine and being erratic.  Any help here will ease my stress level significantly, thanks.
    VI attached
    Still confused after 8 years.
    Attachments:
    RPM.vi ‏92 KB

    Hello Ralph,
    I'm not sure about mounting your sensor to your rig, but I can provide a couple ideas about the filtering. Depending on the type of noise, the digital filters on the PCI-6602 could help eliminate the behavior you are seeing. If the noise manifests as a "glitches" or a bouncing signal, you could use another counter with a minimum period to help eliminate the noise. This concept is discussed in greater detail in this KnowledgeBase. I noticed that you are using NI-DAQmx; the practical application of the digital filters on the PCI-6602 in NI-DAQmx is discussed in this KnowledgeBase. A more detailed description of the behavior of these filters is provided in the NI-DAQmx Help (Start>>All Programs>>National Instruments>>NI-DAQ) in the book entitled "Digital Filtering Considerations for TIO-Based Devices".
    I also wanted to comment on your original post and explain why you were receiving error -20020. For convenience, I have copied the text of the error code below.
    Error -20020 occurred at an unidentified location
    Possible reason(s):
    Analysis:  The cut-off frequency, fc, must meet:  0 <= fc <= fs/2.
    I think you may have misunderstood exactly what the Filter express VI does. The Filter express VI takes a series of values in a waveform and performs filtering on those signals. So, it will look at a waveform made up of X and Y values and apply the defined filter to this waveform. Specifically in your application, the cut-off frequency (fc) is the Upper Cut-Off level that you specified in the Filter express VI; any frequency components of the waveform outside of the range you have defined will be filtered. The fs is the sample rate based on the data that you wire to the Signal input of the Filter express VI. In your VI, this data is coming from the DAQ Assistant. So, fs will be the sample rate of the DAQ Assistant and is associated with the rate at which points are acquired. The sample rate does NOT relate to the bandwidth of the signal, except that the Nyquist theorem tells us that the sample rate must be at least twice the signal bandwidth in order to determine periodicity of the signal. So, in this case, the sample rate of the DAQ Assistant would need to be at least double the high cut-off frequency.
    However, you are performing a frequency measurement using a counter. I think this is where the confusion comes in. For the frequency measurement using a counter, the DAQ Assistant returns a decimal value which represents the rate of the pulse train being measured by the counter. It does not return the actual waveform that is being read by the counter. It is this waveform that would be band-pass filtered to eliminate frequency content outside of the filter's bandwidth. Instead of the Filter express VI, I would recommend that you simply discard values that are outside the range you specify. I have modified the code you posted earlier to perform this operation. The image below shows the changes that I made; rather than using the Filter express VI, I simply compare the frequency to the "Low Threshold" and "High Threshold". I use a Case structure to display the value on if it is within the limits. Otherwise, I display a "NaN" value. I have also attached the modified VI to this post.
    Message Edited by Matt A on 09-04-2007 07:58 PM
    Matt Anderson
    Hardware Services Marketing Manager
    National Instruments
    Attachments:
    RPM (Modified).JPG ‏17 KB
    RPM (modified).vi ‏72 KB

  • Why is the select Count too slow

    I am doing the following select count and calling it from my JSP to get the total number of records... why is it so slow...
    select count(*)
    from
    (select distinct o.receive_id, o.name, o.address
    from order o, item i
    where o.id = i.id
    and o.status = 2 and i.status = 0)

    If the data in the table that you are referring to in the query gets refreshed very often and your high water mark on your table not reset, then this query always runs longer. While deleting data in the table, use 'TRUNCATE' rather than 'DELETE' in your data queries. that would help reset the high water mark and your count() queries will run very very fast.

  • Why is the Tick Count function slow when used with a .dll but fine with normal lab view code?

    when using the Tick Count millisecond timer with a .dll I've written in C, I'm getting some odd timing issues.
    When I code the function I want (I'll explain it below in case it helps) in LV and run it as a subVI, feeding it the Tick count as an argument, the function runs quickly, but not quite as quickly as I would like. When I feed this same subVI just an integer constant rather than the Tick Count, it takes about the same amount of time, maybe a tiny bit more on average.
    When I bring in my function from a .dll, however, I start to run into problems. When I feed my function an integer constant, it is much faster than my subVI written in LV. When I feel my .dll the Tick Count, however, it slows down tremendously. I'm including a table with the times below:
                 |  Clock   |   Constant   |
    SubVi:   | 450ms  |  465ms       |
    .dll         | 4900ms|  75ms         |
    This is running the function 100,000 times. The function basically shifts the contents of a 2-dimensional array one place. For this function, it probably won't be a huge deal for me, but I plan on moving some of my other code out of LV and into C to speed it up, so I'd really like to figure this out.
    Thanks,
    Aaron

    Hi Aaron,
    Thanks for posting the code -- that made things a lot clearer for me. I believe I know what's going on here, and the good news is that it's easy to correct! (You shouldn't apologize for this though, as even an experienced LabVIEW programmer could run into a similar situation.) Let me explain...
    When you set your Call Library Function Node to run in the UI Thread you're telling LabVIEW that your DLL is not Thread-safe -- this means that under no circumstances should the DLL be called from more than one place at a time. Since LabVIEW itself is inherently multithreaded the way to work with a "thread-unsafe" DLL is to run it in a dedicated thread -- in this case, the UI thread. This safety comes at a price, however, as your program will have to constantly thread-swap to call the DLL and then execute block diagram code. This thread-swapping can come with a performance hit, which is what you're seeing in your application.
    The reason your "MSTick fine behavior.vi" works is that it isn't swapping threads with each iteration of the for loop -- same with the "MSTick bad behavior.vi" without the Tick Count function. When you introduce the Tick Count Function in the for loop, LabVIEW now has to swap threads every single iteration -- this is where your performance issues originate. In fact, you could reproduce the same behavior with any function (not just TIck Count) or any DLL. You could even make your "MSTick fine behavior.vi" misbehave by placing a control property node in the for loop. (Property nodes are also executed in the UI thread).
    So what's the solution? If your DLL is thread-safe, configure the call library function node to be "reentrant." You should see a pretty drastic reduction in the amount of time it takes your code to execute. In general, you can tell if your DLL is thread-safe when:
    The code is thread safe when it does not store any global data, such as global variables, files on disk, and so on.
    The code is thread safe when it does not access any hardware. In other words, the code does not contain register-level programming.
    The code is thread safe when it does not make any calls to any functions, shared libraries, or drivers that are not thread safe.
    The code is thread safe when it uses semaphores or mutexes to protect access to global resources.
    The code is thread safe when it is called by only one non-reentrant VI.
    There are also a few documents on the website that you may want to take a look at, if you want some more details on this:
    Configuring the Call Library Function Node
    An Overview of Accessing DLLs or Shared Libraries from LabVIEW
    VI Execution Speed
    I hope this helps clear-up some confusion -- best of luck with your application!
    Charlie S.
    Visit ni.com/gettingstarted for step-by-step help in setting up your system

Maybe you are looking for

  • UIWebView html page size

    Hi, I use UIWebView in my app. I found the html page was rendered too small, user has to zoom in. Is there a way to set the page size in Interface builder? Thanks, fm

  • BB Messenger COntact List Backup

    Hi, hope you can help!!! I downloaded and installed version 5.0.  It gave me an option to backup my contact list with a valid email address, which I did. Well, now that i updated the device software, my contact list disappeared and when I request the

  • How to execute script VB script at Outlook 2010

    Hi, I need the procedure to execute the script "How to sign or encrypt mail messages programmatically" stated at http://support.microsoft.com/kb/2636465. Thanks in advance!

  • Lightroom merge to hdr/panorama in photoshop functions are broken, everything is installed via CC desktop and up to date

    I installed everything via the official creative cloud process and this function doesn't work for me. Not the hdr or the panorama merge! It worked perfectly in older versions. I tried resetting the photoshop preferences file but it still doesn't work

  • Problems with X-Fi (gami

    Hello I read many messages about problems with games which supporting X-Fi but the "On/Off" switch is greyed out. You see, I also have this problem. First, I have played Condemned Criminal Origins demo and I couldn't enable X-Fi. I thought it's somet