Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

USB-6343 Counter sample clock

Solved!
Go to solution

I am using CTR0 of a USB-6343 to measure angular position. I expect ~1million encoder pulses (or counts) per second. Which USB-6343 clock signal would be best to use as the counter sample clock?

0 Kudos
Message 1 of 9
(7,624 Views)

Hey Dar Bahatt,

 

I could use a little more information about your system.  Are you using a DAQmx task in LabVIEW?  The clock should be taken care of as long as you select the one that has is faster than your samples.

 

 

Regards,
Jake G.
National Instruments
Applications Engineer
0 Kudos
Message 2 of 9
(7,600 Views)

You have several options for a clock signal.  My preferred method would be to use one of the other counters (there are 4 counters on the 6343) to generate the clock signal with a Counter Output task.  If you need to use all 4 counters for making measurements, then you can instead use the "freqout" signal.  It's programmed just like a counter, but it doesn't have as many features and can only support a few specific frequencies.

 

Alternatively, you may configure a dummy analog or digital I/O task and use that clock for your counter.  If you go with this option, using the 6343 your rates will be limited to 1 MHz for DIO, ~900 kHz for AO, and ~500 kHz for AI.

 

Any of the internal clocks would be equally accurate since they are all derived from the same 100 MHz 50 ppm oscillator.

 

 

You can also import an external sample clock over any of the PFI lines if desired.  For the full list of signals that may be routed to the counter sample clock, you can refer to the Device Routes tab in MAX.

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 9
(7,582 Views)

Hi John-

 

Attached please find my Angle Measurement VI (LV 8.5). Also attached are 2 screen shots of the USB-6343 direct

CTR0 sample clock routes I got from MAX.

 

A few questions:

 

1) According to MAX the /Dev1/100KHzTimebase cannot be routed to CTR0 sample clock, but my code does not

generate an error when I use this Timebase. Why?

 

2) According to MAX the /Dev1/100MHzTimebase cannot be routed to CTR0 sample clock, but my code does not

generate an error when I use this Timebase. Why?

What I get is the following error message: Error -201314 occurred at DAQmx Read (Counter 1D DBL 1Chan NSamp).vi

Multiple Sample Clock pulses were detected within one period of the input signal. Use a Sample Clock rate that is slower than the input signal. If you are using an external Sample Clock, ensure that clock signal is within the jitter and voltage level specifications and without glitches.

 

3) According to MAX the /Dev1/20MHzTimebase cannot be routed to CTR0 sample clock, but my code does not

generate an error when I use this Timebase. Why?

What I get is the following error message: Error -200361 occurred at DAQmx Read (Counter 1D DBL 1Chan NSamp).vi

Onboard device memory overflow. Because of system and/or bus-bandwidth limitations, the driver could not read data from the device fast enough to keep up with the device throughput. Reduce the sample rate, or reduce the number of programs your computer is executing concurrently. 

 

3) When I use the /Dev1/10MHzRefClock I get the following error message: Error -200361 occurred at DAQmx Read (Counter 1D DBL 1Chan NSamp).vi  Onboard device memory overflow. Because of system and/or bus-bandwidth limitations, the driver could not read data from the device fast enough to keep up with the device throughput. Reduce the sample rate, or reduce the number of programs your computer is executing concurrently.

 

Your help is appreciated!

 

Dar Bahatt

 

 

0 Kudos
Message 4 of 9
(7,562 Views)

Hi Dar,

 

The inconsistency that you see in the routing table is a side-effect (bug?) of how the table is generated.  There is no direct route from the timebases to the counter sample clock, but you may use a 2nd counter to route the timebase.  When the routing table is generated, it picks one of the counters to use to route the timebase to the other 3.  In your case, counter 0 was chosen and so the routing table does not indicate that counter 0 can accept the timebase as a sample clock.  In reality, when you try to configure it in software, the driver will pick an available counter to route the timebase through so it still works (it just uses one of the other counters).

 

 

Now, as far as the results you are seeing:

 

1)  The 100 kHz timebase should be acceptable, but keep in mind that you are really using one of the other counters to route it to the timebase source.  You could get the same 100 kHz clock by using Freq Out without having to use an entire counter.

 

2)  100 MHz is too fast to be used as a sample clock for the counter.  The counter itself is reporting a hardware error in this case.

 

