Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Data sampling issues

Hi everyone,
I have an issue with a program I am using to cycle a component while collecting data from 6 rotary potentiometers acting as position sensors. I'm using an SC-2345 board via 6036E card and SCC-FT01 modules. The problem I am having is that as I increase the cycling frequency I begin to get data that is erroneous. I have verified the calibration of the potentiometers and load cells within MAX and the DAQ assistant. I'm pretty new to this and can't seem to figure out where I am going wrong. Is it something pertaining to an input buffer situation? I'm completely lost and wasn't sure what to make of some of the solutions posted on here for similar situations. I've attached the vi in the hopes that someone might see something right away that I'm doing wrong. Please be gentle, as I know the vi is desperately in need of incorporation of sub Vis and is probably horribly inefficient. Thanks in advance for your help.

EDIT: This is running on an older pentium II with 128 megs of ram; I don't know if this could be part of the problem. I have varied the sampling rates and selected continuous sampling in MAX but this does not seem to affect anything outside of front panel activity.


Message Edited by JohnnyF on 06-21-2006 11:22 AM

0 Kudos
Message 1 of 12
(5,314 Views)

Hello JohnnyF,

If you do a test of just the acquisition part with the DAQ Assistant acquiring at the same rate and number of samples, do you see the same behavior?  I do not see anything in the VI, but it is large so I couldn't follow everything.  Watch out for those global variables  🙂

Can you give us an idea of what happens to the data when it become erroneous?  Do you get any errors? Is your cycle frequency the sampling frequency in your program, or is it the frequency of your potentiometers?  If it is the frequency of the potentiometers, what is the frequency?  Remember that you have to sample at a rate at least 10 times greater than the frequency of the signal you are measuring to accurately acquire the shape of that signal of interest.

Regards,

Laura 

Message 2 of 12
(5,290 Views)
Laura,
Thanks for the reply. If you can believe it, I've about halved the number of local and global variables. Smiley Surprised I'd like to blow the whole thing up and start over but we've got quite a time crunch and it's largely functional (if you don't count inaccurate data as a significant issue).
I played around with some of the parameters and revised that vi. By relocating my waveforms I think I'm getting more accurate data displayed there; the issue is that I'm not 100% certain that I'm accurately capturing all the peak values. We are cycling a test specimen at approximately 4-5 Hz. The sampling rate is determined by the user (probably not the best idea and soon to be remedied) and the best I have been able to make work is sampling once per cycle. Thanks for the reminder about sampling at 10 times the signal frequency-I can't believe I'd forgotten about that. I'm kind of at a loss as to what the best way to capture this signal accurately for exporting data to an Excel file. We expect 2-3 million cycles so the size of the file is an issue. I hope I've explained it somewhat well but I doubt I did. I've attached a library of the entire setup. The main file is the one to launch initially, the setup fil stores the parameters, calculations is the sub vi, and the test program is as before.
Thanks again for your help and for putting up with my stupid questions.
0 Kudos
Message 3 of 12
(5,275 Views)

Hi Johnny,

If you are only able to take one sample per cycle, then you are most likely always missing the peak value you are interested in.  What I would recommend is a different architecture for the analog input portion of your program.  It looks like you have a while loop that does the analog input and output with DAQ Assistants, and then also does some data analysis and displays to the front panel.  You need to do a continuous hardware-timed operation and not a single point software operation that samples once per cycle.  If you set up your DAQ Assistant to be continuous at 100 Hz and to read multiple samples at a time, does this pose a problem for your program?  Are you trying to only find the peak value?  You can use the amplitude and level measurements Express VI to find the peak of a data set, and then use that as an input to your calculations.  Or, if you need all of your data points to be inputs to your calculations, you can use array manipulation instead of performing an operation on one point at a time.  You can always use a for loop to auto-index your arrays so that you can do point by point calculations. 

If you find that the portion of your code that performs the calculations and does the analog output does not run fast enough for the analog input, you can use two separate while loops.  One would do the analog input and the second would do AO and calculations.  You can pass the data between the two using queues.  If you do a search in the NI Example Finder for "queues" you will find examples of this method which allows you to pass data between two concurrently running while loops, without losing any data.

Also, the sample rate you should use will depend on the width of this peak value.  If it is not very wide, you may have to sample faster. 

Regards,

Laura

Message 4 of 12
(5,245 Views)
Laura,
Thanks again for all the helpful advice. Sampling continuously at 100 Hz and reading multiple samples doesn't really pose a problem. Basically, what I want to do is find the peak value that occurs (on each channel) for each cycle, and then save the raw data and calculated values into a file. The issue I'm having now is separating the peak values and controlling the saving to file (and since we'll be in the 2,000,000-3,000,000 cycle range, maybe just saving the data every x number of cycles). I tried the VI you mention and didn't get it to function as I wanted; I suspect I just implimented it incorrectly somehow and will try again. Thanks for the tips on the queues-I hadn't seen or heard anything about them.
0 Kudos
Message 5 of 12
(5,241 Views)
I've tried incorporating the queue function and seem to be missing something-the one while loop doesn't seem to pass data to the other. i can't quite figure it out from the web resources or examples. Sorry I'm so dense, but I'd really appreciate it if you could steer me in the right direction. Attached is the updataed VI.
0 Kudos
Message 6 of 12
(5,233 Views)

Hi Johnny,

You are not enqueueing any elements, so the data is not being passed.  You need to use Obtain Queue to create the queue, Enqueue Element to add data to the queue, Dequeue Element to remove it, and Release Queue when the program is finished to release the reference.  Currently, you are only using Obtain Queue and Dequeue Element.  The best example of this in the Example Finder is Queue Basics.vi.

Hope this helps!

Laura

Message 7 of 12
(5,216 Views)
Thanks, I saw the error based on that example and fixed mine to include those elements, but it still won't pass any data from the AI loop. If I put a probe on the queue out within the loop I get values, but nothing proceeds from there. I can't seem to figure that one out. Any other stupid stuff I could be doing? Thanks!
0 Kudos
Message 8 of 12
(5,209 Views)

Hi Johnny,

As long as you are following the structure in that example you should be fine.  I don't see anything else that might be going wrong.  Can you post your modified code?

Thanks,

Laura

0 Kudos
Message 9 of 12
(5,199 Views)
Sorry, I should've posted it the first time around. I've experimented with a couple variations on this wiring and just can't seem to get the data flow. I'm feeling especially dense at this point.
0 Kudos
Message 10 of 12
(5,195 Views)