LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB 6009

Hi,

 

Greetings. I need to use several sensor nods for data acquisition and control of greenhouse environment. Initially, I will use 4 NI USB 6009 with temp, humidity and CO2 sensors. I am confused about the connection of NI USB with the computer.

 

1. Do I need to connect all the NI USB separately with the computer?

2. Do I need separate coding for each NI USB/sensor nod?

 

Thanks in advance....

0 Kudos
Message 1 of 18
(4,455 Views)
  1. Yes, you need to connect all USB modules to individual USB ports on your PC. Avoid using USB-hubs, because these often cause communication problems and eventually crashes of your code. Best thing to use the "default" USB ports on your PC, or if you do not have enough USB ports, use a brand PCIe-to-USB card.
  2. If you use USB-6009 devices, you need to create a separate DAQmx Task for each device. After that, you can easily access the AI, AO and DIO physical channels and program them for your need. More info about DAQmx programming here: https://www.ni.com/en/support/documentation/supplemental/06/learn-10-functions-in-ni-daqmx-and-handl... (I strongly recommend to forget using the DAQ Assistant approach! Use the proper low level DAQmx VIs, much more flexibility what you get and no playing with that silly dynamic data...)

On the other hand, I am not sure that these USB-6009 modules are the best approach for the task you want to do. Could you give more info about how many sensors and actuators you need to use? So how many AI, AO or DIO channels are required for your project? I am a bit concerned about distances and distribution of the sensors. Usually it is not a good idea to use USB-cabel "extenders", I had some issues in the past when I tried to use a 5m long USB cable extension plus the original USB cable of a NI DAQ device. I got several times driver crashes. There are some solutions like powered USB-extenders, but I believe you would be much better with some Ethernet or wireless distribution approach. NI offers different options, but of course the price range is also higher for these devices. But adding together the price of 4 USB-6009, you might be better with a 2 or 3 module cDAQ chassis?
You can check out options here: https://www.ni.com/en/shop/compactdaq.html

 

I would also consider using the cheap Raspberry PI single board computers for such task. You get a low power consumption linux board, built-in wifi and you can attach a wide range of AI (AO, DIO, etc) "shields", which can communicate to the sensors via different protocols, like I2C. I could imagine a kind of sensor network, where multiple groups of your sensors are connected to several RPi boards, and these boards could broadcast the measurement data via TCP/UDP etc back to your PC which would run LabVIEW. You can program the RPi boards with languages like Python, or even using LabVIEW: https://www.labviewmakerhub.com/

Message 2 of 18
(4,413 Views)

Hello Mr. TRUSTED ENTHUSIAST,

Thanks for your quick reply. I usually DAQassistant for coding. As you said to use DAQmx, I tried to make code but I can't understand how can I put sensor equations/formulas in DAQmx coding system. I have attached my DAQassistant code here.

 

Would you please give some guideline or links to solve the problem.

0 Kudos
Message 3 of 18
(4,388 Views)

@Chowdhury_Milon wrote:

Hello Mr. TRUSTED ENTHUSIAST,

Thanks for your quick reply. I usually DAQassistant for coding. As you said to use DAQmx, I tried to make code but I can't understand how can I put sensor equations/formulas in DAQmx coding system. I have attached my DAQassistant code here.

 

Would you please give some guideline or links to solve the problem.


"DAQmx coding system" and "equations/formulas" have nothing to do with each other 🙂 Are you aware of the basic mathematical formulas present in LabVIEW? Like multiplication?

I put together a small example for you, using a kind of Producer/consumer pattern with Stream Channel. I let you do the data manipulation/scaling and the File saving, their place is in the Consumer loop!

Here is the snippet, try to re-build it (since you have LV2017, I used a "Stream Channel with Abort", more compact than a Queue):

 

ProducerConsumerData_DAQmx1_BD.png

 

 

 

 

Message 4 of 18
(4,379 Views)

Before giving Kudos which I do not deserve! 🙂 Imagine, what happens in case of any DAQmx errors if you use my design: the producer loop will not stop, but will stop generating valid data!

So we also need to stop the top loop in case of error, and send this info to the bottom loop. Using one of the inputs of the Stream Channel Writer, like the "Abort", "Last element?" and the "element valid?" ones!

 

Message 5 of 18
(4,364 Views)

Hello Mr. Blokk,

