Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Question on counter pile up

Solved!
Go to solution

I wish to detect the counter output for fixed sampling at a specified sampling rate. The following code works, but I found that the output array is a pile up of the previous counts. I have therefore get the actual counts for each sampling, by subtracting sequential values. Is there a way to get the value directly without piling up? Because the piling up can easily saturate the counter buffer, and it doesn't have any advantage. Any input is highly welcomed. Thank you!

 

question-counter-pile-up.jpg

0 Kudos
Message 1 of 8
(6,581 Views)

Hi xipeng,

 

It sounds like you want to count the amount of pulses that occur between each edge of the sample clock (as opposed to counting the total number of pulses that have occurred).  You can achieve this by configuring a period measurement--the period of your sample clock will be measured in terms of ticks of your external "timebase".

 

Just replace the configuration of your edge count task with the following:

 

CI Period.png

 

 

Best Regards,

John Passiak
Message 2 of 8
(6,574 Views)

Dear John,

    Thank you for your advice. I have tried but it doesn't work actually as we expected... Below is the error message. I also attached my labview code -- can you help me to see what's wrong? Thank you!

    My hardware is a USB6259.

----------------

Error -200077 occurred at Property Node DAQmx Channel (arg 6) in DAQmx Create Channel (CI-Period).vi:1->test_counter_clock2.vi

Possible reason(s):

Requested value is not a supported value for this property.

Property: CI.Period.MeasMeth
You Have Requested: Rising
You Can Select: Low Frequency with 1 Counter, High Frequency with 2 Counters, Large Range with 2 Counters

Channel Name: Dev1/ctr0

Task Name: _unnamedTask<14>

 

 

-----------------------

errormessage2.JPG

Peng

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

Hi xipeng,

 

The controls you have wired to the Create Channel no longer line up with what is expected.  Edge is wired to Measurement Method, Count Direction is Wired to Minimum Value, and Initial Count is wired to Maximum Value.  On the Period task you don't have access to Count Direction or Initial Count, but you can use the "starting edge" terminal if you want to sample on falling edges.

 

2011-05-13_094644.png

 

Best Regards,

John Passiak
Message 4 of 8
(6,557 Views)

Dear John,

     Thank you for your help. I tried but ther are still errors: when I connect the 100KHz to the "Period property node-CI-Period-term", it outputs 800 counts, which indicated that the system clock is 80MHz. But when I try to connect my signal which is on PFI12, the following error message pops:

Error -200284 occurred at test_counter_clock3.vi

 

Possible reason(s):

Some or all of the samples requested have not yet been acquired.

To wait for the samples to become available use a longer read timeout or read later in your program. To make the samples available sooner, increase the sample rate. If your task uses a start trigger,  make sure that your start trigger is configured correctly. It is also possible that you configured the task for external timing, and no clock was supplied. If this is the case, supply an external clock.

Property: RelativeTo
Corresponding Value: Current Read Position
Property: Offset
Corresponding Value: 0

Task Name: _unnamedTask<32>

 

    Could you please help me to see why this happens? Thank you!

errormessage3.jpg

Peng

0 Kudos
Message 5 of 8
(6,543 Views)

Hi xipeng,

 

The idea was to use a known clock source (generated by either a counter or by freq out) as the CI Period term.  The external signal should be used as the "timebase", not as the input to CI Period Term.

 

It appears you have taken away the timebase input and taken away the task that is supposed to generate the sample clock.  You may use the 100 kHz timebase as the **bleep**, but this is probably faster than you need (remember, the external "timebase" signal must be faster than the CI Period term).  Routing the 100 kHz timebase to the counter gate requires the use of the other counter anyway, so you might as well configure a counter output task that is more in line with the frequency you needed.

 

All you need to do is go back to the original code and make the changes I suggested.  I'm not sure why you took away the counter output task.  The code you posted earlier is correct, but you need to change the inputs to the create channel VI since the inputs to a period task are different from the inputs to an edge count task.

 

 

Best Regards,

John Passiak
Message 6 of 8
(6,532 Views)

Dear John,

    Actually I tried but it won't work, and generate a pulse generation related error. So I modified the original program. It is ideal if the trigger generation-period counting method can work.

     Here is the code I tried as you recommended. The erroe -200284 pops up again. I tried using different timebase but that won't work either. I also tried using one counter or 2 counters, but they won't solve the problem.

     If you can, please help us to run the code on your side and see why it won't work as we planned. Thank you!

Peng

errormessage4.jpg

0 Kudos
Message 7 of 8
(6,521 Views)
Solution
Accepted by topic author xipeng

Hi xipeng,

 

The "Frequency" input of your CO Pulse Freq task is not wired.  It is defaulting to a low frequency and thus the clock is not producing enough samples quickly enough.

 

 

Best Regards,

John Passiak
Message 8 of 8
(6,498 Views)