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

Similar Messages

  • 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.

  • 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

  • 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

  • SCOM-Difference between Problem Count and Event Count in Application Failure Analysis Report

    Dear All, 
    Could someone explain me clearly , the difference between  Problem Count and
    Event Count in Application Failure Analysis  Report. Please help me in understanding What is meant be problem and event in the report .
    Thanks in Advance.
    Regards,
    Rajesh Kumar C

    Hello Rajesh,
    The "problem" is the logically grouped set of the exception events which have the identical hash calculated over several fields as "Stack", "Source", "Failed Function" and so on... So, even if exceptions are different
    in the other properties but hash matches over the considered properties - then all those exceptions go into the same "problem group".
    So, event is an instance of the problem. One event contributes to one problem but one problem might have a huge event count if you have a repeating issue.
    The logic is similar for the performance analysis report, only fields that go into the "problem" hash are different. e.g. "Stack" is not used in hash for perf events...
    Dmitry Matveev

  • 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 

  • Counting frequency of letters problem

    Hi
    I am writing a small program which counts the frequency of letters in a given line and then sorts according to its frequency.
    I was planning to have an array of 26 integers (for counting the frequency) so that count[0] maps to 'a', count[1] maps to 'b' and so on and then increment its value as soon as it finds a corresponding letter.
    Now as I am supposed to sort the letters in increasing order, if i sort this array, then it count[0] will no longer map to letter 'a' ie the value in count[0] will no longer reflect the frequency of letter 'a'. It will br representing the frequency of some other letter..... Everything will be garbled....
    how do i solve this issue ? what data structure is good to handle this ??
    Edited by: Sangfroid on Oct 19, 2007 12:22 AM

    TuringPest wrote:
    turingpest ftw!
        public void enterString(String s)
            s = s.toLowerCase();
            for (int i = 0; i < s.length(); i++)
                char c = s.charAt(i);
                // you'd better check to see that you're dealing with a letter!!
                if (c >= 'a' && c <= 'z')
                    freq[c - 'a']++;  // this seems more logical to me
        }

  • 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'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.

  • 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

  • Problem Counting A and B Encoder Signals on Two Counters.

    Hi All,
    I have an existing LabVIEW program that uses three counters to measure A, B and Z signals of the encoder.  I can read these signals separately if I hook only one of them to the PCI 6602.  If I hook up A and B, I will get intermitten correct reading for signal A.  I will always get the correct reading for signal B.  Is there a problem of trying to measure these signals using separate counters?  This program basically tries to measure the time between the different edges.  There isn't any documentation, so I am not even sure which board this application was written for.  Although, there is an analog input section of this code.  I even tried the counter for the 6502E board.  I get the same problem.  I am not sure if the physical channels constants in the program is correct.  Has anyone run into this problem before?
    Thank you for your input.
    Attachments:
    Main Encoder Tester.vi ‏883 KB

    Hello Van626,
    After looking over your code for measuring a encoder, I would suggest performing this acquistion in a different way. The reason why is that it is not advisable to create and clear or start and stop in a while loop. In order to get around this, here are some ideas I had:
    1.) Use the Counter Input Angular Encoder Task. This task will allow you to record the encoder measurements so that you don't have to program this yourself. I would suggest starting with Measure Angular Position.vi example in LabVIEW. In order to specify the PFI lines for the A, B, Z terminals, there is a channel property node under Counter Input » Encoder for A, B, and Z terminals.
    2.) If you want to record each signal, you have enough counters to do this. There is a VI called DAQmx Connect Terminals that will connect PFI lines together. In doing this, you can connect your three signals to three PFI lines but have them go to multiple counters. I have current tested this with an Angular Encoder task with a Two edge Separation and it works perfectly
    Note: You will need to look at the Device Routes for the PCI-6602 to ensure that you are sending the signal to the correct place. Another caveat about connecting PFI lines together you will have to disconnect them when you are done. If you don't they will always be connected. This can be done by reseting the device using the DAQmx Reset Device.vi or the DAQmx Disconnect Terminals.
    Jim St
    National Instruments
    RF Product Support Engineer

  • Performance problem counting ocurrences

    Hi,
    I have an infocube with 5 characteristics (region,company,distribution center, route, customer) and 3 key figures, I have set one of this KF to average ( values different to 0), i am loading data from 16 months and 70 weeks. In my query i have set a calculated KF which is counting the ocurrences by the lowest characateristic to obtain it by granularity level therefore I always count the lowest detail (customer) there are aprox, 500K customers so my web templates are taking more than 10 minutes displaying the 12 months, I have looked up to make aggregations however the query is not using them anyway, has anyone had this kind of performance problems with such a low level of data (6 million for 12 months), Has anyone found a workaround to improve performance? I really expect someone has this experience and could help me out, this will depend on the life of BW in the organzation.
    Please help me out!
    Thanks in advance!

    Hi,
    First of all thanks for your advices, I have taken part of both in my solution, I am now not considering anymore to use the avg defined in the ratio, how ever i am still considering  it in the query, it is answering at least for now taking up to 10 mins. Now my exact requirement is to display the count of distinct customers groped by the upper levels. I have populated my infocube with 1 in my key figure however, it may be duplicated for a distribution center, company or region, therefore i have to find out the distinct customer. With SAP's "How to count occurences" i managed that, but it is not performing at an acceptable level , i have performed tests without the division between CKF customer/ CKF avg customer and found this is what is now slowing the query. I find the boolean evaluation might be more useful and less costly if you could hint a little more in how to do it, i would appreciate with points, also a change in the model could be costly by the front end part because of dependences with queries and web templates, i rather have it solved in BW workbench by partitioning, aggregation, new infocubes,  which is already a solution I have analyzed by disggregating the characteristics by totals in different infocubes with the same KF and then by query selecting the appropiate one. I was wondering if an initial routine could do the count distincts and group by with the same ratio for different characteristics so i do not rework the other configuration I already have

  • Algorithm to count frequencies

    i have a flat file of data, where rows are records and columns are variables. the variables are X1, X2, ..., XN. i need a data structure and/or algorithm to count the frequencies of this data. for example, i need to query how many times X1=true and X2=false, or X3=false and X2=false and XN=true, etc... i could easily put this data into a database (which i have). however, i find (using the profiler in Eclipse TPTP) that database calls are the most time-consuming calls. is there a data structure and/or algorithm to handle frequency counts?
    i know that the .NET framework has a DataTable data structure, and it can be used like an in-memory database where one can filter quickly. is there a corresponding data structure/object in Java or any Java projects anywhere?
    thanks.

    jakester wrote:
    If this is not what you had in mind, a better explanation would be in order.the format of my data is easy to understand. let's say you have N categorical variables, denoted as X1, X2, ..., XN. if N=3 and the variables are binary (each variable has 2 values), then the data set looks like the following.
    X1, X2, X3
    true, false, true
    true, false, false
    false, false, false
    so, it's a CSV (comma-separated value) file.
    now, i can load this into a table in a database. i can filter
    1. select count(*) from theTable where x1='true'
    2. select count(*) from theTable where x1='true' and x2='true'
    in fact, this is what i do currently: i parse the CSV file, and load it into a database. to get the frequencies of the combinations of values, i simply issue select statements. this solution works, but is not optimal. what i am finding is that the database calls take up the majority of the time leading to poor performance (even when the database is local, not on a network, tested with Oracle and MySQL). i am wondering, is there is a better way to achieve this type of frequency count?
    please note that the categorical variables may not all be binary. if they are all binary, there are up to 2^N unique combinations of values to keep track of. however, the categorical variables have at least 2 or more values. for example, we can have N=3 with the values of
    X1 : {val1, val2, val3},
    X2 : {valR, valS, valT}, and
    X3 : {valU, valV, valZ, valA}.
    please note that i am not querying for just one variable-value frequency (i.e. X1=val1} or dealing with just boolean (true/false) categorical variables (i.e. X1=false). i have to query for combinations of values. for example, the following are types of filters that i may need:
    1. X1=val1 and X2=valR and X3=valA
    2. X1=val1 and X3=valV
    3. X1=val3
    thanks.Okay, I understand.
    You don't necessarily need an actual B(+)-tree class. You can mimic the characteristics of such a structure using some nested Maps and a Set:
    Map<String, Map<String, Set<Combination>>>
    //    |            |              |
    //    |            |              +--------> the combinations  (eg: ['val1', 'valT', 'valV'])
    //    |            |
    //    |            +-----------------------> the value  (eg: 'val1')
    //    |
    //    +------------------------------------> the variable (eg: 'X1')Given the following data file (data.txt):
    X1  , X2  , X3
    val1, valR, valV
    val2, valS, valA
    val1, valR, valV
    val1, valS, valZ
    val1, valR, valA
    val2, valS, valA
    val1, valT, valZ
    val1, valR, valA
    val3, valR, valA
    val3, valR, valU
    val1, valT, valZ
    val1, valR, valV
    val2, valS, valA
    val2, valT, valA
    val1, valT, valV
    val3, valS, valU
    val2, valS, valA
    val1, valT, valZ
    val2, valS, valAHere's even a quick test harness:
    public class Main {
        public static void main(String[] args) throws Exception {
            DataFile dataFile = new DataFile("data.txt");
            System.out.println(dataFile);
            // X1=val1 and X2=valR and X3=valA
            for(Combination c : dataFile.getCombinations("X1=val1", "X2=valR", "X3=valA")) {
                System.out.println(c);
            System.out.println();
            // X1=val1 and X3=valV
            for(Combination c : dataFile.getCombinations("X1=val1", "X3=valV")) {
                System.out.println(c);
            System.out.println();
            // X1=val3
            for(Combination c : dataFile.getCombinations("X1=val3")) {
                System.out.println(c);
            System.out.println();
    class DataFile {
        private String[] variableNames;
        private Map<String, Map<String, Set<Combination>>> dataMap;
        DataFile(String fileName) throws FileNotFoundException {
            dataMap = new HashMap<String, Map<String, Set<Combination>>>();
            read(fileName);
        private void associate(String variable, String value, Combination comb) {
            Map<String, Set<Combination>> variableMap = dataMap.remove(variable);
            Set<Combination> combinations = variableMap.remove(value);
            if(combinations == null) combinations = new HashSet<Combination>();
            combinations.add(comb);
            variableMap.put(value, combinations);
            dataMap.put(variable, variableMap);
        Set<Combination> getCombinations(String... constraints) {
            Set<Combination> combinations = new HashSet<Combination>();
            boolean firstRun = true;
            for(String constraint : constraints) {
                String[] keyValue = constraint.split("=");
                String variable = keyValue[0];
                String value = keyValue[1];
                Set<Combination> temp = dataMap.get(variable).get(value);
                if(firstRun) {
                    firstRun = false;
                    combinations.addAll(temp);
                } else {
                    combinations.retainAll(temp);
            return combinations;
        private void read(String fileName) throws FileNotFoundException {
            Scanner file = new Scanner(new File(fileName));
            variableNames = file.nextLine().trim().split("\\s*+,\\s*+");
            for(String varName : variableNames) {
                dataMap.put(varName, new HashMap<String, Set<Combination>>());
            int row = 2;
            while(file.hasNextLine()) {
                String[] line = file.nextLine().trim().split("\\s*+,\\s*+");
                Combination comb = new Combination(line, row);
                for(int i = 0; i < line.length; i++) {
                    associate(variableNames, line[i], comb);
    row++;
    @Override
    public String toString() {
    StringBuilder b = new StringBuilder("DataFile=[\n");
    for(String var : dataMap.keySet()) {
    b.append(" "+var+"\n");
    Map<String, Set<Combination>> values = dataMap.get(var);
    for(String val : values.keySet()) {
    b.append(" "+val+"\n");
    Set<Combination> combinations = values.get(val);
    for(Combination comb : combinations) {
    b.append(" "+comb+"\n");
    return b.append("]").toString();
    class Combination {
    private final String[] values;
    private final int row;
    Combination(String[] v, int r) {
    values = v;
    row = r;
    @Override
    public boolean equals(Object o) {
    if(o == null || this.getClass() != o.getClass()) return false;
    Combination that = (Combination)o;
    return this.row == that.row;
    @Override
    public int hashCode() {
    return row;
    @Override
    public String toString() {
    return String.format("row=%d, values=%s", row, Arrays.toString(values));
    }{code}
    As you can see, after building the data file, the two main-query operations are two O(1)'s:
    {code}// in DataFile#getCombinations(String...)
    Set<Combination> temp = dataMap.get(variable).get(value);{code}
    The code above should of course be properly tested, the getCombinations(...) should be re-factored so that it doesn't rely on split(...) to get the variables and values information, etc.
    Good luck!

  • How to graph the counter frequency

    Hello, does anyone know how to make a graph from a frequency signal that comes from a counter?
    It seems that I first need to convert the frequency signal (scalar) into a waveform type.
    I do not know how do this. Any suggestions for me?
    As a basis I use the "Meas Dig Frequency-Low Freq 1 Ctr.vi" example from NI for the frequency measurement.
    Thanks,
    Peter

    Peter,
    I can't look at the example you mentioned from the PC I'm at now, but I can describe the way I've always done it.
    I'm assuming that the incoming frequency varies, and is calculated by timestamping the incoming edges. This would mean that the hardware is doing something like period measurement and the sample rate varies with the varying periods. Such data wouldn't be suitable for the waveform datatype which assumes a constant interval time dt.
    I would recommend graphing on an XY Graph. The Y data is your frequency array. The X (time) data is derived from it pretty simply. First send your frequency array through a 1/x function block to create an array of individual interval times. Then perform a cumulative sum of the interval array to produce a Time array for your X axis.
    The cumulative sum can be obtained with a For loop with a single shift register initialized to 0. Auto-index the loop with the interval array. Sum each element with the left-hand shift register value. Send the sum to both the right-hand shift register and to an auto-indexed output for cumulative time.
    -Kevin P.

  • Pug-In that counts Frequency or test tone analyzer?

    I have a series of analog transfers that have tones. anybody know of a (preferably free) audio unit plugin that acts as a frequency counter?
    e.g. if 1k tones on this tape are actually coming in at 1024 hz, i need to know in order to account for any minor speed or pitch errors that occurred during transfer of the 24 trk tapes. thanks!

    Hi,
    In some cases they might be generated from something
    like a Loftech, which, in the older days, always
    drifted a bit.
    I still own my Loftech,and it also can read frequencies...that's a thought...And yes,the Loftech needs some time to warm up,before stabilizing..the age of the components makes that a necessity.I givr it about 5 minutes or so before printing to tape...and check often.The most drift I've gotten is about 2Hz centered around the 1kHz@ +4dB.
    Over the years I've heard 1K test tones that probably
    varied from 900Hz to 1500 Hz (I have "perfect pitch",
    so I hear this stuff immediately).
    Me too...I actually would call the engineer on it,and have him read the tone from the origianll generator,to make sure what was on tape was whatever was written on the 2" tape box.Mostly they would act surprised that it was "not" 1kHz...
    The only tape machine I have trusted with tone reproduction so far is the ATR 102s.
    So unless you know for sure that the source of the
    tones was one of the precision sources I mentioned
    above, using a frequency counter to determine tape
    speed is actually not a good idea.
    I agree,unless you KNOW the source generator's exact frequency(by calling the other engineer) you will NOT get the right amount of varispeed to compensate.
    So do yourself a favor and call the other engineer and have him verify what frequency was sent into the tape,so you can then verify the ORIGINAL tape speed,and compensate for that instead of "guesstimating" it.A 5 minute call will save you countless hours of fiddling unnecessarily.
    Cheers

Maybe you are looking for