12-18-2017 12:42 PM
Background:
I'm an undergraduate mechanical engineering student, minoring in computer science. I've been working in this lab for almost a year now. In that time I have been learning LabVIEW, but more specifically learning how to operate a myRIO and a cRIO. My job has been to recreate the VIs that they have been running on NI-DAQ systems on the cRIO. I have learned a lot, but I am also struggling a lot because I am the only one in the lab learning about the RIO devices. Therefore no one in the lab is really able to help me, so I have to turn to the forums because I am at a point where I am not sure what to do.
About the project:
I am trying to take the three main VIs they are using (the camera, the mass flow controller, and the microphone) and combine them to run simultaneously. I attached the original VIs that I have been given in case that is any help. I am using shared variables (I know it isn't the best method, but it is the one I understand the most) to communicate data between devices. Right now the VIs aren't very neat, I'm self taught in LabVIEW, so I apologize if it is hard to read/understand any tips on better organization/style would also be greatly appreciated.
Equipment:
cRIO-9035
NI 9264 (Analog out)
NI 9213 (Thermocouple, currently not using in the project)
NI 9205 (Analog in)
NI 9344 (On/Off switches)
NI 9401 (currently not using in the project)
Issues:
(1) FFT:
I'm not sure if my fast Fourier transform is done properly on the cRIO. I haven't been able to test, but I am pretty doubtfula about it. I am trying to have it operate exactly like the FFT-DAQ image attached, but I had to get creative with it for the cRIO since I couldn't use the DAQ assistant module in LabVIEW. I'm sure there has to be an easier way to do what I did, but I am not able to figure it out/find one.
Basically I need to read the voltage from the analog input (aquisition mode: N samples, Samples to read: 60k, rate(Hz) 12k, and a range +-10 Volts) of the microphone and then use that to calculate the voltage, pressure, and the sound pressure level (using subVI that was created for the DAQ systems project, but works for this one as well) along with the FFT calculations.
(2) Creating Files:
The professor I work for wants me to add a way for us to send a file of the data acquired from the last X seconds, where X is an inputted value up to the users discretion, from the cRIO to the PC. I am completely stumped for this. I'm working on it now, that's why the host.vi is broken. I think I understand how I would do something like this, but I'm not sure how I would go about doing it in LabVIEW (if that makes sense).
I think all I need to do is create an array of the values and have each value correlate with a time. Then when the user is ready to take the data, just read the values stored from the time requested. There might be an easier way, but that is all I can think of right now.
(3) Syncroniztion:
A big part of the project that I haven't looked much into, but need to start working on is syncronization. All the data readings on the devices have to be done at exactly the same time for this to be succesful. Would I need to do that on the real-time VI or the FPGA VI? What would be the easiest/best way to go about doing this?
I'm stuck on these three things and can use as much help as possible, because at this point it just seems like I am beating my head against a wall on a day-to-day basis trying to work through all of this.
Note* The main project is the "MFC Calibration FPGA"
12-18-2017 02:52 PM
In Programming, as in many other things, "Divide and Conquer". So here are some comments about various aspects:
Bob Schor
12-18-2017 03:16 PM
I'll start by confessing DAQ isn't my strength. Some of your requirements are listed in the way they're measured by DAQ so some of my implementation may need to be tweaked.
That said, let's take a look at what you're trying to do on the cRIO and eliminate some of the "noise."
Let's start by removing the modules you're not using. That gets us down to:
cRIO-9035
NI 9264 (AO)
NI 9205 (AI)
NI 9344 (Switches)
Analog input needs to be read: 60k samples, 12kHz sample rate, +/- 10V. Here's the first place you'll want to get yourself out of the DAQ mentality. You're working with the RIO here. You're sampling at faster than 1kHz, so I'd move to the FPGA rather than the RT. (Scan engine goes at 1kHz.) Place a FPGA I/O node onto your Block Diagram and set it to read at 12kHz. Read a sample each time and send it to a FIFO. Read from that FIFO in your RT VI. This handles your sample rate requirements with a trivial FPGA VI.
Once on RT, you can run the FFT to your heart's desire and see the results to verify if that looks right. Send some known test vectors and you can easily verify this.
Synchronization is easy on the FPGA. Pull down on the FPGA I/O node. Now, each thing you're reading is read at the same time.
For sending the file, is this a task that should be continuous or only happen when you push a button? Do you wish to keep track of ALL the history or do you only care about these N seconds worth of data? For creation of a file, it'll really depend on what your goal is. But, you're likely to only want a file to exist on the Host or on the RIO and never transfer that file between the two. We can look at that soon enough.
12-25-2017 08:35 PM
Thanks for responding!
I only care about the past N seconds of data. I want the data to be stored on the computer.
12-26-2017 07:24 AM
If you only care about the last N seconds and want the file creation to take place on your PC, you'll want to setup a couple of VIs.
On the cRIO, you'll want a VI that maintains the last N seconds at all times (and drops values as they become stale). You'll also want a loop that regularly listens for connection attempts from the host. If there's a connection, it works with it. If there's not, it tries to listen. This will require error handling so that you can clear the error and restart the listening if it's ever broken. The idea here is this VI can run autonomously and won't quit if you lack the connection.
On the host, you'll create the connection. At that point, you can ask the cRIO to send you all of its data in a FIFO. You'll get all the data and be able to create a file then.
01-03-2018 09:54 AM
How would I setup the VI to maintain the last N seconds at all times? I'm trying to figure it out, but I'm not sure how that would be setup
01-03-2018 10:28 AM
@atokad wrote:
How would I setup the VI to maintain the last N seconds at all times? I'm trying to figure it out, but I'm not sure how that would be setup
Look up the Lossy Enqueue function. Use that with a fixed sized queue to create your buffer. You can then flush the queue when you want to send all of the data in it.
01-08-2018 09:40 AM
I understand why I should use a lossy enqueue, but I am confused on how I go from creating the queue to creating a queue based on time