LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to send TTL output AND acquire AI voltage data using USB-6211

Hello,

 

I am relatively new to Labview, so please bear with me.  I have a research application involving 2 pressure transducers and a high-speed camera.  I wish to acquire analog voltage data from the 2 pressure transducers.  However, at the start of the acquisition, I will need to send a single TTL output to trigger the camera.  This TTL pulse must be sent out at exactly the same time that the AI acquisition begins, in order to ensure that my 2 pressure measurements and camera images are 'synchronized' in time.

 

Is this possible on the USB-6211 running with LabView 8.20?  I currently have a fairly simple LabVIEW vi that uses a software trigger to start an AI acquisition - I have attached it with hopes that it may help anyone willing to assist me.  I would prefer to be able to simply add something to it so that it will output a TTL pulse at the start of the acquisition.  

 

Thank you in advance.

 

Regards, Larry

Message Edited by Larry_6211 on 12-19-2008 11:24 AM
0 Kudos
Message 1 of 10
(5,103 Views)

Larry,

 

I do not work with the USB-6211, so I am not sure which things will work with that equipment.

 

One method it to use hardware triggered AI and then generate the trigger with a Digital Output.  The same pulse can be connected to the AI trigger in terminal and the camera trigger. 

 

If the AI does not support hardware trigger and you have an unused analog input channel, start the AI acquisition first, then generate a digital trigger with a Digital Output.  Connect the digital signal to the extra AI channel and to the camera.  Set the size of the AI acquisition to be large enough to capture some pre-trigger samples and all the post-trigger samples you want.  After the acquisition search through the analog data to find the trigger signal and throw out the data before the trigger.  This method can also be used with external triggers.  The maximum trigger latency is less than or equal to one sample period.

 

Lynn 

0 Kudos
Message 2 of 10
(5,091 Views)

Lynn,

 

Thank you for your clear and prompt reply.  I took your smart advice and have now got both my AI and camera to trigger from the same Digital Output TTL pulse (generated by the same USB-6211 that is also used to acquire the above-mentioned AI).  Therefore, conceptually, this triggering configuration seems to be working!  Yay!

 

Now, however, I will need to fine-tune the timing of the AI and triggering, so as to ensure that the first AI Convert Clock (i.e., first AI data sample from the first of two AI channels) occurs at precisely the same time as the AI Start Trigger (and hence the AI Sample Clock).  I understand that by default there are two time delays separating AI Start Trigger and AI Convert Clock (recall I am presuming that AI Convert Clock triggers the sampling of my first 'data point').  The two time delays are:

 

i) 2 ticks of AI Sample Clock Timebase separating AI Start Trigger and AI Sample Clock; and

ii) 3 ticks of AI Convert Clock Timebase separating AI Sample Clock and AI Convert Clock. 

 

In order to ensure that my AI Start Trigger occurs at the same time as my first data sample, I am really tempted to set both of the above-mentioned time delays to 0.  Do you think there would be any problems associated with this?  And while we are on this topic, I am also curious as to why there are even these (default) time delays in the first place.

 

Thank you in advance.

 

Best, Larry

 

 

 

0 Kudos
Message 3 of 10
(5,058 Views)

Hi Larry,

 

It would be useful if you could post your latest piece of code so that we can take a look at how you have implemented Lynns solution and consider the impact of your proposed changes.


Regards,

 

Thomas Clark

Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 4 of 10
(5,041 Views)

Hi Thomas,

 

Thank you for offering to look at my code (it is attached). 

 

I really hope that my code is doing what I "think" it is doing, and that I'm doing it via the "right" way.  Smiley Happy

 

Best, Larry

Message Edited by Larry_6211 on 12-22-2008 06:51 AM
0 Kudos
Message 5 of 10
(5,033 Views)

Hi Larry,

 

You should be OK to set both of those values to 0.  The option is there to add a greater level of control over when the aquisition of data starts.

 

Regards,

 

Thomas Clark

Applications Engineer
National Instruments UK & Ireland
0 Kudos
Message 6 of 10
(5,017 Views)

Hi Thomas,

 

Could you please demonstrate how I can change the two time delays mentioned above?  Moreover, is there a way to have the Timing Node show that the two time delays have in fact been changed?

 

Thanks, Larry

0 Kudos
Message 7 of 10
(5,004 Views)

Hi All,

 

