LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Get time of execution of counter measurements

Hello.

 

I use LabVIEW 8.5 and have a NI PCI-6036E, a PCI-6533, a PCI-6534 card and a BNC-2090 module at hand. I have a given voltage signal, that looks like a square wave, but the pulse width varies randomly over time (average frequency of the signal is 5 kHz).

 

What I would like to achieve is to measure when the signal has a rising edge or a falling edge, i.e. I want LabVIEW to measure the rising/falling edges and tell me the exact time (resolution should have µs accuracy) of this change. (*)

 

My first idea would be to split the voltage signal and connect each signal to a counter input (CI). One CI is measuring rising and the other is measuring falling edges. But there's still the problem of getting the point in time of the edges and it seems a bit surprising to me, that LV doesn't offer a VI for such a seemingly simple task.

 

Therefore I am asking if anybody knows a method to get the time of edge detection.

 

I should say, that I have found the NI example Correlation of time with counter measurement , but that's pretty ugly and maybe someone already figured a simpler way to achieve this. Furthermore I have problems implementing the methode shown in the example: my input signal (signal of interest) is simulated by a function generator and the method should work when it has an average frequency of about 5 kHz; my signal of known frequency can have a frequency of 1 MHz (µs accuracy of the clock), but the VI stopps working, i.e. the time is alwasy zero, when my signal of interest has more than about 200 Hz. It seems that the Insert array VI in the second loop is too slow.

 

I would be very glad to receive some suggestions and I thank in advance.

 

Sincerely,

homunculus

 

(*) Alternatively, one could measure the point in time t0 of a rising edge and the length dt of the subsequent pulse width. The time of a falling edge is then te = t0+dt.

 

P.S.: I already posted a similar question in a german LV forum, but the resolution was not satisfactory; Genaue Zeiterfassung und -speicherung zählergestützer Messungen

0 Kudos
Message 1 of 14
(3,665 Views)

hi, are you on windows ? do you use RT ?

0 Kudos
Message 2 of 14
(3,651 Views)

Yes, i use Windows 7 and XP. LabVIEW Real-Time is installed, but I do not use it, because I do not have the required hardware.

0 Kudos
Message 3 of 14
(3,632 Views)

Ok, although I do not use RT yet, can you please tell me how I would be able to resolve my problem if I used LabVIEW Real-Time with the appropiate hardware?

0 Kudos
Message 4 of 14
(3,610 Views)

Hi homunculus,

 

actually I dont think that this will work on PC or RT. It sounds like a FPGA application, because DAQmx will not be able to handle what you want to do.

RT wouldnt make any differences here, because you would also need to use the DAQmx. In FPGA you could read the values as you get them and read also a timestamp and would have all the information you need. It should be pretty easy.

 

I hope this helps, RMathews

Ramona Lombardo
Applications Engineer, NI Germany
Certified LabVIEW Developer
0 Kudos
Message 5 of 14
(3,583 Views)

Hi RMathews.

 

Thanks for your answer. Could you be so kind and explain in more detail why DAQmx is not able to accomplish this? Is it too inaccurate? I mean, LabVIEW seems able to set timestamps, but why do you consider it impossible to achieve my aim with DAQmx?

 

And if I used FPGA, how would I accomplish the given task? Are there any examples or some pages in the documentation that explain this?

 

I've never used FPGA before and giving more details would enable me to suggest some new hardware to my group and may convince them to learn how to handle LabVIEW FPGA.

0 Kudos
Message 6 of 14
(3,559 Views)

Hi,

 

what you need is to get the time of the rising AND the falling edge. DAQmx would either read the one or the other one, but not both.

 

In cRIO you can do what you want: reading timestampes at any edge and any time you want to.So for any edge you would just read the timestamp and you wouldnt need  a driver etc. to do this for you. You can direclty access the signals and perform low-level functions on them.

 

Here you have more information on FPGA

http://zone.ni.com/devzone/cda/tut/p/id/6984

 

 

Ramona Lombardo
Applications Engineer, NI Germany
Certified LabVIEW Developer
0 Kudos
Message 7 of 14
(3,538 Views)

It sounds to me like you could do this with "semi-period measurement".  The only catch is that with your E-series board, I don't know if there's a way to specify whether the 1st captured semi-period begins on a rising or a falling edge.   There didn't used to be any way to do it.  However, that may not be crucial for your purposes anyway.

 

You'll get an array of alternating semi-period times.  A cumulative sum of those semi-periods will be the time associated with each edge.

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 8 of 14
(3,524 Views)

Buffered semi period is just about right.  With a couple of adjustments, you can get an absolute counter time for each edge.  Instead of resetting the count at each edge, it just records the value and keeps counting.  If you do this on two counters, one counting rising and one counting falling, you can interleave the measurements to get everything you need.  The trick is start both counters simultaneously.  I would set up the second counter to use the first counter as the timebase, start the second counter, then start the first counter.  You can also route the input signals so both counters use the same input pin, so you don't have to split the incoming signal either.  You can test the synchronization by setting both counters up as rising edge and verify they both have the same counts.  After verification, switch one to falling edge.

 

You will need to create a large buffer for each counter and read it frequently to avoid losing data.

 

Now if I could just remember what this method is officially called...

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 9 of 14
(3,520 Views)

I took a look at the DAQmx options and couldn't find the one that keeps counting.  However, I did notice there is a property that you can set for semi-period that controls which edge to start on.  If you can get it to always start on a rising edge, you are all set.  You could test it with a signal generator with the duty cycle set low and see if it always starts with the desired edge.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 10 of 14
(3,513 Views)