Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

period measurement .NET

Hi
 
  I have a counter 7 output which generates the continous pulsetrain sample (10KHZ)connected to the gate of counter 5. Another counter 6 output which generates the continuous pulse train (30KHZ)is connected to the input of counter 5.
 
  First step works out and generates continous pulse using CreatePulseChannelFrequency
 
 From the counter 5 I have to count the edges from the source taking into account  the gate signal. I need the non -cumulative counts for the edges of the source for a period of the gate signal.
 
 I'm using 6602 DAQMx . I'm not familiar with labview. I'm using .NET C#. The documentation is not sufficient.  There are no proper explanations in the help for .NET for DAQMX.
 
 I'm confused with Period measurement hardware. I will not be able to use the gate in that case.
 
 Can anyone guide me through the 3rd step.
 
Thanks
Murugan
0 Kudos
Message 1 of 53
(5,508 Views)
Murugan,

Thanks for contacting National Instruments.  

In general, period measurement is done by applying a signal with a known frequency to the source and your unknown signal to the gate of your counter.  Your source singal must a frequency much higher then the gate.  The period of the gate signal is then calculated by multiplying the count and the source period. 

If you are able to create a digital pulse train signal with a known frequency on one of your counters and connect that to the source of another counter you should then be able to do a period measurement of your unknown signal.  From what you have described I think you have done all this.  Even though you know the frequency of your 10kHz signal, so I imagine you are just testing it first.

As far as .NET goes I have attached some shipping examples that come with Measurement studio.  You should be able to determine from this code what is going on.  Thanks again.

Regards,

Message Edited by Kenn N on 09-20-2006 03:48 PM

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 2 of 53
(5,489 Views)

Hi Kenn

  Thank you very much for your reply . I have seen this example. But it doesnt clarify the questions I have.

  My objective is to count the edges of the source (later will be an APD) taking the gate into account. But the counts should not be cumulative. I want to do the edge counting of the source taking both the high and the low frequency of the gate and buffer the edge counts of the source at every rising edge of the gate (Pause trigger will not work because I need to count the edges at both the rising edge and falling edge fo the gate ).

  Should I have to use the period measurement in this scenario ?

  In my Example the Counter6 which generates the continuous pulse (stimulates the APD) which is connected to the Counter 5's input (30 KHZ).  For testing purpose I'm using another counter 7 (10 KHZ) which generates continuous pulse output connected to the gate of Counter 5 .

 In this case if I use the period measurement what will be my measurement time?.I'm not clear with the following statement in your reply

" The period of the gate signal is then calculated by multiplying the count and the source period. ".

How will I know the count because thats what I want to find . What will be the source period ? .I think I'm missing something.

Can you please clarify.

 Thank you

Murugan

  

0 Kudos
Message 3 of 53
(5,482 Views)
Murugan,

" The period of the gate signal is then calculated by multiplying the count and the source period. " 

This is how the period measurement is calculated.  For period measurement there is a count taken of the number of times the source sees a rising edge.  This count is used to determine the period of the gate signal.  To determine the count divide the gate period by the source period.  Normally the source signal is the internal 20MHz clock.

Regards,
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 4 of 53
(5,466 Views)

Hi Kenn

 Thanks for your explanation.

 I have a unknown source(I dont know the count or the source period). The gate is a known signal of 10KHZ. I need the non cumulative count of the edges in the source with reference to the gate.

Question 1 :Should I make use of the period measurement in this case ?

Question 2: If period measurement is the mode I have to go for what will be the measurement time parameter in the create period measurement in the above scenario? Is it 1/10KHZ ?

 Can you please answer these questions?

Thank you

Mullai JK

 

0 Kudos
Message 5 of 53
(5,463 Views)


 I have a unknown source(I dont know the count or the source period). The gate is a known signal of 10KHZ. I need the non cumulative count of the edges in the source with reference to the gate.

Question 1 :Should I make use of the period measurement in this case ?

Question 2: If period measurement is the mode I have to go for what will be the measurement time parameter in the create period measurement in the above scenario? Is it 1/10KHZ ?


Answer 1: Yes, to measure non-cumulative counts per sampling interval, period measurement is the correct choice.  The "gate signal" can be thought of as a "sampling clock".  What's being sampled is the value in the count register.  That value increases with every input "source" edge.  In period measurement mode, the counter hardware resets that count back to 0 on every "gate" edge.