I'd like to clear a few things up. First, you'll find that if you try to set the delay from ai start trigger and delay from ai sample clock to 0, you'll get an error. Due to hardware synchronization and delays, the min you can set is two. Note that when I say two, I am referring to two tick of the AI Sample clock timebase, which for most acquisitions is the 20MHz timebase. I modified a shipping example so you can play around with those delays if you want to - I find that exporting the signals and looking at them with a scope helps me visualize what is going on. The Manual has some good timing diagrams as well but it looks like you've already hit that. The defaults would give you a delay of  250ns from the start trigger - is this too high for your situation? What is an acceptable delay? I tend to think that "exactly the same time" is a measure of how precise rather than an absolute (think delays in cable length making a difference.)

With all that in mind, I see a few options:

 

Start your camera off of the AI start trigger (an internal signal) and just know it is 250 ns before your first convert. 

Export the convert clock to use as a trigger. This assumes your camera can ignore the next set of convert clocks.

 

More complicated option: Internally you have an ai start trigger, sample clock and convert clock. From your start trigger to the first convert is 250ns but if you export your convert clock you're going to get future convert clocks as well. One option would be to generate a single triggered pulse using a counter (start with the  Gen Dig Pulse-Dig Start.vi example) with the AI start trigger as the trigger for the counter, an initial delay of 250 ns, and a high time of whatever you want it to be. This should give you a singe pulse at very close to same time (on the order of path delays) as your first convert clock. 

 

Hope this helps, 

Andrew S

MIO DAQ Product Support Engineer

Message 8 of 10
(4,993 Views)

Hi Andrew,

 

Thank you for your clear reply.  You raised some very interesting questions in regards to timing precision, and I would like to respond to them. 

 

The default delay of 250 ns is acceptable for my application.  However, I would like to confirm for myself that this delay is in fact 250 ns.  Would the easiest way to do this be to output the Sample Clock and Convert Clock to a scope?  I was under the impression that the Sample Clock and Convert Clock were always ticking, in which case, how would I be able to know on which clock tick the data sampling actually begins?

 

Furthermore, for the purpose of clarification, you had recommended: "Start your camera off of the AI start trigger (an internal signal) and just know it is 250 ns before your first convert."  If I am hardware triggering my AI Task using a Digital Output TTL pulse -- which is generated by the same USB6211 DAQ and which is also used to trigger my camera, as per suggestion by Lynn above -- then which of the following two situations should I expect to occur:

 

a) The Digital TTL pulse and AI Start Trigger will occur at the same time (i.e., with timing precision on the order of internal path delays); or,

b) There will be some (possibly significant) time delay between the Digital TTL pulse and AI Start Trigger.

 

And in the event that I am not being clear enough: Yes, I completely understand that I can trigger my camera from AI Start Trigger.  However, I plan not to trigger my camera from AI Start Trigger but instead to trigger my camera from a Digital Output TTL pulse sent from my USB6211 to the following:

 

1) the Digital Input of the same USB6211, which in turn triggers an AI Task;

2) My camera trigger input, which in turn triggers the start of image capture.

 

In step 1) above, I would like to know if there will be a significant time delay (i.e., on the order of micro-seconds) between the receiving of the Digital Input and the activation of AI Start Trigger, after which 250 ns should pass before the first Convert Clock initiates my first data sample from the first channel of my AI Task.

 

Thanks in advance.  I really appreciate all the help that everyone has been giving me.

 

Cheers, Larry

Message Edited by Larry_6211 on 12-22-2008 06:41 PM
0 Kudos
Message 9 of 10
(4,984 Views)

Hi Larry,

 

Good questions. I find the easiest way to verify to be a scope - if you have a 4 channel you can compare the external trigger, AI start trigger, ai sample clock and ai convert clock. The sample clock and convert clock are not free running - they start after the ai start trigger (which occurs internally whether you use an external trigger or not) so you could trigger your scope off of the external trigger and look at the delays to the next signals.  

 

As far as the delay from the external trigger to the AI start trigger, it will be on the order of 10's of nanoseconds. It does take time for the trigger to propagate, pass through some circuitry and sync with the AI timebase, but if I recall right it should not take more than 1 timebase tick (50ns) to sync up. The M-series user manual has some timing diagrams (Appendix B) that get into the guts of the timing and while the values are slightly different because the 621x devices use a different timing chip the same signals and delays are there. Regardless, it will not be on the order of microseconds so you should be ok.

 

Cheers,

Andrew S.

0 Kudos
Message 10 of 10
(4,963 Views)