Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to start and stop N times the acquisition of an analog input with a single digital trigger (NI-PCIe6259) ?

Solved!
Go to solution

I have been looking at all the examples involving triggers in labview and quite a few ones in the forum, but I cannot figure out how to do what I want.

I am using Labview 8.5 and the DAQ PCIe-6259.

 

I need to start and stop the acquisition of an analog input (voltage) with a digital trigger, several times.

It basically corresponds to an X-Y scan.

My raster scan is started and done till its end without me having to interact with it.

The scanning controller is just giving me some trigger times in between which I need to acquire some data.

A few lines would be looking like that (the x axis here being the time):

 

      ---------trigger1+++++++++++++++++++++++++++++++++++++++++++++++++++++++++trigger2---------------

          ---------trigger4+++++++++++++++++++++++++++++++++++++++++++++++++++++++++trigger3---------------  

      ---------trigger6+++++++++++++++++++++++++++++++++++++++++++++++++++++++++trigger5---------------

...

The ------ correspond to two zones were I do not need to scan (where the movement is not linear).

 

What I need to do is:

  • start the acquisition at trigger1
  • acquire N1 samples (I do not know N1 exactly) at a known rate (~10kHz) between trigger1 and trigger2
  • stop the acquisition at trigger2
  • store the result (1D-array) in the first column of a 2D array
  • start again the acquisition at trigger3
  • acquire N2 samples (I do not know N2 exactly) at a known rate (~10kHz) between trigger3 and trigger4
  • stop the acquisition at trigger4
  • append the resulting 1D array in the previous 2D one.
  • ... and so on

 

I do probably not fully understand the stop trigger concept, but I hope that someone would be able to help me.

 

Thanks

Message 1 of 8
(4,462 Views)

Good morning Zedude,

 

Please peruse the attached file. Its a fairly simple example vi, illastrating how to trigger (start and stop) a analogue acqusition from a digital PFI line. The block diagram is well documented, so it should be easy to follow and modify. I have not included any data logging or array creation - but from the tone of your forum post, you are happy to impliment this yourself.

 

I hope this was helpful to you.

 

Best wishes

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 2 of 8
(4,429 Views)
Solution
Accepted by topic author Zedude

Hi Rich,

 

your example is in Labview 8.6 and I am using Labview 8.5, so that I cannot open it.

could you post your example in an earlier version of Labview ?

 

 

Thanks

0 Kudos
Message 3 of 8
(4,423 Views)

Sorry, but by mistake I pressed the button "solution ?" when I actually do not have my solution yet !

0 Kudos
Message 4 of 8
(4,418 Views)

Ha Ha! That was pre-emptive solution acceptance. I feel that there is alot of pressure on my example code now 😉

I should have checked your LV version before posting. Sorry about that, myfriend.

 

Best wishes,

Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
0 Kudos
Message 5 of 8
(4,416 Views)

Rich,

 

I am not sure that your solution would allow me to do what I want, because I don't know exactly where the triggers are, so that I cannot really define the number of samples and the number of pretrigger samples.

 

But actually my problem has changed recently, because I discovered that I have more trigger points that I was expecting and that they are not defined as a "position tag" as I was expecting, but as timestamps.

 

So I actually now need to do a continuous acquisition during all my scan, which give rise to a new question - I don't know if it should be a new post.

 

My question is how to acquire two continuous signals (one AI, one DI) at a frequency around 10kHz for probably around 8M samples and store them in a file?

 

I don't think it is reasonable to try to fill an array every X samples, because anyway at the end it will be huge.

 

Any help would be greatly appreciated.
0 Kudos
Message 6 of 8
(4,411 Views)

A very efficient method of data logging is the tdms file format. The TDMS file format is designed to write and read measured data at a very high speed, while maintaining a hierarchical system of descriptive information. 

 

Traditionally, TDMS was a National Instruments only file format – you could only read it using our products – LabVIEW/CVI/DIAdem. However, bolt-on’s are now available, which allows you to directly open the .tdms files with Excel (see link). 

 

National Instruments Technical Data Management Overview

http://zone.ni.com/devzone/cda/tut/p/id/3676 

 

Introduction to LabVIEW TDM Streaming Vis

http://zone.ni.com/devzone/cda/tut/p/id/3539 

 

VI-Based API for Writing TDMS Files

http://zone.ni.com/devzone/cda/tut/p/id/6471 

 

TDM Excel Add-In Tool for Microsoft Excel User Guide

http://zone.ni.com/devzone/cda/tut/p/id/4906 

 

Examples of the use of the TDMS API ship with LabVIEW. You will find them in HELP > find examples > fundamentals > File Input and Output. For you application, I would recommend the “Cont Acq&Graph Voltage - Write Data to File (TDMS).vi”. 

 

If you are not interested in the TDMS file format, then you just need to look at streaming data to disk. There is a lot of information to be found on the NI website, but example vis ship directly with LabVIEW.  

 

HELP > find examples > fundamentals > File Input and Output > Write to Text File.vi 

 

The fact that you are using the low level functions means that you can open and close references to the file on start up and end of your acquisition, and just stream the data to disk as it is being acquired. This minimizes the interactions you make with the OS and increases efficiency… and it also means that you do not need to build huge arrays of data, before saving it all to disk in one hit. 

 

However, at the speeds you require, the TDMS format would likely be the best solution.

Message Edited by RER on 02-16-2009 08:37 AM
Rich Roberts
Senior Marketing Engineer, National Instruments
Connect on LinkedIn: https://www.linkedin.com/in/richard-roberts-4176a27b/
Message 7 of 8
(4,393 Views)

Thanks for your help Rich.

 

It is funny because before your answer I got a phone call from NI and, after asking me if I wanted to buy something, they transferred my call to an engineer who suggested me to try this TDMS file format.

 

I will give it a try.

 

Thank you again

0 Kudos
Message 8 of 8
(4,390 Views)