Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

PCIe-6602 measure edge separation between two square waves

Hello,

 

I have a PCIe-6602 and I wish to measure the edge speration of two quadrature wave forms from an rotary encoder.  Example: I watch for a transition of channel A. This transistion is can be either positive or negitive going edge. On the transistion the timer starts and then stops when the other channel, channel B sees a positive or negative transition.  This delta is the time that I am interestined in and that needs top be captured.

 

Thanks for help,

 

Mike Walczak

 

 

0 Kudos
Message 1 of 12
(7,822 Views)

Hello Mike,

 

You can just use the Meas Two Edge Separation.vi from the Example Finder (Help » Find Examples » Hardware Input & Output » DAQmx »Counter Measurements »Two-Signal Edge-Separation) Just put a DAQmx channel property node to specify what channels you are going to use as inputs.

 

 

Two edge separtion measurement.png

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 2 of 12
(7,815 Views)

Hi, I am having some problems with Two Edge Separation method, and I use .Net exmple from DAQmx.

 

The problem is that I wanna measure following two signals separations.Separation between two raising edges is 52ms.

However, when I measure it using .Net example. I get Time out error or inaccurate values.

Timer 1.JPG

 

I used following setting to measure it. Another problem is that the acquisition Data changed if I changed Maximum Value and Minimum Value.

For example,

  1. When I set 45ms(min) and 65ms(max) to get 52ms, I got Time Out Error.
  2. When I set 1ms (min) and 100ms (max), Acquisition data is around 0.9.
  3. When I set 1ms (min) and 200ms (max), Acquisition data is around 3.2.

timer1 twoedgeseparation vb measure after triggering.JPG

 

There are other timing signals to measure as well. The edge separation for other signals are 10ms, 12ms and 112ms.

I can only measure accurately for 112ms Timing Signals using .Net example

 

.Timer 3 Pass.JPGtimer3 twoedgeseparation vb.JPG

 

I tested 112ms Timing Signals at other CTR channels and it showed accruate values too.

Please advise me for that problem. Thank You.

 

Yan

 

0 Kudos
Message 3 of 12
(7,718 Views)

Hello Yan,

 

I tried out the Measure 2 Edge Separation example from the .NET 4.0 folder, and it worked just fine for me, as expected. I tried to read in two counters, and set up a delay of 52 ms for each counter pulse.

  1. Can you try to read two internal counter outputs? You can do that using the function myTask.CIChannels.All.TwoEdgeSeparationFirstTerminal = "/Dev1/Ctr0InternalOutput"; You can insert it just before the counterInReader function.
  2. Has the two edge separation ever worked before? Can the counter measure a 52 ms single pulse? Maybe try to use another example such as the MeasPulseWidth.
Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 4 of 12
(7,704 Views)

Hi Daniel,

 

Thank you for your reply.

  1. I do not understand how to read two internal counter output.
  2. I can measure other two timing signals (edges separations are 120ms and 10ms) with two edge separation method.

I don't know what is wrong with input signals for 52ms separations. However I can still get the correct input waveform on Oscilloscope.

0 Kudos
Message 5 of 12
(7,692 Views)

Hello Yan,

 

  1. Take this code as an example. In this example, I used Counter 3 to read in the signals, which is specified in the UI. However, notice how I can specifically set the input terminals where my signal will be routed (which are CTR3 Source and CTR3 Gate) to the internal counter outputs for CTR0 and CTR1, in my example, which are going to generate the pulses to be measured. By doing this, you don’t have to do any external wiring, since the signals are captured internally by using other counters on the same card.

                               myTask= new Task();

                              

                               myTask.CIChannels.CreateTwoEdgeSeparationChannel(

                        counterComboBox.Text,"",

                                      Convert.ToDouble(minimumTextBox.Text),

                                      Convert.ToDouble(maximumTextBox.Text),

                                      firstEdge, secondEdge, CITwoEdgeSeparationUnits.Seconds);

     

                    //Set the counter input channel as an Internal Counter of my pulse output channels

                    myTask.CIChannels.All.TwoEdgeSeparationFirstTerminal = "/XSeries/Ctr0InternalOutput";

                    myTask.CIChannels.All.TwoEdgeSeparationSecondTerminal = "/XSeries/Ctr1InternalOutput";

     

     

                               counterInReader = new CounterReader(myTask.Stream);

                               double data = counterInReader.ReadSingleSampleDouble();



  2. It appears that there might be something wrong with a specific internal timebase, as you seem to be measuring accurately 120 ms separation as well as 10 ms separation. As you can see from the specifications on page 2, we have access to 100 kHz, 20 MHz and 80 MHz timebases. Try to use the Test Panels and start counting edges using the 80 and 20 MHz source for a while to see if it is counting as expected. E.g. if you count for 30 seconds the 20 MHz timebase, you will end up with 600 million edge counts.

    Test Panel Edge Count.PNG



  3. Can you try to use the MeasPulseWidth example and try to measure a 52 ms pulse width to see if this issue persists?

 

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 6 of 12
(7,666 Views)

