LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to read voltages from 4 sensors using LabVIEW and NI USB-6009 DAQ board?

Solved!
Go to solution

Hello dear LabVIEW community.

 

I have 3 pressure transducers (Omega PX409-015G5V, Omega PX309-002G10V, MKS Baratron 750C13TCE2GK)  and 1 flow meter (Omega FPR303). All of them output voltages. With the transducers I just want to read voltages and save them to an Excel file, with the flow meter - which is a turbine type flow meter - I want to read voltage, convert it to frequency and then save it to an Excel file.

 

I wrote separate LabVIEW programs for every sensor, tested them and even calibrated the sensors with them. Everything worked fine like I wanted.

 

Then I figured out that I had to combine them to one LabVIEW program in order to run all the sensors simultaneously.

That's where I have problems and that's what my question is about: how to combine them all into one program.

 

I've tried two ways.

 

The first way was suggested on the LabVIEW forum. It was about mere copying the 4 sensors' programs into one program. And that one program would have 4 separate while loops. That didn't work. I had some error about DAQmx. That error was mentioned in the suggestion on the forum. So, I abandoned that way.

 

Then I found another suggestion on ResearchGate. I created one while loop and one DAQ assistant for all the sensors. Within the DAQ assistant I created the channels for each sensors. Turned out, the DAQ assistant would output data from all the sensors simultaneously and I had to split the data after the DAQ assistant. I added a "convert from dynamic data type" vi, then I added an "index array tool" to split the data. Then I added "convert to dynamic data type" to read the voltages.

 

And nothing works. I would start the program, it would sit for a while and would give me an error.

 

The worst part is after I got the error from the combined program, the separate programs for each sensor stopped working and started giving me the same error.

 

I'm wondering if anybody can have a look at my code and say what's wrong with it, please.

 

The specs are as follows.

  • LabVIEW version 21.0
  • DAQ board is NI USB-6009, I'm using AI channels (all of them: two pressure transducers and the flow meter have two signal wires, one pressure transducer has one signal wire)
  • Computer is HP Z220, Intel Xeon, CPU E3-1240 V2 @ 340GHz, RAM 12GB, 64bit operating system, x64 based processor
  • Windows 10 enterprise, version 20H2, OS build 19042.928, Windows feature experience pack 120.2212.551.0
  • 4 separate .vi programs for each of the sensors and 1 combined .vi program for all the sensors are attached
  • The screenshot of the combined .vi is attached
  • The screenshot of the error is attached, the error number is 201003
  • Troubleshooting steps attempted: tried to play with the rows and channels in "convert from DDT" vi.

Thank you in advance.

Ivan

0 Kudos
Message 1 of 3
(2,315 Views)
Solution
Accepted by topic author nepomnyi

Alas, another LabVIEW user who has been misled by the Dreaded DAQ Assistant,A its evil twin, the Dynamic Data Wire.  Please open a Web Browser and find and read "Learn 10 Functions in NI-DAQmx and Handle 80 Percent of your Data Acquisition Applications" (I've mentioned this so much I'm 95% certain that this is the actual title of this excellent NI White Paper).

 

Ignore the first point, which mentions the Dreaded DAQ Assistant.  You should never use it.  Here's how to get started "the right way":

  • Connect your USB 6009 to your sensors, and plug the USB line into your PC.
  • Open MAX.  Do you know about MAX, the Measurement and Automation Explorer?  Whenever you have a new device, you should "plug it in" and explore it with MAX.
  • Click on your USB-6009 and open up a Test Panel.
    • Define an Analog Input Line for one of your sensors.  Set it up (like you set up the DDA (Dreaded DAQ Assistant) specifying the Channel, the Range,  Set "Acquisition Mode" to "Continuous", which means "As so as multi-sample input is finished and the data are available, start the next so no samples are lost".
    • Set "Samples to Read" to 1000 and the Sampling Rate to 1 kHz.  This means that once a second, you'll get 1000 data points.
    • Try to run this (push the "Start" button in MAX).  You should see, once a second, a burst of 1000 points.
    • If this looks more-or-less right to you, remember how you created this Test Panel.  Now create a Task -- you'll do more-or-less the same steps as before, but now you'll save it as a Task (choose a better name than "MyDAQTask").  Be sure to Save the task.
  • Now build a VI. 
    • Drop down three DAQmx functions -- Start Task, DAQmx Read, and Stop Task, in that order, left to right.  Connect the Task Wires and Error Lines between them.  Drop a Constant on the upper left corner of Start Task -- it will turn into a Task Constant.  Click the little triangle, it should show you the Task you just created in MAX -- select it.
    • Drop a While Loop around the DAQmx Read, and tunnel the Task and Error lines through the left and right edges.  Configure the DAQmx Read to Single Channel, Multiple Samples, 1D Waveform (Samples).
    • Wire a Stop button to stop the While Loop.
    • Run the program.  Look at the Chart.  Wow!  (You may want to not let the Y axis auto-scale).
  • That was a "One Channel" A/D Task.  Go create another task with four channels for your 4 sensors.  Give the task another name.
  • Modify your VI by changing the DAQmx Read to Multiple Channels, Multiple Samples.  Try it.

Here is the One Channel A/D VI I just built (yours should look similar):

Simple DAQmx Routine.png

Give it a try.  Your code for your 4 channels into the USB-6009 should look (almost) identical to the above (except it is NChan NSamp, and a different Task name).  Note that the 6009 is sampling all 4 channels at the same time, keeping them separated and organized for you, and you can just plot it (or do whatever you need).

 

Bob Schor

Message 2 of 3
(2,278 Views)

Thank you very much, Bob.

I accepted your answer as the solution: it seems clear, but I haven't been able to proceed beyond the third bullet point.

When I opened MAX and expanded the devices list, I noticed a worrying red circle with a white cross next to the symbol of my DAQ. And then I saw this message: Error status code: -88705. I have attached the screenshot.

I don't think that's something good. I've been looking all over the place for the test panel you talked about and couldn't find it.

I think something had happened to my DAQ.

Like I mentioned in my original post, my separate codes for each sensors worked fine. Then I wrote that all-in-one code, ran it and got the error. Immediately, I tried running separate codes and they started giving me the same error. I think I broke my DAQ with that all-in-one code. Do you think that is a possibility?

Thank you.

Ivan

P.S. For those like me who doesn't know what MAX is, double click on the LabVIEW shortcut on your desktop. Go to Tools. The first line there is MAX.

 

----------------------------------------------

UPDATE.

I panicked too early. My DAQ is working. I deliberately don't delete this post in case another person experiences the same issue. I found two posts: this one and this one. I followed the second post primarily. I rebooted the computer having my DAQ plugged in. I suspect that solved the problem, but I didn't try my DAQ after the reboot. Instead, I went ahead and did the manipulations with NI device loader as prescribed in the second link (note that it wasn't that clear how to access that, I ended up typing administrative tools in the Windows search bar and it opened up a folder for me where I could locate services). Then I just opened NI MAX and saw my DAQ there without any errors. The test panel Bob talked about is now there in NI MAX.

0 Kudos
Message 3 of 3
(2,228 Views)