Answer 2: Dunno the syntax for your programming environment -- I only know LabVIEW.  But the calculation would be (1/10 kHz) / (counts per interval).

Answer 3: Based on your 30 kHz source signal example, you may end up with a lot of quantization error.  If your source signal is nominally, say, 5 times the freq of your gate signal, you could reasonably expect to see period values of 4,5, and 6.  These in turn will suggest periods of 25, 20, and 16.667 microseconds, a fairly large quantization effect percentage-wise.  Just an FYI.

Answer 4: If your external Source signal may occasionally drop to a frequency lower than the Gate signal, you may also need to look into setting up "Duplicate Count Prevention."  It's a topic that has come up quite a bit here so you should be able to get a bunch of search hits.

-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 6 of 53
(5,452 Views)
Mullai JK,

Thanks again for replying.
You can certainly make use of the period measurement.  You can use a 2-counter High frequency period measurement.  The first counter's output will be a pulse of known period (your 10kHz). The second counter is configured for period measurement, the signal to be measured is connected to the source of this counter. The gate of the second counter is internally connected to the output of the first counter. Since we know the period of the pulse generated by the first counter, and we can measure how many edges of the unknown signal occurred during that time, we can calculate the frequency of the unknown signal.  This count is used internally, but by dividing the resulting frequency or period from our known signal period we can get the count.

Ok so there are 2 ways to do a period measurement.  You can use 1 counter a or two.  The two counter method is used for higher frequencies above the internal timebase.

Using 1 counter you connect signals like so:
Source - Known frequency signal (internal timebase 20MHz is used, unless specified in a property node)
Gate - unknown signal, but slower then the source
Output - nothing

Using 2 counters
Ctr1 source - unknown signal with high frequency (higher than the internal 20MHz)
Ctr1 gate - nothing
Ctr1 output - pulse train and at frequency lower than the source to be used a reference and internally connected to the ctr2 gate

Ctr2 sourece - Known frequency signal (internal timebase 20MHz is used, unless specified in a property node)
Ctr2 gate - internal output of Ctr1
Ctr2 output - nothing

You need to fit your signals to one of these scenarios to work right.  Then once you are accurately getting a period output you can divide to get the count.

Hope this helps.

Regards,

Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 7 of 53
(5,452 Views)

Hi Kenn and Kevin

 Thanks for your explanation. It worked with 2 counters.

 One thing that bothers me is  even if I ignore the gate signal but specify the measurement time (i.e) 1/Gate frequency alone in my period measurement function it counts the number of edges in the unknown source based on the measurement time given. But I still use 2- counter high frquency measurement.  Is this another way of doing it ?

One Counter:

  Source: Unknown frequency .

  Gate : nothing

task.CIChannels.CreatePeriodChannel("/Dev1/Cntr1,

"BufferedEventCounting" , .000000025, 53.6, CIPeriodStartingEdge.Rising, CIPeriodMeasurementMethod.HighFrequencyTwoCounter, .0002, 4, CIPeriodUnits.Ticks);

where .0002 is the measurement time which is 1/Gate frequency.

Thanks

Murugan.

0 Kudos
Message 8 of 53
(5,433 Views)
Murugan,

There isn't another way, because you need the second counter to accomodate the higher frequencies. 

Regards
Kenn North
Principal Product Manager - Search, Digital Analytics
http://ni.com/search
0 Kudos
Message 9 of 53
(5,416 Views)
Hi
 
  Thanks for the reply.
 
  I have another question. How will I internally connect a counters output to multiple counters gate ?
 
 

    DaqSystem

.Local.ConnectTerminals( "/Dev1/Ctr5Gate","/Dev1/PFI8");

  to connect Counter 5's gate to Counter 7 output. Is this correct ?

I also wanted to internally connect the counter 7 output to another counters gate.

 What is the syntax for it? If I do the connect terminal it says the resource is reserved.

I couldnt find enough information in the .NET C# help. The help doesnt give the  picture of what can be done. It just gives the bits and pieces we have to do a serach and fill the rest.

 What does the yellow boxes in the device routes specify ?

Thanks

Murugan

0 Kudos
Message 10 of 53
(5,402 Views)