Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

6602 Concepts

Each counter has a Source, Out, Aux, and Gate. Now are these just names for things, or do they have actual functions "hardwired" to them.

For example: I would guess that if I get a counter to generate a 10 Hz signal and route that output to a second counter's gate, and then run the second counter at 100 Hz, I should only see 100 Hz pulses on the second counter when the first counter is active. This is not the case, as the DAQmx VB.net code below does not do this:

t = New Task("test")

DaqSystem.Local.ConnectTerminals("/Dev1/Ctr7InternalOutput", "/Dev1/Ctr4Gate")
t.COChannels.CreatePulseChannelFrequency("Dev1/ctr7", "Internal", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, 10, 0.5)
t.COChannels.CreatePulseChannelFrequency("Dev1/ctr4", "External", COPulseFrequencyUnits.Hertz, COPulseIdleState.Low, 0, 100, 0.5)
t.Timing.ConfigureImplicit(SampleQuantityMode.ContinuousSamples)
t.Start()

In other words, since I'm routing the output of counter 7 to the gate of counter 4, I would expect counter 7's 10Hz signal to "gate" the 100 Hz pulses of counter 4, but all this does is generate a continuous 100Hz train out of counter 4.

I believe the proper way to do such a thing is to use a retriggerable counter, the details of which I don't want to include, because the question is: are "Source", "Out", "Aux", and "Gate" just names or do they correspond to actual purposes/signal types?
0 Kudos
Message 1 of 7
(9,062 Views)

The names "Source", "Gate", "Aux", "Out" do refer to specific signal types.  The way these signal types map to actual connector pins is hardware-dependent, though there is a specific default pin that will be used if nothing else is specified.  Certain counting modes (position encoder mode) will require physical wiring connections to default pins.  Other modes will allow more flexible signal routing.

Yes, it is possible to "gate" the output of one counter with the output of another. 

As a LV guy, I can't comment on the VB.net syntax.  But in addition to configuring the signal routing, one must also configure the counter in question to "pay attention to" the gate signal.  Under LV and DAQmx, this would be known as "Pause Triggering."  Without setting up "Pause Triggering", the counter treats the signal at its gate as irrelevant.  You can think of a Pause Trigger as a level-based Enable signal.

A "retriggerable" counter would use its gate signal differently.  It would be edge-sensitive and wouldn't respond to a constant-high signal.

Sometimes it's not clear how to map DAQmx terminology down to the underlying counter hardware.  Under traditional NI-DAQ, you basically were forced to understand how the counter hardware worked with "Source", "Gate", etc. signals.  DAQmx largely removed that requirement.  As a result, most simple operations and many intermediate ones are easier to setup, but other less common tasks can be a bit confusing.  I've had trouble finding the correct property to set when trying to do period measurement with an external clock.

At the hw level, the Source increments the count register.  The Gate is a control input, either a level-based Enable, an edge-based sampling clock, or an edge-based trigger.  Aux is typically only used for position measurement.  Out seems self-explanatory, though there are various non-default output modes that can prove handy at times.

Under DAQmx, the Source is defined differently for different counting modes.  For edge counting, you wire in a signal identifier.  For period measurement or pulse generation, it wants to use an internal clock.  Similar for Gate.  Sometimes you set it up as a pause trigger, sometimes as a sampling clock, sometimes as a digital start trigger.

Hope this helps some.  Have fun with the 6602, it's a pretty nice piece of hw!

-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.
Message 2 of 7
(9,053 Views)
Thank you for your explanation. It is exactly what I needed to know.

I am having many issues with DAQmx in .NET. The documentation is bad in that it's like trying to learn a language by reading a dictionary; the examples are rudimentary and microsoft's help file's search feature really doesn't help when it returns 90% useless hits. Also, the documentation doesn't actually say what the functions do, so I run into a lot of trouble when I try to "pre-setup" for a function call not knowing that the function will also try to do that and then I get "route already exists" kind of messages. I'm frustrated with the trial and error method I'm having to retort to because it feels like to write one line of my program I have to look in three help files: one for the function call, another for which channel is which PFI, and another one to find out what the words they are using mean. It's just a tough learning curve, I guess, because I know what I want to do but I don't know "what it's called".

I did not program in the old DAQ; though I'm trying to rewrite a program from scratch to replace one that was written as such. But the old program used 6 counters with one acting as the "master" by physically wiring the out of this master to the gate of all the others and I really don't want to do that - I am trying to write a program that is more flexible.

Thanks again for your help.
0 Kudos
Message 3 of 7
(9,051 Views)

One of the nice things about DAQmx is the ease of flexible signal routing.  If I'm guessing right about the example you mentioned, here's how I'd setup the counters in LV and DAQmx.  I would expect that it'd be done in a similar manner but with different syntax with VB.net:

1. Configure the master counter for pulsetrain generation but don't start it yet.

2. Query the master counter's task for the "output terminal" property.

3. When configuring the other 6 counters, pass this "output terminal" into their DAQmx Timing calls where it's known as the "Sample Clock source" (or something similar).

4. Start the 6 counters.  Their count registers may start incrementing if they are receiving Source pulses, but no count values are being buffered yet.

5. Start the master counter.  This acts as the sampling clock.  The 6 counters start buffering data.

6. Note that the very first value in the 6 counters' buffers represent # of Sources from when they started until the first sample clock edge.  Since the counters weren't sync'ed to start on a digital trigger, their start times were offset by some software execution time and they are NOT perfectly in sync.  However, you can subtract these initial values off every buffered value to get a "change since first sample clock" measurement that will be in sync for all 6.

-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 7
(9,048 Views)

I agree Pelesi ; it is hard to go through NI documentation for dotNet (and I use NI products for over 14years now) !!!

 

I stilll haven't found how to generate a finite pulse train on a PCI-6601 .....

I guess that I will have to use 2 counters: one as continuous pulse generation of my target frequency ; and a second timer that will gate the first one, and that will pulse only once at a much slower frequency than the 1st one.....

0 Kudos
Message 5 of 7
(7,040 Views)

Holy moly. 4 years later someone is still complaining.

 

Anyway, I may as well upload the code I ended up with. It's not the best UI, and not the best software in general, but it allows some pretty flexible use of a 6602. Maybe it will help someone.

 

It's a VS2005 VB.Net project.

 

Please keep in mind:

1. I can't run this software right now (don't have a 6602)

2. I haven't run it since 2007

3. I can provide very limited assistance, if any. And no, the comments are probably not very good.

4. The program was designed for timing two lasers to synchronize it with a camera. It was also designed so both the lasers and camera could be synchronized to an external pulse. My forum posts here were from when I was writing this thing.

 

I hope it helps!

Message 6 of 7
(7,027 Views)

Hello Pelesi,

 

Sorry to have taken such a long time to answer you. I am not using the forum often.

 

Let me just tell you that I am IMPRESSED by your code. I think that NI should provide it as a VB.NET sample code for the 66xx family.

There is everything required to create IO task. It is much better than the documentation.

 

Now I will have to find my answer in your code; such as : why the dividing value can only be a even number ???

 

 

Thans you very much for this beautifull code.

 

Anthony

0 Kudos
Message 7 of 7
(6,596 Views)