LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to use counter output pulses to trigger analog input?

Hello all,


I hope the kind people using this forum can help me, a lowly beginner LV programmer! I have been attempting to create a VI that produces a user defined number of TTL pulses, separated by every n seconds. Each TTL would be outputted to a stimulator, which in turn generates its own TTL. Using the stimulator-generated TTL, I would like to trigger finite analog data acquisition (e.g. for every TTL, trigger the collection of a data sweep that contains 4000 samples (collected at 4000 Hz), with 1000 samples collected pre-trigger. I would like to also be able to see each data sweep as it is triggered on a chart. As I understand things (lots of online/book/forum reading), I should be using the counter output to generate my TTL pulses, and syncing each counter produced TTL with analog input, as well as using a reference trigger. Also, the AI part should be started first, so that I don' t miss any counter outputs. If it matters, I also need to use one of the AI channels to acquire the TTL, so I can see my stimulator-induced responses to the stimulator in time.


I am able to generate the TTL pulses from the counter output, but I am having a problem with the AI part. I am unsure how to sync the counter output with AI. Also, since I need to acquire pre-trigger samples, I would be needing to acquire samples continuously, but when I set 'continuous samples' on daqmx timing, the VI doesn't work (hence why's its set to 'finite samples').


 I hope someone out there can help, as I have been at this for what seems ages, with limited success. I am using a USB-6259 and LabView v8.2. Thanks! Smiley Happy

0 Kudos
Message 1 of 6
(5,380 Views)

Hello,

 

Due to the fact that analog tasks themselves are not retriggerable, a pulse train produced by a counter is always used as the sample clock for the analog input task in order to recreate a retriggerable effect for analog input. This can be done by creating a finite pulse train set to retriggerable using the DAQmx Trigger Property Node, or the pulse train could be continuous and just be gated by another signal. Neither of these methods can be properly applied in hardware to create a retriggerable reference trigger. You can however implement something similar in software by just stopping and restarting your reference triggered analog input task within a loop. There will be some delay between when the task is stopped and restarted, as these events require software intervention, but if there is enough time between when each trigger signal is generated, there should not be any noticeable delay or missed samples.

 

I have attached an example of this!

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

Hello,

 

Please note the example code I posted does not have the counter output code in it, please feel free to add this back in!

0 Kudos
Message 3 of 6
(5,341 Views)

Hello,

 

This is a version of the VI compatible with LabVIEW 8.2

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

Hello macaba,

 

Thank you for your help. Sorry for not replying sooner, but I have been away. I have added my counter output to the modified VI you posted, and everything seems to be working. However, I am still a little unclear about your statement 'a pulse train produced by a counter is always used as the sample clock for the analog input'. If I want my AI to be sampled at 4000 Hz, but I have set the counter output to deliver a TTL pulse once every 5 seconds (which would be the normal parameters for what we do), is the sample clock running too slow? Or have I got this completely messed up?! In my VI, should I be linking the 2 DAQmx Timing VIs? Any more valuable help you can provide would be greatly appreciated.

 

 

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

Hello,

 

'a pulse train produced by a counter is always used as the sample clock for the analog input' means you will need to set up another counter that runs at 4khz to act as the sample clock for the AI task.

 

The 5 second TTL pulse is the pulse that triggers the reference trigger? If so, then this will need to be a seperate counter.

 

I hope this helps!

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