Measuring period of a pulse

Hi
I m measuring period of a pulse coming from a magnetic proximity sensor. There r two porblems.
1. I want to monitor the data coninuosly in a while loop but the moment it waits for pulse it doesn't stop and hangs for some time....
2. While monitoring the data , sometimes high values appear ....... but these values are unwanted. Once if i want to filter out thse values and see only the exact pattern , how to make it...
PLz. do answer these queries at earliest......
Thanks and regards
GNS

Hi,
To monitor data continuously without hanging:
1. Configure your counter to do "buffered period measurement"
2. In your loop, query the counter for "available points" using "Counter Get Attribute.vi"
3. When == 0, do nothing. When > 0, read that # of points from the counter buffer. This way, you're never asking for any data that isn't already there and your loop won't ever have to hang and wait for it.
4. Accumulate/store/graph your data according to the needs of your app.
To filter out unwanted high values:
First, I'm assuming that your "high values" are high frequencies, thus small periods. If so, these may be caused by sensor and/or electrical noise. The best thing to do first is try to reduce/eliminate the noise at its source. Failing that, there *may* be a way to make good estimates of the correct data, but it could get pretty tricky. Here's an outline of a way to think about and deal with the simplest case -- where you know the expected measured frequency and it's very nearly constant over time.
The characteristic of such a noise glitch would be a a pair of transitions in rapid succession, either low-->high followed by high-->low or vice versa. Either way, you'll pick up one of those transitions in your buffered period measurement. The trouble is that it may happen anywhere within the nominal period, possibly more than once.
Let's first look at a case where the nominal period is 1 msec +/- 20% and there is one glitch of duration 0.1 microsecond, occurring at the 70% point of the real period. The measurement should show one period of duration 1.0 msec, but the noise glitch will cause you to receive instead two periods of duration 0.7, and 0.3 msec.
The simplest correction would be to simply trash all measurements outside the acceptable range of [0.8, 1.2] msec, including these two. Note however that a noise glitch occurring at the 90% point would lead you to trash the 0.1 msec measurement, but believe and keep the 0.9 msec measurement. Note also that if noise glitches are distributed randomly in time, you would end up keeping 40% of such erroneous data (glitches in either the first 20% or final 20% of the real period).
Another correction would be to estimate the period interrupted by the glitch. Start by assuming no more than one glitch per legitimate period. Since the glitch subdivides the true period into a pair, you can re-create the true interval by summing the pair of periods. The catch is to identify which pair needs summing.
The smaller of the pair will show a period <= 50% of the real period, and can be identified. However, the larger of the pair cannot always be identified. The larger of the pair can be anywhere from 50%-99.999% of the real period and may located either right before or right after the smaller of the pair. If you wish to recreate the real period, you'll need to make a mathematically educated guess about which adjacent period to consider as the "larger of the pair."
This is tricky enough as a post-processing exercise, but it's even worse when you process the data as it comes in. Then there will be times where the last element in the buffer is the "smaller of the pair" and you don't yet have the "larger of the pair" data. There will also be (rarer) times when the last element is the "larger of the pair" but you can't yet know that it needs to be summed with the next "smaller of the pair" measurement.
Now consider a case where there could be two or more glitches inside true period. You'll need to evaluate the best choice of summing any two, three, four, etc. consecutive periods to reconstruct the real period. {note that for n glitches and a +/-20% acceptance criteria, then (2/5)^n of the glitched intervals will produce one measurement within the +/-20% bounds.} In such a scenario, I would advise working *really hard* on eliminating the glitches at the source.
Whew, that's a mouthful and a half! Reply if you'd like an outline for an alternate approach, involving buffered semi-period measurement...

