Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Throw a switch to take N samples from a USB-6361 DAQ.

Solved!
Go to solution

I have a USB-6361 DAQ connected to my laptop, and I am using DAQ assistant to interface with the DAQ. I am trying to create a VI that graphs N samples of data when the user toggles a switch. I have a while loop containing the DAQ assistant and a switch connected to the "stop (T)" input of the DAQ Assistant. When the "stop (T)" switch is true, the DAQ assistant should stop collecting data.

 

However when I run the VI, the DAQ assistant continuously takes N samples, and the "stop (T)" switch does not stop data acquisition.

 

The DAQ assistant output connects to two graphs and a "record measurement data" block. A second switch controls when the data are recorded. Please refer to the attached VI and a diagram of my logic.

0 Kudos
Message 1 of 8
(3,263 Views)

Do you want data continuously or just a quick snapshot when you press the button?  This will determine which of the two solutions I have in my head.

 

One other note: Never have an infinite loop in Windows.  Your Stop button should actually stop your VI.  If you are relying on the Abort button in the toolbar, STOP IT!!!  That can cause all kinds of interesting issues due to resources being left open.  Just stop your loop with a condition, do whatever cleanup you need to, and let the VI complete.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 8
(3,247 Views)

Hello crossrulz,

 

Do you want data continuously or just a quick snapshot when you press the button?  This will determine which of the two solutions I have in my head.


I want to take N samples of the analog input, when I press the button. Where N is a constant.

 


One other note: Never have an infinite loop in Windows.  Your Stop button should actually stop your VI.  If you are relying on the Abort button in the toolbar, STOP IT!!!  That can cause all kinds of interesting issues due to resources being left open.  Just stop your loop with a condition, do whatever cleanup you need to, and let the VI complete.

My goal is to run the VI, then only acquire data when the user pushes the button. I have been relying on the Abort button in the toolbar. In order to stop my loop with a condition, should I tie a separate switch to the "loop condition" within the while loop?

 

Secondly, once I stop the while loop, do I then use the toolbar to abort the VI, or is there another button to stop the VI from within the GUI window?

 

Thank you,

0 Kudos
Message 3 of 8
(3,238 Views)
Solution
Accepted by return_of_the_mack

I recommend using an Event Structure.  This way, you press a latching button (resets when the terminal is read) and a single shot of the data is read, processed, and saved.  Then another case for the Stop button (use the normal Stop button that is in the palettes to make your life easier) so that the loop can stop when it is pressed.

 

When you let the VI stop normally (all code finishes execution), there is no need for the abort.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 4 of 8
(3,234 Views)

Thank you very much, crossrulz! This is working exactly as desired.

 

I have run into a separate issue though, and I was wondering if you could help. I am using an Agilent 33250A arbitrary signal generator to send a 500Hz, 1 Vpp sinewave to the analog input 0 of the DAQ. I am sampling the signal with the DAQ assistant at 3k samples / second. However, my sampled signal has jagged edges and it looks like I am not sampling enough.

 

Do you believe this is a hardware issue or software issue? Should I try sampling the same signal on different channels of the DAQ?

 

Thank you

0 Kudos
Message 5 of 8
(3,220 Views)
Solution
Accepted by return_of_the_mack

Ok, let's do a little math.  You have a 500Hz (500Cycles/s) signal being sampled at 3kS/s.  So (3000S/s)/(500 Cycles/s) = 6 S/Cycle.  So you have 6 samples to represent your sine wave with.  Yes, it will look a little jagged.  If you want a smoother signal, sample at a faster rate.  My general rule of thumb is 10x your signal for most calculations.  But the faster you sample, the better you can represent that signal.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 8
(3,211 Views)

It is a *configuration* issue.  You need a faster sampling rate if you'd like to see a reasonable approximation of a sine wave on your graph.  Right now you're sampling at 6x the waveform frequency.  That leaves you trying to approximate an entire sine wave with 6 data points, which isn't enough to look very sine-like.   I'd be aiming for more like 20x if feasible which gives you 10 points per "hump" of the sine wave.  That'll at least make your graph start to look like a sine wave.

 

Like many things, there are tradeoffs -- a higher sampling rate more closely reproduces the original analog signal, but also puts greater demands on your hardware, software, and file storage.  

 

 

-Kevin P

 

EDIT: Guess I'm a little slow at the keyboard, you already got the same answer before I managed to finish.

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
Message 7 of 8
(3,208 Views)

Ahh right, that is my mistake. I was using the Nyquist - Shannon theorem to determine that the maximum frequency I could measure would be 1.5kHz, and that 500Hz would be well within the sampling frequency. I forgot to consider that I am still viewing the sampled signal in continuous time, rather than converting to digital.

 

It's been a while since I've worked with signal processing. Thank you for the help!

0 Kudos
Message 8 of 8
(3,194 Views)