From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger on Every Digital Transition

I am trying to write a program that triggers an analog aquisition on every transition (rising and falling) of a digital signal.  I have seen several examples on retriggering and the start-stop trigger example, but these are not exactly what I am hoping for.

 

The ideal setup would be a continously running vi that would write both pre- and post-trigger samples to a file every time my digital signal transisitons from hi or lo.  Seems like the state change trigger could be used to make this happen, but I haven't really seen it used this way.  Thoughts?  Thanks!

0 Kudos
Message 1 of 4
(2,671 Views)

Keller01,

 

What is the minimum time between the high and the low that you would need it to retrigger? Is the digital signal consistent or random? 

 

Becca B.
Product Marketing
National Instruments
Message 2 of 4
(2,632 Views)

As I understand it, you want to acquire "snippets" of analog data timed to surround a transition of a digital line.  I'm assuming that you want all of your analog signals on a consistent clock, by which I mean if you are sampling at 1KHz, the time between the stopping of one A/D acquisition and the beginning of the next is also in milliseconds.

 

Assuming this is true, and assuming that your digital signals are basically level changes (as opposed to sub-milliisecond pulses), it is not too difficult to do what you want.  We're actually doing this ourselves -- we are doing a behavioral study with a 1KHz A/D sampling rate.  We have several digital signals that are basically levels.  

 

The heart of our DAQ loop (a timed loop in a LabVIEW RT Target, running at 1KHz) is to take 1 sample of N channels of our A/D and to do a Port read on our two 8-bit Digital Input lines.  This is passed out to a Consumer loop.  We detect the presence of a Digital transition by asking if the 8-bit quantity from, say Digital In 0 differs from the previous value (held in a Shift Register).  When they differ, we have a Transition and can do whatever extra logic we need to do.

 

If you want to capture the Analog signals 10 msec before the Digital pulse, create yourself a 10msec (= 10 sample) "buffer" to hold your analog data.  A convenient buffer is a 10-element Queue configured as a Lossy Queue.  Once you get the "trigger", you know you need to start saving the values that "fall of the end" of your Lossy Queue, as they represent the data 10 msec before the trigger occurred.  If you also want to save data to 20 msec after the transition, then you know you'll have to save 10 + 20 = 30 samples in all.  [Does this make sense?  Sorry if my words are inadequate -- draw a picture and it should be clear].

 

Bob Schor

 

 

Message 3 of 4
(2,615 Views)

Thanks for the replies.  The transition is every two seconds or so and I think Bob's idea is actually pretty close to the solution I am working towards.

 

I found an example where someone had coded in a retriggerable analog trigger with some pretrigger data saving.  I am taking that and mofiying it this evening.  If I think it will work, I'll post it here.  

0 Kudos
Message 4 of 4
(2,609 Views)