04-27-2023 04:48 PM
Hello working on a project for school but are running into some trouble. This is my first time using labview so I am not very familiar with it. We are trying to build a equalizer using labview. The first thing we wanted to get working was to use the headphone jack output from my phone into NI Elvis II analog inputs then using the analog outputs from NI Elvis II to a amplifier out to a speaker. We used two DAQ assistant modules on our block diagram one set up as a input going to analog input 0 and one set up as an output going to analog output 0 on NI Elvis II. We do get sound output sometimes but it is delayed by like 10 seconds and other times it just throws up error messages or it wont start all together. We got the idea from a website which I will attach below we followed the same settings they used as well but labview can't keep up with. I will attach pictures of our block diagram and settings below let me know if you need anymore information.
https://blog.studica.com/graphic-equalizer-labview-2017
Thanks in advance for your help.
Daniel
Solved! Go to Solution.
04-27-2023 09:41 PM
Hi, Daniel. From your picture of your LabVIEW code, I know you are using Express VIs, but I can't "examine" the code (so I can't tell how you've configured it, nor can I advise you on how to fix it), and I also cannot "test" the code in the "picture".
I also cannot tell what version of LabVIEW you are using. If you're "new" to LabVIEW, you may be using the "latest version", and many of the "old hands" are still running LabVIEW 2019 or 2021. Are you using a LabVIEW "Project"? If you'd included the .lvproj file, we could at least know your LabVIEW version.
Suggestion:
Bob Schor
04-29-2023 12:07 PM
Hi Bob,
Thanks for getting back to me, I only have access to labview at my school and I won't be back there until Monday. But I have the VI that we were using for our tests which I will attach bellow. Also not sure what version of labview they are using at my school but I can check that on Monday if thats something you need. Thanks in advance for your help.
Daniel
04-29-2023 10:01 PM
Daniel,
Thank you! You are running LabVIEW 2021 (which, fortunately, I have installed on one of my PCs, so I can open your VI, which consists of two Express VIs (not useful for what you are trying to do), and explain many of the problems you are having. And it also tells me that you have not learned the "Three Rules of Data Flow" (the programming paradigm that LabVIEW uses).
Here's the basis of Data Flow. First, there are "things", and "wires". "Things" include Functions (like "Add" or "Write Text File"), Structures (like a Case statement, a While or For Loop), and VIs (or sub-VIs) that you might write. "Things" usually have "Inputs" and "Outputs" -- data comes into the "Thing" through its "Inputs" and goes/ out through its "Outputs" (you can have zero or more Inputs or Outputs). "Wires" carry data, can go into and out of "Structures", and can go from the Output of a "Thing" to the Input of another "Thing". Got that?
So what are these "Three Rules" (that's what I call what comes next)?
So I looked at your first DAQ Assistant, which is reading Voltages. You have set it up to take Continuous Samples (good, you don't want the data to be "interrupted" between samplings), acquiring 50,000 of them at a frequency of 44.1 kHz. It is connected by a strange wire, a Dynamic Data wire (which I never use, though, when they were first introduced, I tried them for about two weeks, then swore "never again!") to another DAQ Assistant (I call these the "Dreaded DAQ Assistant", or "DDA" for short) that accepts 10,000 data points and writes them out as a Voltage signal. I don't know what device you are using, but it appears that the data rate for output might be 1 kHz.
And finally, there's a Stop Button, wired to the Stop input of the first DDA, with its output going to the Stop input of the second DDA, and the final output going to the Stop Control of the While Loop.
So let's talk Data Flow. Assume you start the program with the Stop button not pushed. The While Loop starts, the first DDA starts, it collects 50 k samples at 44.1 kHz (which takes 50/44.1 = 1.13 (approx.) seconds, then puts those samples into the Dynamic Data Wire (DDW?). At this point, DDA #1 can start generating the next batch of 50 k samples. Meanwhile, DDA #2 accepts 10,000 (or 1/5 of the DDW's content) and starts playing it out at some rate (which might be 1 kHz). This takes 10 seconds, right? And that's only 1/5 of the data, so it will take 50 seconds to output the first 1.13 seconds of sampled data.
But we're not done -- there's the Stop button to consider. We assumed it was not pushed when we started, but let's say you pushed it 1 second after you started this routine running. Will this value be transferred to the While Loop's Stop Control? Remember the Third Rule -- everything in the While Loop that is not connected output-to-input runs "simultaneously". But the only thing that is not so connected is the Stop button, so it runs first, and when it does, it is not pushed. So it puts "False" on the input to DDA #1, which 1.13" later puts "False" on the output of DDA #1, which puts False on the input of DDA #2, which 50 seconds later puts False on the Stop Control of the While loop, so the Loop tries to run again. The second time, the Button has been pressed, so after another 1.13 + 50 seconds, the While loop will finally stop.
Some of my timing might be off because I don't know what device you are using, but you see the problem, I hope. But not to worry -- if you learn a little bit more about LabVIEW, you can sample DVD Audio (44.1 kHz) and play it out through speakers (with a faster D/A converter, like in a Sound Card) without a 50 second "lag".
To get a sense of how to wean yourself from the DDA, do a Web Search for "Learn 10 Functions in NI DAQmx and Handle 80 Percent of Your Data Acquisition Applications". Ignore Section 1, which talks about the DDA. I haven't looked at this White Paper recently, but as I recall, it tells you "How To" do things in LabVIEW and in other languages like C and C++ -- pay attention only to the LabVIEW sections.
Here's a little exercise to get you thinking Data Flow and learning the Joy of LabVIEW.
That's all for now.
Bob Schor
04-30-2023 08:41 AM
Hi, Daniel.
After a good night's sleep, I re-read your initial post, and this time, I "listened to what you said". You are clearly asking about processing a sound signal (I can say "I knew that", because I recognized the 44.1 kHz sampling frequency, but my brain wasn't fully functioning).
Forget entirely everything to do with DAQmx, Express VIs, etc. (though it's not a bad idea to read that long post of mine and be sure you understand the concepts I was trying to get across). You are dealing with sound, a particular type of data that LabVIEW knows and understands. Open a blank VI, and go to the Block Diagram. Right-click to bring up the Palettes, and notice one called "Graphics and Sound". Open that, then open "Sound".
The functions in the "Input" sub-Palette are designed to work with the "Sound In" (or microphone) port on your computer (and sample at 44.1 kHz), the ones in Output are designed to work with your Speakers (and also can handle that data rate), and the one called "Files" is for (well, I'm not going to give it away, I'll let you discover what's inside there for yourself). Unfortunately, NI made the "Acquire" Express VI output the Waveform data in Dynamic Data format, then has the audacity to tell you in the detailed Help "Returns the data this Express VI acquires from the selected device using the setting you specify in the configuration dialog box. You can convert this output to a waveform or one-dimensional array of waveforms (one per channel) by using the Convert from Dynamic Data function".
05-02-2023 09:46 AM
Hi Bob,
Thanks for all your help, you are very knowledgeable when it comes to labview. I am going to test everything tonight in class I'll let you know tomorrow if it works.
Thanks again,
Daniel
05-02-2023 07:55 PM
@Danwei98 wrote:
Hi Bob,
Thanks for all your help, you are very knowledgeable when it comes to labview.
Not so much "knowledgable" as "experienced and still learning". I had been doing programming in conventional (text) languages (my favorite was Pascal), so had some experience with data structures and code organization, plus a colleague who worked with me to show me the rudiments of LabVIEW. I was thrown in to maintaining (and eventually completely re-writing) a LabVIEW Real-Time routine in LabVIEW 7, and learned additional tricks (like "hold down the Shift key to make the Arrow keys move LabVIEW Objects around the screen 8-times faster") from our Graduate Students.
And when confronted with a function or situation I didn't quite "get", it's so simple to type ^N, spin up a blank VI, and write a tiny Test routine to see how something works. I also learned about the Examples that Ship with LabVIEW, and in a few cases, I've written (and Posted on the Forums) "Revised" versions of these Examples to try to show how to use certain LabVIEW features. "Learn by Doing".
Bob Schor
05-02-2023 08:11 PM
Indeed I always love learning something new even if it is a struggle at first. I followed your other post step by step and finally got it working it was much simpler than I thought its always a great feeling to finally figure out something you been struggling with for weeks. One of the programming languages I have had the most fun learning is BASIC just started learning it a couple of months ago as sort of a hobbie haven't had much time with it lately but will get back into it this summer. It been great talking with you and thanks again for all your help.
Daniel