3)  The counter is capable of sampling at 20 MHz, but you can't pull the data off of the device quickly enough to keep up with the clock.  Each sample of the counter is 32-bits (4 Bytes), so 20 MHz would be 80 MB/s of data.  This is above the theoretical maximum of USB 2.0 which is 60 MB/s.

 

4)  The 10 MHz clock is also generating too much data to be sent over the bus.  While 40 MB/s is under the theoretical limit of USB, the highest observed throughput on Windows with USB 2.0 is in the low 30 MB/s range due to packet overhead and latency.

 

 

Anyway, I wouldn't think that you need to sample your count register this quickly.  The register increments from your external signal independently of the sample clock, you just use the sample clock to sample the value of the register.  Contrary to the first response you received, the clock should not be faster than the input signal--it is typically much slower.  If you do want a hardware-timed sample clock, I still stand by my original suggestion to either use freqout or a 2nd Counter (although of course there are other options).

 

 

Best Regards,

John Passiak
0 Kudos
Message 5 of 9
(7,536 Views)

Hi John-

 

Thank you. Your detailed response makes things very clear now.

 

My goal is to study the rotation of a motor (10,000rpm max). In an ideal system the change in angle should be constant if measured at identical

time intervals. The DAQ system has to measure angle at sufficient resolution.

 

I see two ways of achieving this goal with my USB-6343:

 

1) Set the counter to encoder mode; Read the counter register (expressed in degrees) at constant time intervals determined by the sample

     clock; The sample clock should be fast enough to measure angle at sufficient resolution; Compare the actual angle change to the theoretical

     value. This is the option we discussed.

 

2) Set the counter to pulse width or frequency measurement mode; In this case the time between encoder pulses is reported by counter clock ticks.

 

From your experience and knowledge of the USB-6343, is there any performance difference between these two methods? Will one of them sample angles

at much better accuracy (clock variation, clock rate, etc...)? Is there any better method you can suggest?  

 

Best,

Dar Bahatt

 

0 Kudos
Message 6 of 9
(7,528 Views)
Solution
Accepted by topic author Dar_Bahatt

Hi Dar,

 

At what resolution do you need to measure the angle?

 

A colleague of mine has benchmarked the maximum sample rate on USB X Series counters to be about 8 MHz for a single channel, running continuously for 10 minutes.  However, if the signal you're counting is only generating pulses at 1 MHz, the 8 MHz rate seems unnecessary as you would receive the same reading multiple times.

 

 

Regarding the two methods you mentioned, either would be possible:

 

1)  You could count the external signal and sample it at regular intervals.  For example, if sampling at 10 kHz you would expect to see ~100 counts per sample clock if your signal is 1 MHz.

 

2)  You could also use the counter to count an internal timebase (e.g. 100 MHz) and sample it off of your external signal.  So, during one period of your external signal you would expect to see 100 ticks of the timebase.

 

 

It sounds like what you're trying to do is measure the frequency of your encoder at regular intervals.  For this, I'd actually suggest a 3rd option.  X Series cards support a Sample Clocked Frequency Measurement (see X Series User Manual).  The card counts both the occurrences of the external signal as well as occurrences of the known internal timebase and uses this to determine frequency.  The one caveat is that the signal you are measuring from the encoder has to be at least twice as fast as the sample clock signal.  I'd suggest using either Freq Out or another Counter to generate the sample clock.

 

 

Best Regards,

John Passiak
0 Kudos
Message 7 of 9
(7,469 Views)

Hi John-

 

Thanks for your response. Again very helpful.

 

As you suggested I am using a sample clocked buffered acquisition of angular position.

The sample clock is a 50% duty cycle pulse train generated by a second counter on

my USB-6343.

 

My code requires the detection of an angle reset (to zero) by the encoder index pulse.

I am un-successful detecting a 0 degree angle. This led me to the following question:

 

Does the quadrature encoder counter write the angular position to the buffer only when a

sample clock pulse is detected or does it report the angular position every time the A and

B signals change regardless of the sample clock?

 

In the first case if the sample clock did not sample when the angle was reset that will explain

my observation. In the second case I should be able to detect an exactly zero angle value.

 

Best,

Dar Bahatt 

0 Kudos
Message 8 of 9
(7,445 Views)

Hi Dar, 

 

Your first case is correct.  The angular position is only written when the sample clock pulse is detected.

 

Allie

0 Kudos
Message 9 of 9
(7,429 Views)