Similar Messages

  • Measure period and pulse duration of ttl level continuously

    Hello,
    i want measure the period and pulse duration continuously of two signals with an usb-6009. Every 8s there is a high pulse for 15ms. I want to measure length of the pulse and  pause. Can someone help me? I can`t get a start up with this problem.
    The four measurements (two channels two measurements per channel) are a dataset. This dataset should be stored in a textfile continuously. But this not a problem.
    thankyou
    Schwede

     Hi Schwede,
    Thanks for the update - Im now back in the office!
    I have some bad news, your using the wrong device - you need a device with at least two counters - to acquire for two signals. But, secondly,(see specs), the counter measurements support by the USB 6009 doesn't include pulse or width measurements.
    The specs for the USB 6009:
    Counter
    Number of counters ................................1
    Resolution...............................................32 bits
    Counter measurements ...........................Edge counting (falling-edge)
     To acheive the functionality you require I would recommend a USB 621x: 
    Number of counter/timers ............... 2
    Resolution ....................................... 32 bits
    Counter measurements.................... Edge counting,
    pulse,
    semi-period,
    period,
    two-edge separation
    Also, this link is rather useful also:
    How Many Counters Does Each Type of Counter Input or Output Task Take?
    http://forums.ni.com/t5/forums/replypage/board-id/170/message-id/363123
    Please let me know if you have any other questions.
    Kind Regards,
    Kind Regards
    James Hillman
    Applications Engineer 2008 to 2009 National Instruments UK & Ireland
    Loughborough University UK - 2006 to 2011
    Remember Kudos those who help!

  • How to measure the time a pulse is high for?

    I am using Pulse measure.vi to measure the output of a comparator. My comparator output feeds to an LED. The duty cycle is 50% so the LED just flashes on and off. I want to measure the time the output is high ('ON time') and I have been getting this by just multiplying the pulse width measure by the no. of pulses but I want to modify it to measure the 'ON time' of random signals with different duty cycles...
    The aim is that I am taking in a signal and need the LED to turn on when the signal 'ON time' reaches a certain specified time.
    But before I continue with the LED I am wondering how to add up the time the signal is high for?

    Hi PinkLady4218,
    You should be able to use one of the shipping examples to do what you need, please open LabVIEW and go to Help >> Find Examples.
    From the Example Finder please go to Hardware Input and Output >> DAQmx >> Counter Measurements >> Period or Pulse Width >> Meas Buffered Semi-Period-Continuous.vi
    You will then need to deinterleave the output array as it will show high time then low time then high time then ...
    You will need to confirm the order these values appear and then you can use a function from the arrays palette and use the function "Decimate 1D Array"
    Regards
    JamesC
    NIUK and Ireland
    It only takes a second to rate an answer

  • Measure Period with error out.vi

    I am using LV6.0. Can Measure Period With Error Out be found in the functions panel? If not where it is? If not there can it be imported into LV6.0?

    labview1958,
    Are you looking for a specific VI called Measure Period with Error Out.vi or are you asking about any general function that can be used to measure the period of a signal and includes error handling? If you are looking for a specific VI, I'm unaware of it, so I won't be much help there. If you're looking for any function to do it, have you looked at the VIs called Measure Pulse Width or Period.vi or Pulse Width or Period Meas Config.vi? They are located in the Data Acquisition>>Counter palette. The Measure Pulse Width or Period.vi does not include error handling, but it would be extremely easy to add it. The Pulse Width or Period Meas Config.vi DOES contain error handling, but it only configures the counter to measure the period, it doesn't actually measure it. These, of course, are for TTL signals coming into your hardware device. If you are reading waveform data from a file and want to calculate the period of that signal, these won't do much for you. So what exactly are you wanting to take a period measurement on, a physical signal, physical signal data points from a file, or some other method?
    Tyler S

  • Counter roll-over when measuring period

    Hi,
    I'm using PCI-6251 counter 0 to continuously measure the period of a signal, and I notice there are occasionally  error readings. Since the counter can roll over when it reaches 2^32-1, I need to know what will happen to the period measurement when counter roll overs. Would anyone please help me?
    Thanks.
    David

    The count value will simply wrap-around back to 0 and then continue to increment.  I can think of a few ways to handle this:
    1. Specify a slower timebase for the measurement.  If you go from, say, 80 MHz to 100 kHz, it'll take 800 times as long a period to cause rollover.  This method is pretty simple to implement, but not all apps can accept the loss in precision.
    2.  You can use a 2nd counter to be sensitive to the 1st counter's "terminal count".  This gets a bit complex, so you may need to do more research on some of the terms that follow.
    An internal pulse signal is generated on the board when the 1st counter rolls over from 2^32-1 back to 0.  It's commonly known as "terminal count" or TC.  You'll need to configure a 2nd counter that also measures periods of your external signal, but which uses those TC pulses as its timebase signal.  You may need to fiddle with the "Duplicate Count Prevention" property on the 2nd counter so that it will buffer values of 0 during the majority of intervals where no TC pulse occurs.  During the intervals where rollover happens, the 2nd counter will count how many times it happens.
    You would further need the 2 counters to be started off a common "arm start" trigger to keep their data sync'ed.
    3.  Software method.  You can query the DAQmx Channel property "Counter Input -> General Properties -> More -> Terminal Count Reached".  When you get a 'True' output, the property resets such that subsequent calls will return 'False' until the next rollover occurs.  The problem here is trying to correlate this software-detected rollover with a specific period in the 1st counter's measurement buffer.  You'd probably also need to be querying and tracking the DAQmx Read property for Total Samples Acquired both before and after the TC event.  Even then you might not always be able to determine unambiguously which interval had the TC event.
    -Kevin P.

  • Can I measure period with USB 6501?

    Hi,
    I was told that I can use the one counter in the NI USB 6501 to measure period.  So, I wrote this little VI, modeled after the VI I have that measures encoder period using the counters built into the NI cDAQ 9174 with the NI 9401 digital I/O module.  I have my encoder wires GND and 5VDC on terminals 1 and 2, respectively.  Also, I have encoder channel A and Channel B wires connected to terminals 9 (P2.7) and 24 (P0.7) respectively.  With the MAX, I can count edges with this wiring.  The purpose of this VI is to display an average value of 25 period measurements of the encoder.  The encoder (120 cpt) is turning at about 2-5 rev/second, so, not that fast, maybe a total of 500 period per second; should be easy for this counter.  I'm just spinning it with my finger, so, not that fast.
    Please advise how to use the USB 6501.  I can't find any wiring instructions, other than the pinout, but, the pinout doesn't tell you which channel is the counter gate on the USB 6501, so, I found a response on MAX at channel 24.
    When I run this, the array is correctly initialized to 0.5, but, then I get this error, 200431. I found some things on the forum that suggest I cannot measure period, that I can only count edges.  Should I throw this 6501 away?
    Thanks,
    Dave
    Attachments:
    USB 6501 error.docx ‏24 KB
    USB 6501 period measurement.vi ‏26 KB

    The 9178 also only has 4 counters.
    Do the 5 period measurements actually have to take place at the same time?  Sometimes it might make sense to cycle through the channels to reduce the number of counters used (you wouldn't have to rewire connections or anything as the input terminals are software-defined).  Switching from channel to channel in software should take on the order of ms depending on which hardware you end up using.
    The 9171+(9401/9402) is a relatively cheap way to add additional counters to a system as the 9171 chassis has 4 counters just like the 9174 and 9178.
    Best Regards,
    John Passiak

  • Using a rotary angular encoder to measure period of pendulum

    Hi,
    I'm new to Labview (I hope I've posted this in the correct section) and am trying to measure the period of a physical pendulum. I'm using an Omron rotary angular encoder (E6D-CWZ 2 C) and the SCB-68 NI card. Basically I'm trying to interface my pendulum to the PC in order to analyse the motion.
    I'd appreciate if anyone has any advice or can point me to a tutorial that might help.
    Thanks,
    Sarah

    Hi Sarah,
    Interesting application--I think your best best is to use the counters on the 6024E as follows:
    1.  Configure a Count Edges Task (the E Series cards don't directly support quadrature encoder tasks).
    2.  Use the A output as the edge to count, and the B output as the direction control line.
    3.  Set an initial value such that the bottom of the arc is your "0 reference" (e.g. if you are starting the pendulum 1000 encoder ticks above the bottom of the arc then your initial count should be -1000).
    4.  Every time the counter rolls over it will produce a pulse on its internal output.  This will be every time the pendulum reaches the bottom of the arc.
    5.  You can perform a period measurement using the 2nd counter on the 6024E.  The line that you want to measure will be the other counter's internal output.
    This isn't the most straightforward configuration so you should probably start out by combining shipping examples.  I would start with the following two examples (which can be searched for in the Example Finder by navigating in LabVIEW to Help >> Find Examples...)
    Count Digital Events.vi
    Meas Pulse Width-Buffered-Cont.vi
    I would start out by getting the Count Digital Events example to work so that the value is 0 every time the pendulum reaches the bottom of the arc, then you can try adding in the Meas Pulse Width example to perform the period measurement.
    Best Regards,
    John Passiak

  • Measure time of 5 pulses

    I need to measure the speed of a motor which has an eccentric load so the instantaneous speed of the motor looks like a sine wave. I have 5 hall pulses per one revolution so I want to measure the time of 5 hall pulses and convert this to a frequency to basically filter out the speed fluctuations. The frequency range of the hall pulses to be measured is from 4Hz to 50Hz. I have two motors that must be measured this way and two counters available on a 9172 with a 9411 module. I have tried most of the shipped examples but I have had no sucess trying to filter out the speed fluctuations. I am using LabView 2009.
    Solved!
    Go to Solution.

    Use a running or moving average of the pulse periods.  (I am assuming that you are able to measure the time from one Hall pulse to the next for all the pulses). Since you want the speed based on five consecutive pulses, you really do not need the average, just the sum of the times.  See the attached example in which the pulse frequencies are random but in the 4 to 50 Hz range you expect.  Notice that the speeds are smoother than the pulse times.
    Lynn 
    Attachments:
    Motor Speed test.vi ‏13 KB

  • Measuring period in time critical loop

    I have a loop running at 6 ms for all my application code. I need to integrate a measurement for period of a TTL signal into this loop ( connected to my gate input of a 6602) but all the example VI's I have looked at wait for the counter to respond before moving on - This is a problem with the low speed I am looking at, and when the speed is zero ( hence the overcount kicks in). What is the best way for me to measure a period given that I am restrained by my overall loop time. I have set up a VI which looks at the counter every tenth cycle, but I would rather have the data more frequently than this using some sort of 'peek' type buffered approach.

    If I understand correctly, you have a loop that must run continuously irrespective of whether there is a period measurement available. And if there is a period measurement available, you want to use that value in your loop.
    If all that's correct, just put a case selector around Counter Read Buffer in your loop. Only call Counter Read Buffer when there is a period measurement available.
    How will you know when there is a period measurement available? Call Counter Get Attribute, checking "available points" attribute ID.
    Now, your loop must call Counter Get Attribute every time, but that is a small price to pay compared to locking up the loop waiting inside Counter Read Buffer. Let me know if this helps.

  • 12M Measure Periodic/YTD application

    Dear all,
    When looking into the PeopleMgt application, we noticed that the 12M measure is calculated differently in a periodic application for AST/LEQ accounts.In periodic application, it will take the avg of 12 months whereas in a YTD application, it will take the sum of last 13 periods/13. In the periodic application, it means that months without data are not being considered which leads to an incorrect 12M Measure.
    Looking into AppShell I don't see 12M Measure as a custom measure. Being not involved in the measure setup previously, I would like to know your opinion. Acc to use the 13periods/13 seems more logic. Once we take a decision, can I just change the formula in the MeasureFormula/MeasureFormulaYTD table? Or some other settings I need to consider?
    Thanks in advance!
    Kind regards,
    Sofie Luyten

    Hi Sofie,
    Formula from 12M measure is an MDX formula.
    If that is correct then you just have to place that formula into table MeasureFormula.
    Please make sure you have the correct value for Solve Order. Probably in your case must be bigger than 3 because actually you need the evaluation of your formula to be done after the evaluation of other measures.
    After you insert the correct formula into table MeasureFormula you have to process application using Modify Application and make sure you check both flags: "Reindex and Process application".
    You have all the information about customer measures into HTG from http://wiki.sdn.sap.com/wiki/display/BPX/EnterprisePerformanceManagement%28EPM%29How-to+Guides
    "How to Manage BPC &M Time Dimensions and Custom Measures "
    Regards
    Sorin Radulescu

  • Measure frequency of Z pulse of an accu coder shaft encoder to measure speed using an 6034 E card

    Hi,
    I would like to measure the speed of a engine which has an accu coder encoder hooked onto it. It provides 3 pulses A, B, and Z. I am using a 6034 E PXI card. I wanted to know if there are any examples/ideas that could help me with this (I am new to the digital programming in Labview). I have moved to NI Daqmx 9.8 recently from the older version which supported legacy codes and hence in process of updating the code. I also want to know if an external clock source is required to do this. this. 
    Solved!
    Go to Solution.

    Hello,
    There are several examples in the NI Example finder (you can get here by going to Help >> Find Examples in a LabVIEW window). You can browse to the encoder examples by going to Hardware Input and Output >> DAQmx >> Counter Input. You should be able to find a few examples that will be helpful. 
    Also, this link is a good resources for getting started using DAQmx: http://www.ni.com/white-paper/5438/en
    Thanks!
    Stephanie S.
    Application Engineer
    National Instruments

  • Send CAN remote frames periodic on RTSI pulse

    Hi. I'm trying to send a remote frame (with the RTR bit set) on receipt of a RTSI pulse from a PXI 6602 timer card. I then need to receive CAN data frames at the CAN card from the instruments with the arbitration ID of the remote frame sent.
    I can do this using CAN object transmits period using RTSI example vi and Cont pulse train vi to provide the RTSI pulse. However this can only send CAN data frames, not remote frames. Grateful for any help on this.
    VIV

    Hi VIV
    Instead of using a CAN Object you can use a Network Interface Object for that. There is already an example that just needs minimal modification.
    If you are using LabVIEW:
    Open the NI ExampleFinder and navigate to the Network Interface transmits CAN frame on RTSI example (Hardware Input and Output » CAN » Frame API » Synchronizing CAN with DAQ » DAQ Card Controls RTSI » Network Interface Objects). Modify the example by wiring a '1' (numeric value) to the currently open 'IsRemote' terminal of the ncWriteNet.vi.
    If you are using C:
    Navigate to the …\National Instruments\NI-CAN\MS Visual C\Frame API examples folder and open the Network Interface transmits CAN frame on RTSI example. Locate the line
    Transmit.IsRemote=NC_FALSE;
    And change it to
    Transmit.IsRemote=1;
    Now, you’re transmitting a remote frame with every RTSI pulse.
    -B2k

  • Pulse/Period measurement to control VI

    Hi
    I am enquiring regarding controlling a vi iterations with an external trigger. Let me summarise my VI first.
    I have a for loop using single point aquisition i need to run for a specific number of iterations depending on the time base between my external trigger (this is approx. 1-3 seconds). This is located in a while loop containing a number of other data manipulation including limit testing etc. The reason i am using single point rather than buffered is that i need to display the data in RT and (from my knowledge) i can't get the buffered aquisition to do this, or even waveform AI to do it either.
    I have used the measure period VI in labview to obtain a time in either s or ms within the while l
    oop and passed this to my for loop to iterate x times.
    The problem is (which actually makes sense!) when the while loop runs it must recieve two pulses from the external trigger before it can pass a number to the for loop. The result of this is that i lose sequences (a sequence is the data occuring between the pulses).
    The VI does exactly what i want BUT the timing is all wrong.
    What i need the VI to do is capture the time between ALL the pulse sequences, so that when the VI reiterates, the number of times the for loop must iterate is already in place. I have tried buffered pulse measurement but can't seem to get it to work as i think it should.
    Any ideas? It is kinda difficult to explain this exactly in writing but any solutions appreciated.
    R

    Ross,
    There are definitely different ways of doing this. The way you have done this in your VI will work; however, there are drawbacks. First, each time you call the AI single point VI, it performs a configuration, which takes time, so you're doing this 4 times every loop. This slows down your readings.
    A better way is to scan all four channels at once, and then read them all at once, saving the time to configure every loop. Even better than that is to run a buffered acquisition, and read the most current data out of the buffer.
    Therefore, I would propose taking a look at an example in the LabVIEW directories for a Continuous Scan example. It will show you what VIs you need to set up the acquisition. Then, there will be a while loop w
    hich reads the data. What you'll need to do is look at the inputs of the AI Read VI. There's an input to tell it where to get the data. If you set it to "Relative to the end of the buffer", and tell it to get 1 point, you'll get the most up-to-date point for all 4 channels. Then you can combine the channels to get your plot, just as you are now, and you can look to see if your trigger happens.
    Second, when the trigger does occur, you can do an AI Read outside of that loop and read the ENTIRE buffer, to get ALL of the points. These will be at whatever scan rate you set up, but they will be nice and evenly spaced, not determined by the loop time. So, in this manner, you can still get real-time updates of what's happening, but your scan rate can be higher than the loop time, and you'll still get all the data. Got it?
    If you need an example to demonstrate how to do this, I'd be glad to show you.
    Mark

  • Measure Pulse Width and Period Statistics

    Hello,
    I'm trying to solve what should be a very simple problem. I would like to measure common characteristics of a binary analog voltage input, pulse width and period. The canned pulse width/duty cycle/period VIs and express VIs use a histogram or peak to peak method on a set buffer size of data and produce one output. I would like to measure these signal characteristics over a long period of time and collect statistics on pulse width and period data (max, min, median, mean, standard deviation, etc.) to indirectly measure the eccentricity of a system. Although I am relatively inexperienced in LabView scraping off a considerable bit of rust, I did not think this task would present a challenge, but I have been stumbling around for a couple of days trying to create an array of output parameters such as pulse width so that I may calculate the statistics on all measurements.
    If anyone can step me through some of the thought process to a solution or show me how to format data collection so that this can be done, I would very much appreciate the help.
    Thanks,
    Evan
    Attachments:
    Example.jpg ‏194 KB

    Hi Gena,
    I am assuming you are using the DAQmx drivers in LabVIEW for your
    PCI-6014.  Avoiding a While loop may be difficult if you need to
    perform this measurement many times and you might not know when the
    signal is going to begin.  Without a While loop, you'll have to
    set up your timeout period long enough so the pulses will begin before
    your VI stops.
    With this in mind, you may want to look at some of the shipping
    examples with the DAQmx driver.  You can find these in LabVIEW's
    Help menu by going to Find Examples.  For measuring the pulse
    width, browse the folders in the Example finder by going to Hardware
    Input and Output>>DAQmx>>Counter Measurements>>Period
    or Pulse Width.  In this folder, there is the Meas Pulse Width.vi,
    which measures the pulse width once and stops.  You should be able
    to take the pulse width measurement you get from here and check to see
    if it's in your range, then output a pulse on the other counter if it
    is in the range.  The pulse output examples can be found in
    Hardware Input and Output>>DAQmx>>Generating Digital
    Pulses>>Gen Dig Pulse.vi.
    Thaison V
    Applications Engineer
    National Instruments

  • How to use multiple counters in the 6602 to measure cycle length, calculate delay and generate triggered pulse.

    Hi,
    I need to measure the cycle length of a pulse, calculate a delay based on this value, and then generate a triggered pulse with that delay value. The input and output pulses will be continuous. The best case would be to use the cycle length from one pulse in the calculated delay for the next pulse. One of my biggest problems has been getting the calculated delay value into the pulse specs.vi for the triggered output.
    This output pulse will be used to trigger an IMAQ video acquisition; therefore, the solution to this problem will be part of a larger video acquisition application. This has posed a problem, in that accessing the counters has interfe
    red with the triggered video acquisition.
    Any suggestion will be welcome.
    Thanks
    Dave

    Filipe,
    The overhead is the problem I'm trying to get around.
    Specifically, what I need to do is to generate an output pulse after a trigger pulse, which is a given percentage of the cycle length. The input pulse is from heart rate, so it will have some variance, and the output pulse will be at a stationary point in the cardiac cycle. For example, for an input pulse of 2 Hz (500 ms) the user would likely request the output pulse be delayed by 75%. Therefore, the generated pulse will have a 375ms delay after the trigger.
    In the past I have had hardware built to do this, but I am hoping I can accomplish the same thing with multiple counters on the 6602. I have been able to accomplish this with 3 counters (2 to measure period and 1 for output
    ) but the overhead prevents adequate triggering of the IMAQ video acquisition. I am hoping another method would solve this problem.
    Thanks
    Dave

Maybe you are looking for