Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

Count number of triggers from paused counter source

I have a very large, very complicated VI that I am using to control an experiment. This experiment requires certain environmental conditions to be true in order to acquire data. Once these conditions have been met, a trigger is sent to an independent data acquisition system to initialize the acquisition. I need to be able to count the number of times these triggers have been sent (approximately one is sent every 10-15 mins) but can't seem to get the CI Cnt Edges scheme to work. I can't use DAQ Assistant because it is too slow due to the size of my VI.

 

Anyways, I have the VI setup so that I basically have an analog output as Pause source on the counter output that sends the triggers. I just need some way to count these pulses but the way I currently have it working, the VI won't stop or abort because I have the Counter sample wait time as -1 (wait indefinitely) and I have to terminate labview from the task manager to stop the VI. Is there an easier way to do this?

 

I am using Labview 2014 with a PCI-6221 DAQ with a BNC-2120 attached for all of my outputs.

Download All
0 Kudos
Message 1 of 6
(5,241 Views)

Hi there,

 

I just saw  "Counter Reading.png ‏22 KB" and the problem is not the Counter sample wait time, I think that the problem is that you are using an "AND" instead of an "OR", so it wont matter if you press the stop button it will never stop because the AND is "True" when the error status and stop button are TRUE and in your code the error status never turns to False, so lets try to change the AND to an OR

 

Regards

0 Kudos
Message 2 of 6
(5,172 Views)

You'll want to avoid using a -1 timeout as well.  Here are a few options:

 

Make the timeout much lower and simply handle the timeout error (i.e. check for the specific error code and discard the timeout error if it occurs--only write the indicator if the read does not timeout).

 

Use the DAQmx Every N Samples Event to only read when a new sample is available.

 

Poll the Available Samples per Channel property and only read when a new sample is available.

 

 

 

Best Regards,

John Passiak
0 Kudos
Message 3 of 6
(5,137 Views)

keroba, Yeah I noticed that after I submitted my post but it still causes LabView to crash.

 

John_P1, I was able to get something working without actually reading the triggers with a bunch of shift registers and such but I would really prefer to actually read the counters so I will try out your suggestions.

0 Kudos
Message 4 of 6
(5,093 Views)

Hi mechengrkj

 

When you said LabVIEW still crash, what do you mean by that? It does not stop when you click the stop button?

 

Instead of using local variable why do not you use notifiers to pass the boolean data from one while loop to another?

 

I tried to read a counter with a -1 in the timed out pin and I was able to stop the VI when I wanted. Did you tried to run the Counter - Count Edges Continuos clock?

 

Is in help>>find examples>>Hardware input and output>>Counter Input>>Counter - Count Edges (Continuos clock)

 

regards

0 Kudos
Message 5 of 6
(5,060 Views)

I think one more option is to abort this task (on stop button) in master loop. Counting loop DAQmx Read will fail and error will stop the loop. Then clean the task and profit.stop by control.png

A little hint: you can input error to boolean functions without unbundle status.

0 Kudos
Message 6 of 6
(4,831 Views)