Hello Yan,

 

I discussed your issue with Daniel. We believe this could be a possible RMA. Could you please do some further testing and see if only the signals near the range of 52 ms are the inaccurate ones. If so, then I would recommend calling to NI support and creating a service request for RMA. You will be transferred to one of our applications engineers for further troubleshooting and processing. It sounds as if the timebase parameter for this range is damaged.

 

Best Regards,

 

Alina M

0 Kudos
Message 7 of 12
(7,663 Views)

Hi Daniel and Alina,

 

I modified the program according to your example program as shown in attached program. However, I don't know which value to set for parameter values (Physical Channel,min and max value range, First Edge, Second Edge).

I also measured internal Time Base as you suggested. There is no edge source option for 100kHz to select. Below images are results for 80MHz and 20MHz when I run it for 10sec.

Timer Device 80 Mhz time base 29 Nov.JPG

Timer Device 20 Mhz time base 29 Nov.JPG 

 

Is there a way to generate signal of 52ms puls width because I don't have DC source with me to generate it.

Thank you.

 

Yan

 

 

 

0 Kudos
Message 8 of 12
(7,652 Views)

Hello Yan,

 

In my example, I used CTR3 as my Physical Channel, but you can use any counter you want, as long as it is not the counter you are generating your signal from. You can use the combo box default parameters for min and max range (1E-7 and 0.1, respectively). For the first and second edges you can select rising edge.

 

It seems as the 80 MHz and 20 MHz timebases are working fine, but I’m not that sure on the 100 KHz one, though. According to this KB, if you select a min and max value that are high enough, DAQmx selects different timebases. However, we can force DAQmx to use a specific timebase. Use the “MeasPulseWidth” example and insert the following line before your task starts.

 

myTask.CIChannels.All.CounterTimebaseSource = "/XSeries/100kHzTimebase";

 

 

Regarding the 52 ms generation pulse, use the GenDigPulse example (Programs » National Instruments » NI-DAQ » Text-Based Code Support » .Net4.0 Examples.

Regards,
Daniel REDS
RF Systems Engineer

Help us grow.
If a post solves your question, mark it as The Solution.
If a post helps, give Kudos to it.
0 Kudos
Message 9 of 12
(7,637 Views)

Hi,

I am trying to measure two edge separation between two square waves separated by 10 milli seconds. I am using external source connected to PFI 39.

 

myTask.CIChannels.All.CounterTimebaseSource = "/Dev1/PFI39";
myTask.CIChannels.All.CounterTimebaseRate = 60000000;

 

CIChannel cChannel = myTask.CIChannels.CreateTwoEdgeSeparationChannel(
counterComboBox.Text,"",
Convert.ToDouble(minimumTextBox.Text),
Convert.ToDouble(maximumTextBox.Text),
firstEdge, secondEdge, CITwoEdgeSeparationUnits.Seconds);

 

I am getting the following values when i use seconds to measure

 

12/13/2012 10:23:05 AM,3.3333833333333334 milli secs
12/13/2012 10:23:06 AM,3.3333833333333334 milli secs
12/13/2012 10:23:07 AM,3.3333833333333334 milli secs

 

I am getting the following values when i use ticks to measure

 

12/13/2012 10:23:37 AM,200001000

12/13/2012 10:23:38 AM,200002000 
12/13/2012 10:23:39 AM,200004000 
12/13/2012 10:23:40 AM,200002000 

 

Can you tell me the value should be around 10 ms, why i am getting 3.333xxx as the value?

My setup is simple i have two inputs connected to PFI 37 and 38 seperated by 10ms and external source connected to PFI 39? 

 

Thanks

0 Kudos
Message 10 of 12
(7,565 Views)