LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Generate a delayed counter pulse

I am posting this to see if anyone can shed any light on various DAQmx operations with counters.  I appear to have found a solution for the project but various counter operations are certainly not well documented and the notes I am posting may help anyone trying to do something similar.
 
The project is to monitor an analog input channel and when a certain criterion is met generate a pulse with a specified width at a specified delay from the event.  It is being done in a LV Real Time system.  Initially I tried to start a counter task within a loop, wait until done and stop the task.  What I have found is that it takes a long time (of the order of 10-100's of ms) for the start task to return and the wait until done doesn't reliably return at the time the counter pulse is finished being generated.  Other people seem to have found the same problem.  This is described in the part 1 attachment and the attached vi.
 
The other way to do it is with a retriggerable counter task and using a digital line on the same card to trigger the counter.  Then the way the counter works if there is a single pulse or multiple pulses is different.  The way low time and high time are interpreted is odd.    This is described in the part 2 attachment with screenshots from Scope captures.  I have a proposed solution but I'm not sure if it is the best way to do it.
 
Any suggestions appreciated.
0 Kudos
Message 1 of 4
(3,085 Views)
Andrew,
 
If you want to start a counter output task based on an analog input you should use an analog trigger (if your device supports analog triggering). Take a look at the example Cont Acq Sample-Timed Loop-Analog Start.vi (in the example finder - search for "trigger") for how to set up an analog trigger in DAQmx. Also, you can use the Start.Delay property in the DAQmx Trigger property node to specify an amount of time to wait after the Start Trigger is received before generating the first sample
--
Michael P
National Instruments
0 Kudos
Message 2 of 4
(3,068 Views)
Thanks for reply.  That example is to acquire data (or a block of data) based on a trigger source.  I can see that you could generate a delay from the trigger using the analog trigger with the trigger delay property which is available for an analog trigger (unfortunately the delay property wasn't available for a counter task).
However what I want to do is acquire data at a constant rate (as fast as possible on a real time system) and when a condition of the data is met (eg exceeding a threshold) then generate a pulse at a specified delay from this event.
 
The M series card is a 6221 which doesn't have an analog trigger.
0 Kudos
Message 3 of 4
(3,062 Views)
The only way I know to do what you are requesting on a device without analog triggering would be to do it in software -- monitor the analog input in LabVIEW, then start the counter task.
--
Michael P
National Instruments
0 Kudos
Message 4 of 4
(3,046 Views)