Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Change timebase on Counter Source

Hi,

 

I'm using the NI-6221DAQmx board for testing a motor control board. I use both counters, one for controlling the motor and one for measuring the frequency of a feedback signal.

Frequencys I'm measuring are between 50 and 300 Hz. The feedback line with the signal is connected to counter 0 gate.

 

This is working very fine up to a frequency of about 250 Hz. Then I receive some strange sample values. 5 samples OK, 1 exactly at 4000 (ticks), then 20 samples OK and one bad.

So, I wanted to change the timebase on the counter source from 80MHz to a lower frequency. But if I do this by routing the signal of the timebase to PFI8 my read function results a timeout.

I can't find an examplecode for VB6 for changing the counter source, but the user manual of the card tells that this is possible.

 

Does anybody know the problem of the bad samples, or can tell me the correct coding for changing the counter source?

 

earny

0 Kudos
Message 1 of 4
(7,582 Views)

Hi, 

 

basically you can let DAQmx select an appropriate Counter Timebase for your configured Frequency-Range.

I don´t have the VB-Example at my fingertips, but it´s simple to configure the task, so I show you in LabVIEW.

DAQmx also does configure the Timebase automatically in buffered mode.

 

Low frequency 1 ctr mode should be ok for your frequency range.

 

CTR_FREQ.jpg

 

 

Marco Brauner NIG

0 Kudos
Message 2 of 4
(7,573 Views)

Hi earny,

 

Counting the 80 MHz timebase takes about 53.69 seconds to roll over--the rollover is the usual reason to want to use a lower frequency timebase and doesn't really apply to your situation.  I don't believe that the timebase is the cause of your problem.  However, to answer your question, you may set the counter timebase with a DAQmx Property.  In VB.NET you use CounterTimebaseSource in the CIChannel class.

 

What I think is more likely happening is that you are seeing a small amount of noise or glitching on your line, which is resulting in the card reading duplicate edges on some transitions.  This would manifest itself as reading in an occasional high frequency (e.g. 4000 ticks of the 80 MHz timebase is a 50 microsecond period). 

 

I suggest to try using digital filtering (see M Series User Manual).  With digital filtering enabled, the counter would only register pulses larger than {125 ns, 6.425 us, or 2.56 ms).  If your max frequency is only 300 Hz, you should be able to safely set the 2.56 ms digital filter, which is guaranteed to pass through any signal up to ~390 Hz.  Any high frequency glitches that occur during the transition of your signal would be filtered out.

 

To enable digital filtering and set the minimum pulse width, use the CIChannel.FrequencyDigitalFilterEnable and CIChannel.FrequencyDigitalFilterMinimumPulseWidth properties.

 


I hope this helps, let me know how it goes!

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 4
(7,560 Views)

Hi,

 

I acuallay solved my problem. My mistake was, that I tried to route the desired timebase directly to the source of the counter, but the dll just excepts the name of the counter (/dev1/ctr0"). So I could use the other timebase, but the faulty measurements were still there. After I used digitil filtering with 6.425 us minimum pulsewidth everything worked fine.

 

Thanks for your replys!

earny

0 Kudos
Message 4 of 4
(7,537 Views)