LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Continuous measurement with AI (6-60 kHz sampling frequency)--how to use NI-DAQmx 'Read' VI?

Solved!
Go to solution

Hi,

 

I have an encoder and a voltage source I need to measure, synchronously (I need to know the position at every time I sample the voltage) for 25 seconds straight. Although I need to perform a couple checks on the data as it comes in, I can use microchips outside the PCI board (a PCI-6280--single-channel sampling frequency 625 kS/s and multichannel sampling 500 kS/s, onboard AI buffer is 4096 bytes) to do this instead and use the PCI-6280 for only reading the measurements as they come in if necessary. I've already thought of a couple ways to do this, and I want to know whether I'd be implementing them properly: 

 

  1. Make a task with 4 AI's (voltage/A/B/index), all sampling at the same frequency (somewhere between 6 and 60 kHz, as above). Start the task, and then use NI-DAQmx's 'Read' VI to read periodically from the buffer while sampling occurs continuously. LabVIEW apparently will make a buffer 100kS in size for this frequency of continuous sampling, so the Read VI would need to read out 60kS worth of data every second (I figure I can use a timed loop in which the Read VI is called on a 1-second period to pull 240000 samples out of the buffer--or, 460 kB of data? Obviously the 'Read''s retrieval frequency isn't too constrained, and I can make it go faster so it doesn't need to pull out as much data at a time. Any clocking suggestions?). Note that three of these AI's are for the quadrature encoder, which seems pretty wasteful given that all I need to know is the position when the voltage is read.    
  2.  Use the encoder as an external clock for the measurements and sample 1 AI in pretty much the same way as above when it comes to the way 'Read' VI is used. One potential problem here is that I don't want one measurement per external clock tick--I want 5-50 measurements at each encoder tick (x2 resolution). This (encoder) external clock input would have a frequency close to 1.2 kHz (although it would vary, I would guess, between 800 and 1.4 kHz). Instead of using it as an external clock per se (unless LabVIEW can be configured to take several measurements at each clock tick), can I wire the encoder input in as a digital trigger, and tell the PCI board to take n measurements every time it triggers? And after I've done that, could I reliably recover the encoder measurement by counting the number of times the PCI board has sampled n times after I've retrieved the data using 'Read' VI (ie, take all the measurements the board made and divide it by n)? Is there any way I could monitor the index value as well so that the PCI board could tell when it hit an index point and somehow put that into the data (I can always grab a simple microchip counter to do this outside the machine, but I'd really prefer to do it in the PCI board)?  
  3. As an alternative to using the 'read' VI, since I only want to log data can I use TDMS on the 4 analog inputs? Would it be a faster way of draining the buffer so that I don't miss any of my measurements, or will 'Read' VI work best for this purpose?  

 

Thanks for any help you guys can offer. I'm sorry I don't have any VIs to show you yet--this is more of a theory problem right now. 

0 Kudos
Message 1 of 6
(3,038 Views)
Solution
Accepted by acmap

Hi acmap,

 

Your card has two counters.  You can use the counters to read in your encoder.  For instructions on connecting it, see the following:

http://digital.ni.com/public.nsf/allkb/B3945A72AE53D1B086256EF7007C4D0D

 

An example of how to synchronize it can be found here:

https://decibel.ni.com/content/docs/DOC-10785

 

 

Regards,

 

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 6
(3,001 Views)

Hi,

 

To get the data I need, I would have to take 10-100 measurements at a frequency of ~2400 Hz or higher. Could I use the 10 kHz clock to digitally trigger samples on both the counter and the analog input, and have them each take a finite number of measurements (2-25 for the analog input and 1 for the counter input)? The alternative is for me to sample continuously at 240 kHz on both channels--is this possible for the PCI card or will I run into difficulties (given that the PCI's maximum multichannel sampling frequency is 500 kS/s)?

 

Thanks for your help Chet.

0 Kudos
Message 3 of 6
(2,984 Views)

Hi acmap,

 

I'm rereading your first post.  By synchronize, I was under the impression that you want to take an AI measurement whenever we detect anything from the encoder.  But, your latest post confuses me.  Can you reiterate what it is that you want?  and define synchronize.

 

 

Regards,

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 6
(2,970 Views)

Hi Che,

 

Sorry about that--yes, I want to take n AI measurements (10-100) every time the encoder moves. The synchronizing VI example you gave me will work fine, anyway--I figure I can synchronize encoder/AI measurements by having both digitally triggered by the exclusive or (done with a digital electronics gate outside the PCI board, to save processing) of encoder outputs A and B, giving me encoder position measurements (and AI measurements) at x2 resolution of the encoder. Thank you for your help.

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

Hi acmap,

 

Not a problem.  Definitely feel free to post again if you need assistance.

 

 

Regards,

Che T.
Applications Engineer
National Instruments
0 Kudos
Message 6 of 6
(2,915 Views)