Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

sync period measurements

Hi,

 

I'm doing period measurements with two counters with the USB-6210. I'm trying to synchronize them so they both start at exactly the same time. I attached the code that I'm using. 

In order to check if they are synced, I split a signal into both counters and I run the code. When I look at the results the array sizes are not the same. This can be an indication that the signals don't  stop at the same time. When I wire one the signal to one of the counters only in the middle of the measurement (meaning that it detetcts no signal for a few seconds), I don't see a long delay from the results.This is making me wonder if the period measurement actually starts at the same time. I also have other results which indicate that the signals don't start at the same time.

Eventually, when this works, I'm going to use two different signals at a totally different rate.

I don't understand why this is not working. Any advice would be great.

 

Also, I have another card (pci-6251) which I would like to use for a third period measurement. I would like this signal to also by synced in time with the 2 other signals. Is this possible?

 

Thanks,

Eyal
0 Kudos
Message 1 of 8
(3,941 Views)

Hi,

 

How exactly are you trying to synchronize these measurements?  Are you using an arm trigger? if you use an arm trigger properly then it should ensure that both counters start reading at exactly the same time. i was able to do this on my M-series device and had it return two arrays of exactly the same size if stop at the same time.  However, the array size will depend on the the signal you rout to the counter as a pulse width measurement is returned anytime a full pulse has passed. 

Please see the attached code to see how to implement an Arm Trigger for two different counters. If you are stillhaving trouble reply to this thread and attach you code.

The use of an arm Trigger is discussed in the following knowledgebase Article.


http://digital.ni.com/public.nsf/allkb/9C657EE63C9D07A686256F6D0062AC66

Charley Dahan

Global Account Manager
0 Kudos
Message 2 of 8
(3,923 Views)

Oops... I forgot to add the attachment.

The latest labview version I have available is 8.5 so I couldn't open the attachment.

I'm using arm trigger but it doesn't seem to work. I didn't wire the number of samples per channel on the Daqmx read task. Doing so can make the arrays identical but does not necessarily mean that the two counters are synchronized in time. 

Lets say I take the same signal and split it but I only wire it to the second counter a couple of seconds after I start measuring. I would expect that counter to start with the first counter but only detect the first pulse after a couple of seconds (+ the actual time of the pulse). It doesn't seem to be the case when I try to do it.

Am I doing something wrong? Are my expectations wrong?

At the moment I'm trying to use the code with the USB-6210.

 

Thanks,

Eyal

0 Kudos
Message 3 of 8
(3,908 Views)

Hi,

 

I think I figured out part of the problem. When run a period measurement (1 counter) with the pci-6251 the first number in the array is always a random one. This number is the time interval between the start of the measurement until the first pulse. When I run the exact same program with the USB-6210, the first number is always the pulse interval.

If I use a 1kHz input signal the result with the pci-6251 would be a random number and the rest of the array would be 1msec. 

If I do the same with the USB-6210 the results would be just all the values of the array = 1msec.

This means that on the usb-6210 the measuring task begins not when you tell it to begin but when the first pulse after that arrives. If this is true, then making sure that the tasks on 2 channels start at exactly the same time is irrelevant. 

Is this an issue with the driver or the card?

I also have another issue with the usb-6210. When I run the period measurement ( ticks units), it always omits 1 on all of the values. This is not the case with the pci-6251. 

 

I'm running labview 8.0 and the diver is NI-DAQmx 8.7.1

 

Thanks,

Eyal

0 Kudos
Message 4 of 8
(3,903 Views)

After looking at your program you look like you are arming your counters properly (like i was in my program which i attached).  When I run your program on my device by splicing a square wave signal into both counters of my M-series card (PCI-6251) The two arrays that returned- counter 1 and counter 2 are always identically sized. as long as they are always connected.  You are correct that if you have ctr 0 disconnected for the first couple of seconds you will get a different sized array.  This is because a sample is returned from a counter when a rising edge is sensed on the counter this is called implicit Timing. More specifically how a period measurement works is that the counters counts how many ticks of the Timebase (80Mhz) clock occurs between two rising edges.  Once the second rising edge occurs the period is calculated by the driver and moved to the computer buffer (this is now a sample that can be pulled off of the daqmx buffer using a counter read period measurement.  Therefore if you do not have any signal connected to your counter, your counter will count up forever and not return a sample to the computer buffer as there are no samples ready to be moved. This is the main reason why you would get different sized arrays.

Please see the DAQmx help for a description of implicit timing:

http://digital.ni.com/public.nsf/allkb/2B6477E3A9B7C07386256D1F0066FBDD

 

Your counters however are armed and synched as they started counting the timebase at the same time by use of the same arming trigger.

 

I don't exactly know if the driver handles the USB device any differently but I would imagine that it wouldn't because the ONLY difference between the two devices is that the USB-6210 has a larger FIFO buffer (1023 samples) on board. I haven't been able to check into this at all as I don't have the device on my desk currently. 

 

I hope that this sheds light on your application and the problem you are experience.  let me know if there is anything else that I can help with. 

Charley Dahan

Global Account Manager
0 Kudos
Message 5 of 8
(3,884 Views)

Thanks for your reply CharlesD.

 

Once I start the measuring task I should count clock edges until my next signal arrives. This is the reason why the first value of the measurement is never an indication of the actual signal I'm trying to measure (it is the time difference between the beginning of the measurement and the first pulse of the input signal ). If I don't wire one of the counters for lets say a second my first value in the array should be slightly larger than 1sec. Ofcourse my array size would be different, but if I sum all the values in each array and compare the result, it should be the same (both should be equal to the time of the measurement). This is not what I see with the USB-6210 but it is what I get with the pci-6251.

I would appreciate it if you check this out on the usb-6210. I think there is a bug somewhere since my two cards don't behave in the same manner.

I also think that the arm trigger is not working on the usb-6210 and I would like to find out the reason for the problem.

I would also like to know why my usb card always gives the number of edges -1 when I perform period measurements. 

 

Eyal

0 Kudos
Message 6 of 8
(3,880 Views)

Eyal,

 

I tested your program and it worked fine with the USB-6210.  How exactly are you wiring up the 6210 I think that this is the problem here.  Do you get the correct numbers in Frequency 1&2?  Where are you getting this number of edges -1?  Are you seeing any errors?

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 7 of 8
(3,868 Views)

Hi Jason,

 

I get similar frequencies in 1 & 2 but unless I add 1 to all the values in the array it is the wrong frequency.

I don't see any errors.

I'm not sure how I can wire the 6210 incorrectly. I use PFI 1 (or PFI 2) and the ground. How would incorrect wirring give me the number of edeges -1.

Either my card is bad or the previous drivers have a bug.

I get the number of edges -1 for period measurement or frequency measurements (on both counters). I didn't try any other task.

 

Thank you,

Eyal

0 Kudos
Message 8 of 8
(3,863 Views)