LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing more than one channel to a file using Xaincnbg VI from the Universal Library

Hi,
 
Could anyone help me with writing more than one channel to a file?  I am using the Universal Library version 5.40 with LabView 7.0 with the Xaincnbg VI.
 
With one channel everything in my program works beautifully, but when I add another channel and graph and wire it to the Write LVM only one channel ends up being written to the file.  It seems like there should be some function that works to add the two output arrays or something of the sort, but I can't seem to find it.
 
If anyone has come across this problem or knows of how it might be solved, I would really like to hear about it!
Thanks
0 Kudos
Message 1 of 12
(4,044 Views)

What is the data type that you have wired to the Write LabVIEW Measurement File? Scalar, 1D array, 2D array? How are you getting multiple channels? Does this Uinversal Library (whatever that is), have a single function where you specify multiple channels or are you using a function twice? Write to LabVIEW Measurement File will write as many channels as you want but the data has to formatted correctly. The Build Array function will take two separate 1D arrays and create a 2D array if that is what you are missing.

A majority of these questions could be avoided if you would post an image of the block diagram or the code itself. Just click the 'Browse' button below the message body (next to the Attachment box) and point to the VI or image (.png or jpg) you want to attach.

0 Kudos
Message 2 of 12
(4,034 Views)

Thanks Dennis... I'm sorry I'm not very familiar with the Universal Library functions myself (they are a lot less straightforward).  And my LabView skills themselves are not expert.

Regardless, I have attached one of my files.  If you could point out some obvious errors if you see any I would really appreciate it.  I know it's not perfect.

In response to some of your questions I basically copied all of the functions from the first channel for the second channel and wired it all to one Write LVM file.  I am trying to wire two 2D arrays to the write file, which I guess is not possible.  But if there is some way to convert these arrays, maybe what I'm trying to do would be possible.

 

0 Kudos
Message 3 of 12
(4,027 Views)
A big part of the problem may be that you have two separate loops. You have the top one with some acquisition and the file write. The bottom loop is acquiring but data is not passed out of the while loop until it finishes. And then, you only pass out the results of the very last iteration. I don't quite understand the need to convert the 1D array from the acquisition function to a 2D array but then, I'm not familiar with the DAQ board and functions you are using. I've attached a modified version of what you wrote. I had to do significan cleanup on the placement of your functions and wires. To be blunt, it was a huge mess. You should read the LabVIEW Style document that ships with LabVIEW. Go to the Help menu and select Search the LabVIEW Bookshelf. This VI may or may not work exactly the way you want but it will be closer with both acquisition functions in the same loop. There are other, more sophisticated wasy to do this but this is the simplest.
0 Kudos
Message 4 of 12
(4,021 Views)

Hi Dennis,

I appreciate your help.  I'm sorry if my file was frusterating and messy.  The reason why I was converting the 1D array into a 2D one is because this was part of a sample VI that I used, but I've tried the modified file without converting into a 2D array, and I still get the same problem.

Initially I had my set-up similar to what you sent, but thought that maybe the reason why I wasn't able to control both channels at one time was due to the fact that they appear in the same loop.  I guess this was a wrong assumption.

When I try to run the modified file I get prompted twice to save it, followed by an execution of only one channel.  An error message appears in the other channel that a "Background Operation is already in progress".  Perhaps I need a similar T/F Boolean function like what appears for the 1st channel in order to properly stop the background operation that is already in progress?

Please let me know if I can do anything to clarify what I mean further.

Thanks again

0 Kudos
Message 5 of 12
(4,014 Views)
Howdy,

It looks like you are using a Measurement Computing device of some sort. I've used some of them before myself. Even if you are using something different, your program is overly complicated. You can simplify things by thinking of your program as a sequence. Step 1) Initialize/setup the Analog Input Scan. Step 2) Read the Analog Input channels into a 2D array. Step 3) Display the data from the channels (as a chart or whatever). Step 4) Save the data if desired. Step 5) Repeat Steps 2 and 3, (and 4). You've got it mostly, but you only need one while loop, and you need to put the actual scanning inside the loop. As far as saving the data with the Write Labview Measurement File Express VI, I think if you combine all of your data into one array, it should store everything.

Take a look at the examples from the Universal Library, such as XAINSCBG.VI. See how it is a sequence... do the same with yours.

If you still need help, just bang on the keyboard!

😉


0 Kudos
Message 6 of 12
(4,010 Views)

Hi,

Yes I am using a Measurement Computing PC-CARD.  I want to continuously sample my data, so I'm making use of the Xaincnbg.  I'm not sure what the benefit of a sequence structure is in my case (other than making it much more organized).  Are you suggesting that the steps to follow correspond to separate frames in a stacked sequence?  How would I go about reading all of my analog input channels (I have three in total) into one 2D array?  Also, how would I use one while loop throughout different frames in a sequence?

I appreciate your help and your response.

Jenna

0 Kudos
Message 7 of 12
(3,974 Views)
What kind of data rate do you need from the PC CARD device?

Honestly, I don't use the scan multiple channels at once feature very often. Most of the time I only need to scan a few channels at very low rates (100-1000Hz). For that I just use multiple instances of the single channel analog input vi and put the numbers into whatever indicators I need.

I'm attaching the AIN subvi I use most of the time, as well as a quick and dirty VI for reading and saving the data. I don't often use the Write to LVM express vi either. For me, a simple spreadsheet file is fine, so I included examples of both of those.

If I get a few spare minutes, I might play around with the background scan vi. However, I don't have the MCC device with me at the moment, so I can't test it. If you still have any problems, don't hesitate to ask!

B-)
0 Kudos
Message 8 of 12
(3,954 Views)
Oops, forgot to attach the files...

And, pics of the VI's, in case you don't have LV8.2


Message Edited by LabViewGuruWannabe on 05-22-2007 06:15 PM

0 Kudos
Message 9 of 12
(3,951 Views)
Picture of the block diagram for the subAIN.vi

B-)
0 Kudos
Message 10 of 12
(3,948 Views)