11-03-2020 08:41 AM - edited 11-03-2020 08:49 AM
Hey guys, hope you're all safe and sound.
I have a question regarding NI-DAQmx (my device used is NI USB-6341 together with LabVIEW 2016 Version 16.0) and LabVIEW.
I'm using LabVIEW to generate a voltage output, while also reading voltage input from an input channel.
Without going into too much detail, I'm basically applying an electric force (using my voltage output) to a mechanical system, measure the position/amplitude of my mechanical system, and then I want to feed this information back into LabVIEW, because the amplitude of my output should actually depend on the current state of my mechanical system.
Here's what I want to to step-wise:
I'm not really looking for code, I'm just looking for a basic strategy. Even though I'm very new to LabVIEW, I have already played around with a couple of VIs, watched some videos and checked some of the example projects in LabVIEW. I guess the main questions I want to ask are the following:
Every comment/idea is welcome. There are definitely some things I'm unaware of in LabVIEW, so I might think about this totally the wrong way. Let me know.
What I have tried:
For starters, I have tried to realize this with a constant voltage output instead of a sine wave.
So I'm basically working with DOUBLE as datatype and one single sample per while loop iteration. I can then plot the amplitude of my oscillation over the index of iteration. So if I collect 10 samples, my X-axis would just be 1,2,3,4,5,6,7,8,9,10, whereas my Y-axis is the voltage I have measured in the respective iteration of my while loop.
I realized that this is definitely not ideal, because my while loop iterations are taking a bit too long have different times in general (ranging from 0.0001s to 0.002s) I can almost certainly not use this VI and just add an additional SINE wave as my output, because I wouldn't really know what value my SINE wave should have at what iteration of my while loop. And it would not really be possible to emulate specific frequencies for my Sine wave.
I hope this is not too much text. Providing you with screenshots wouldn't help much here, in my opinion. I would be very grateful for any sort of advice/hint/suggestion. Thanks and have a great and healthy week 🙂
11-11-2020 06:55 AM
I just ran across this previously-unanswered question.
First, thanks for a nice thorough first post. That's a big head start in the right direction.
Second, I've got bad news for you. You're tackling a pretty difficult problem in real-time mechanical control for which Windows, USB, and buffered input & output are not particularly well-suited. You've got all three working against you so you may not be able to "get there from here."
Your concern about "lag" is exactly the crux of the problem and it will be most pronounced for your buffered output signal. It will never be 0 and is unlikely to get low enough (or consistent enough) for you to establish the degree of control you're after.
What kind of mechanical oscillating system are you dealing with?
What's its natural frequency when oscillating?
What kind of feedback sensor are you using?
In plain words, what are you trying to do? In other words, how would you describe the way you want your feedback control loop to work if you were talking to someone with very little technical background?
What's the overall purpose of doing this control -- what do you hope to observe and learn?
What excitation frequency do you intend?
What is your intended/desired control loop rate?
I'd recommend you do a little basic tinkering with your system using *unbuffered* input and output. This is your biggest point of leverage for reducing lag. You still have the timing uncertainty of Windows and the USB bus against you, but there isn't much you can do about those.
-Kevin P
11-11-2020 07:06 AM
Hi,
crosspost in German www.labviewforum.de!
(We came to the very same conclusion of USB setting the limits in this application…)