LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I use two counters simultaneously for pulse width measurment

Solved!
Go to solution

Thanks, I can see your VI now.

 

The example I posted was more of a way to show how the hardware might be configured to do what you needed.  Figuring out how to architect your application around these hardware calls is a little more open-ended.  From what I gather, you need to be able to:

 

    1. Arm / Pause the input channels through the UI.
    2. Store a log entry once both channels are triggered.  Then presumably re-arm the channels for another set of samples after this.
    3. Be able to clear the log entry.
    4. Save the log to file (this wasn't in your attached VI though, but you mentioned it).
    5. Change the distance between gates dynamically (what should happen to the old log entries that were taken with a different distance setting?)
    6. Change the bullet mass dynamically (again, what should happen to the old log entries that were taken?)

 

Writing good user interface code can be tricky--I'd suggest incorporating a queued event handler (and using DAQmx Events), but it will likely be difficult to get started if you haven't done something like this before.  I might have some time tomorrow to post an example.

 

 

Best Regards,

John Passiak
0 Kudos
Message 31 of 38
(1,218 Views)

I had some time to write a simple state machine example that should get you started:

 

Penetration Test.png

 

I realized you'll probably end up polling the inputs anyway--getting the USB device to work with events can be frustrating (samples left on the hardware buffer, etc.).

 

 

Best Regards,

John Passiak
Download All
0 Kudos
Message 32 of 38
(1,204 Views)

Thank you a lot John

 

There are so many things to learn on Labview! As what I see in the VI, the DAQmx Timing is set as '2 samples per channel'. Does that mean the buffer only save 1 sample from each counter, or save first 2 samples no matter which counter they come from (may be the 2 from the ctr0).  I am a bit confused about that.

 

Sorry for taking your time.

 

 

Cheers

Daisy

0 Kudos
Message 33 of 38
(1,195 Views)

The minimum buffer size is 2 samples per channel (it's a DAQmx peculiarity).  Each task has its own 2 sample buffer, but you really only care about the first sample.  The "Read Relative To" property is set to "First Sample", so you will always read the first sample in the buffer.  Once you have acquired from both channels, the tasks will restart which will clear the buffers.

 

 

Best Regards,

John Passiak
0 Kudos
Message 34 of 38
(1,188 Views)

OK, now I understand! Thank you a lot, John.

Best Regards

Daisy

0 Kudos
Message 35 of 38
(1,181 Views)

John...

Sorry to bother you again and again. I have a tiny question about the button state. Is it possible if I want to change the button state programmatically, i.e. can I change start button to 'pause' state if both channels get data? So that I can click start button manually rather than the restart automatically.

 

Cheers

Daisy

0 Kudos
Message 36 of 38
(1,158 Views)

Hi John

 

I have solved my problem.

 

Cheers

Daisy

0 Kudos
Message 37 of 38
(1,156 Views)

Hi,

 

Can anyone help me in this situations. I am also using two counters for measure pulse width.

 

Link: http://forums.ni.com/t5/LabVIEW/Why-get-Error-201314-when-measure-two-counters-simultaneously/m-p/32...

 

Thank you,

0 Kudos
Message 38 of 38
(1,035 Views)