Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

PXI 6123 counter problem

Hi,
 
I am using a PXI-6123 data acqusition card to measure voltage and displacement in my application. The displacement sensor is a linear encoder, which outputs TTL signals at Channel A and Channel B. I connected Channel A to Counter 1 Source (Pin 42), Channel B to Counter 1 Count Direction (port0/line7, Pin 48).
 
The measured waveform of displacement looks like the shape was fine, the problem is that the value of the displacement was wrong, it never starts from zero. And after I ran the vi for a few times, the counter seems overflowed.
 
I have attached the vi in the post, any help is very appreciated.
0 Kudos
Message 1 of 5
(3,834 Views)
Hello JSI,

I have taken a look at  your code, and I believe I have found where the misunderstanding is.  Your signal connections all look correct, and your code runs as well.  I believe you are seeing the results you are, because your counters are receiving (and counting) tics before your analog task triggers.  As soon as you start your counter task, it will start to count tics.  It does not wait for the start trigger you configured in your analog input task.

Although the counter does not receive the clock to latch values, it still counts tics from your source (pin 42) and Channel B pins.  This would explain why it is not starting at 0.  On M Series devices and STC2 (new isolated boards) based S Series you can arm trigger the counters to prevent this, and start the analog acquisition and counter task at the same time.  Perhaps it would be possible to externally gate your signal.

Regards,

Jesse O.
Applications Engineering
National Instruments
Jesse O. | National Instruments R&D
0 Kudos
Message 2 of 5
(3,824 Views)
Hello Jesse,
 
Could you please give more details on "externally gate signal" ?
 
I have another question: I realized that LabView did not allow me to use Counter 0 to measure the displacement, is it because it is used by this vi for START DELAY counting?
 
Thanks,
 
JSI
0 Kudos
Message 3 of 5
(3,819 Views)

Hello JSI,

As soon as you start your counter task (even if the analog task has not be started/triggered), the counters will count ticks from you encoder.  If you start your counter task before you trigger your analog task you will need to stop these tics from reaching the counter.  Perhaps it would be possible to AND these TTL pulses with another signal that is high after your trigger signal is sent. 

Next, the error message -200078 is expected when using an STC based device (not STC2).  You can find more information on this here.  If you want to use counter 0, you will need to start the counter after your analog task triggers or set the data transfer mechanism to interrupts.  You can find the property node to set this in the DAQmx channel property node.  I have attached an image of this below.  If you want to use interrupts, you might have to decrease the sampling rate from 250k because of the FIFO size of a counter.

Regards,

Jesse O.
Applications Engineering
National Instruments

Jesse O. | National Instruments R&D
0 Kudos
Message 4 of 5
(3,806 Views)
Hello Jesse,
 
Based on your information, I make some change to the vi and solved the problem. I am attaching the vi here in case somebody has the same problem.
 
Thanks for your help.
 
JSI
0 Kudos
Message 5 of 5
(3,787 Views)