Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

reset counter - 6601

Solved!
Go to solution

Hi,

I am using a 6601 board and the C++ interface.

My setup:

I am trying to continuously count pulses, where I am using a sample clock to get samples every time the sample clock transitions from low to high.

My problem:

I would like to reset the counter every time the sample clock does the low to high transition, such that I avoid all overhead (checking for the sample count and subtracting current from previous).

 

I would be very greatful for some advice on this matter.

 

cheers

Rolf N.

0 Kudos
Message 1 of 6
(5,253 Views)

Hi Rolf,

 

It is unclear to me what exactly you're trying to do here. In your setup description it sounds like you are trying to count pulses using a sample clock, but in the problem description it sounds like you are using that sample clock signal to reset the counter at each edge of this signal. Is this "sample clock" an external signal or are you using an internal clock?

 

What I think you might be describing here is that you are using an external pulse signal, to reset your counter on it's rising edges. This counter is continuously counting using a different sample clock, not the external signal that you are providing.

 

You can perform this type of count using an external signal to reset the counter or use another onboard counter to generate the signal you want to use to reset your counter.

A good way to do this sort of thing is to use an encoder task that is set to two pulse encoder. In this way all you would need to do is to feed your input signal to the source of that counter (PFI 39 for ctr 0), and feed the reset signal (Z index) into the counter gate (ctr 0 – PFI 38). Also, you would need to set the Z index to be A Low B Low and wire the AUX (ctr 0 – PFI 37) line of the counter to ground.

 

You can also use another counter on the board to generate the "reset" signal that you will be feeding into the gate of the encoder counter.

 

There is an explanation of this type of two pulse encoder in the User Manual.

The ANSI C shipping example “MeasAngularPositionBufferedCont_ExtClk” is a good starting point that only needs these slight modifications.

There is also a good example program of a similar situation using Visual Basic on our Developer Zone site. Here is the link. I hope this gets you started.

 

Chris N White

High Speed Products Group

Message Edited by Chris W. on 10-31-2008 12:30 PM
0 Kudos
Message 2 of 6
(5,235 Views)

Hi Chris,

thanks for your advice, much appreciated. I can see now I should have been a bit more explicit, still your assessment is spot on.

To recap:

I have a 5khz time base (I generate with a counter) and an external heartbeat signal. I need to continously count pulses from the time base over the period of the heart beat. At the begin of each heartbeat period I want to reset my counter and immediately start counting again (beginning from zero).

I think your encoder scheme would fit the bill. The only problem is my heart beat signal is normally high and pulses low at the end of its period. From what I can see in the manual, the z-index input must be high when both A and B inputs are low (in my case anyway). Is there any way I can reset as desired without putting some extra inverting hardware into the heartbeat signal path?

 

thanks again

Rolf

0 Kudos
Message 3 of 6
(5,217 Views)
Solution
Accepted by rjnn

Would it be sufficient to simply define a buffered period measurement task?  You could designate the 5 kHz clock as your timebase and the heartbeat as the signal whose period is to be measured.  Then you can define which edge of the heartbeat signal you care to respond to, and the hardware would take care of resetting the count internally on each new heartbeat signal edge.  For simpler interpretation of the result, read the count value in U32 form and/or set Units="Ticks" in the task configuration.

 

-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 4 of 6
(5,209 Views)

Hi Rolf,

 

That does present a bit of an issue having a normally high z index signal. You can do it using some external hardware, but it may be easier just to perform the period measurement that Kevin suggested above. It's great that he suggested this option because that was going to be my next suggestion as well. Thanks Kevin!! The buffered period measurement is certainly a good way to go.

 

Here is a link to an example that does exactly this.

 

http://zone.ni.com/devzone/cda/epd/p/id/5905

 

Chris N White

High Speed Products Group

0 Kudos
Message 5 of 6
(5,200 Views)

Hi Chris, Kevin,

thanks a stack. I'll go with the period measurement. 

 

Your help has been much appreciated

 

cheers

Rolf

0 Kudos
Message 6 of 6
(5,194 Views)