LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

counter/timer high resolution

Dear all

 I have developed a counter-timer program by using NI PCI-6601 card and LabVIEW 7.1 on P-IV with Windows XP.

It gives satisfactory results when I apply i.e.

 

                                                              Input 100000 Hz at 1 sec high Time and 1.00E-7 sec low time  which gives output 100000 counts,

                                                              Input 100000 Hz at 0.5 sec high Time and 1.00E-7 sec low time  which gives output 50000 counts and

                                                              Input 100000 Hz at 0.2 sec high Time and 1.00E-7 sec low time  which gives output 20000 counts

 

 But when I goes to achieve high resolution it gives incorrect data i.e.

                                                              

                                          Input 100000 Hz at 0.1sec high Time and 1.00E-7 sec low time  which gives output 20000/10000 counts, and below this value it also gives wrong output data.

                                                     I want to achieve .001 sec high time.

                                                     Please help me to solve this problem.

 

Best Wishes

 

Ishfaq

                                           

0 Kudos
Message 1 of 6
(3,575 Views)
Hello Ishfaq,

Welcome to the NI forums!  I am slightly confused as to what you are trying to accomplish with your application.  It appears that you are inputting a 100kHz signal to your counter's source and then using a pause trigger with another signal that you are changing the high time of (1s, 0.5s, 0.2s, etc).  What is confusing to me is if this is what you are doing why are you only going low for 100ns?  This would generate a pause trigger signal that has a very high duty cycle (pausing for a very short period of time).  I am unsure how you would be able to tell your count after just one of these high times.  It would be easier to tell what count you are achieveing with one pulse.

The other option I can think of that you could be using would be buffered counting.  This would allow you to poll your counters value on every rising edge of your signal.  If this is the case, then a 50% duty cycle would do exactly the same thing (with changing frequency) because the rising edges would be in the same place.  This would allow you to know the count after each period.

Either way, the signal you are inputting is not beyond the specifications of the counters.  What you may be seeing is that you are somehow getting 2 periods of your signal sometimes (2x10000=20000).  For troubleshooting, I would strongly recommend using the example programs titled Count Digital Events - Pause Trig.vi and Count Digital Events - Continuous - Ext Clk.vi (located in the example finder in the help menu under Hardware Input and Output»DAQmx»Counter Measurements»Count Digital Events).

If you would please post back with a little more detail about your setup and your end goal,  I can try to go into more depth and give more troubleshooting ideas.  I hope this helps you out,  please post back if my explanation was unclear.

Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 2 of 6
(3,528 Views)
Hello Neal M,
 
Thanks for reply and sparing time for me. I am using counter-0 for reading and counter-2 for pulse output.
I want to achieve the following readings/counts at respective inputs which are following:
 
 Input 100000 Hz at 0.1sec high Time and 1.00E-7 sec low time  then the output should be 10000 counts,
 Input 100000 Hz at 0.01sec high Time and 1.00E-7 sec low time  then the output should be 1000 counts and 
 Input 100000 Hz at 0.001sec high Time and 1.00E-7 sec low time  then the output should be 100 counts.
 
I am also sending you "counter timer high resolution.vi" in attachment.
 
Thanks a lot again in helping me.
 
Ishfaq
0 Kudos
Message 3 of 6
(3,512 Views)

Hello again Ishfaq,

I believe what is going on is that you are using software timing to control when your counter is running. You are controlling the counting by how long it takes for the pulse generation code to run, not by when the pulse is high.  What I believe you want to do is actually pause triggering, which is done in hardware.  What this does is counts while a digital signal is high and then pauses the counter (i.e. freezes the count and prevents further counting) when the digital signal is low.

The example program titled Count Digital Events-Pause Trig.vi located in the example finder that I reference in my first post does this(it is in the Help menu select Find Examples..., then look under Hardware Input and Output»DAQmx»Counter Measurements»Count Digital Events).  To generate your pulse,  take a look at the example titled Gen Dig Pulse.vi (located in the example finder under Hardware Input and Output»DAQmx»Counter Measurements»Generating Digital Pulses).  You should be able to combine these two to accomplish your goal by specifying the counters InternalOutput (e.g. Dev1/Ctr0InternalOutput) for the pause trigger source.

Take a look at these examples and let me know if you have any more questions or if my explanation is not clear.



Message Edited by Neal M on 01-17-2008 05:50 PM
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 4 of 6
(3,489 Views)

Hello Neal M,

Thanks for comprehensive discussion of problem. I try to explain my problem. I want the counter should start counting when pulse is high. Actualy I want to control counter's counting through pulse not from directly software. In the example program titled Count Digital Events-Pause Trig.vi  there is a while loop around the DAQmx Read.vi having Wait Until Next ms Multiple which controls the counter instead of pulse. But I want to control the counter through pulse by generating that pulse through software with counter's counting software.

 

Please help me in this regard.

 

Message Edited by Ishfaq on 01-18-2008

 

 

Ishfaq

0 Kudos
Message 5 of 6
(3,470 Views)
Hello again Ishfaq,

I think there is some confusion as to how the hardware is being called.  At the rates that you want to go, you do not want to use software timing to control the counter.  We want to use hardware timing and buffers.  What this means is that the acquisition (including the pause trigger) is controlled in hardware with physical signals, and not in the program.  The loop does not control when the counter increments. Instead, the loop controlls when we read the value of the counter.

To do this, we need to tell the counter to look at the pulse and count when it is high (our pause trigger source).  We then need to start the counter task so it is waiting for the pause trigger to go high (to start counting) and stop counting when low again.  We then send it the pulse.  The DAQmx Read vi then asks the counter what its count is (it does not control when the counter is counting).  The way to accomplish this is by combining the examples I reference in my previous post, and would look something like this:



I have circled the only changes I have made other than error routing. I believe this is what you want to do.


Message Edited by Neal M on 01-21-2008 02:34 PM
Neal M.
Applications Engineering       National Instruments        www.ni.com/support
0 Kudos
Message 6 of 6
(3,432 Views)