10 days already passed. I am sorry I can't reply. I bought a "5 port PCI-E PCI express to USB 3.0 HUB Expansion Card SATA Adapter". and it works well. But the DAQmx seems difficult/hard to me. Actually, I used some sensor equation in DAQassist coding. But in DAQmax I couldn't find "Abort.vi" for putting formula/equation. I have some others problems too.

1) I already bought NI USB 6009. So I have no option to buy wireless NI products.

2) How can I add several (4 NI USB 6009; 1 CO2, 1 Temp., 1 humidity, 1 light sensor are connected with each 6009) NI USB in one DAQmx code?

 

I don't know, is it clear to you or not. Now, adding 4 DAQassist or DAQmx in one code is my target. Would you give me the suggestion, please? 

0 Kudos
Message 6 of 18
(4,309 Views)

To be honest I do not understand this sentence: "But in DAQmax I couldn't find "Abort.vi" for putting formula/equation. " You can create a formula simply using the "Mathematics" palette set from the block diagram, you do not need those Formula/equation Express VIs!!

 

For the DAQmx question: You need to create 4 DAQmx Tasks for the 4 USB6009 modules. USB6009 supports up to 4 Differential AI inputs, so I recommend to use Differential pin configurations for your sensors instead of RSE (since you need to connect only 4 sensor to each USB device). Here you can see how to wire your sensors to the USB modules: https://www.ni.com/docs/en-US/bundle/usb-6008-6009-feature/page/pinout-signal-descrip.html

Channel0 will be AI0/AI4 (AI0+/AI0-), Channel1 AI1/AI5 (AI1+/AI1-), etc...

 

I show you here a simple example, no explicit timing setup (just "on demand" sampling), only taking a single sample per channel per While loop iteration (so 4 channels X 4 devices = 16 samples per iteration), might be enough for your sensors (you can modify it to take more samples, but in that case you might need to use 4 separate While loops due to make timing/acquisition tight in the loop).

 

DAQmx_4_USB_BD.png

 

 

 

 

 

 

Message 7 of 18
(4,302 Views)

Hello Mr. Blokk,

Thanks for your patient and continuous support. Still, I have some confusion. 

1, During the use of DAQassistant, I separated the signals using "Select signal" option and the used "Formula" option to set sensor equation for getting the actual value (Picture attached). How can I separate those signals in "Consumer while loop"?

2. You told me to do math in Consumer loop's "false case". So, what about the "True case"? Should I keep it empty?

3. I also want to add "Numeric indicator" and "Waveform graph" to see the data. Should I add these at "Consumer loop"?

 

Thanks in advance.

0 Kudos
Message 8 of 18
(4,280 Views)

Hi Milon,

 

1. You get an array in the consumer loop. Which function can be used to index single elements from an array? Basic stuff: IndexArray…

 

2. Yes.

I suggest to use scales for your DAQmx channels, see the LabVIEW example VIs and this one!

This way you don't need to scale your DAQmx readings afterwards…

 

3. Yes.

 

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 9 of 18
(4,275 Views)

I really advise to take someonline tutorials for LabVIEW, you miss many of the most basic concepts and techniques of the language. You can find many links here: https://forums.ni.com/t5/Community-Documents/Unofficial-Forum-Rules-and-Guidelines/ta-p/3536495

(under section "Looking For Free Training")

 

Regarding to your questions:

  1. You do not need to use dynamic data and Express formula VIs. The DAQmx Read function gives you a 2D array of numeric values. You can use Index Array to index out elements you need. If you are not familiar even with LabVIEW arrays, really take some tutorials before attempting to code your project...
  2. In my example VI, the True case is for stopping the Consumer loop. When you stop the Producer loop, it will set the Stream Write node's "last element?"  input to True, so the Consumer will "know" about that you stopped the Producer loop (either by user, or by error, see the logical OR operator there!), so the Consumer will not process more data and stop itself. By the way, if you turn on that little yellow question mark at the top right of the Block Diagram (Context Help Window), then you will get more info about different objects in the BD if you hover your mouse over them...
  3. Yes, any indicator, Chart/Graph (do you know the difference between Graphs and Charts?? I feel you want to use a Chart here not a Graph!), data analysis/conversion, data logging, etc should be in the Consumer loop! The producer loop is ONLY for Data Acquisition.
Message 10 of 18
(4,273 Views)