LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding different types of elements into Data Array

Here is the code.  I included profile.txt file that is what the vi is reading, converting it to hex, and then trying to write the hexademical data to file. 
Download All
0 Kudos
Message 11 of 20
(1,356 Views)
So the problem here is that you are writing out all the columns and rows using the array to spreadsheet string, along with the end of line characters that indicate a new row, and then want to add another column. When you look at the data in a spreadsheet it looks like there should be some easy way to just add another column of data but in reality your text file would look like 3, 5, 5, \r\n, 4, 6, 7, \r\n.  Each element in a new row would have to come before the \r\n.

You are going to have to do index through your 2D array, format each 1D array into a string using the Format Into String function, then do the same for the hex element for that row, then concatentate the two to have your complete row, and do this in an auto-indexed for loop to build your 2D string array, then use the Array to spreadsheet function or Write to Spreadsheet function.
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 12 of 20
(1,341 Views)

Doug-

Thanks for looking at the code.  Can you edit the code with what you are talking about doing, I am not totally sure on what to do, and how to implement it into the rest of the code. 

0 Kudos
Message 13 of 20
(1,334 Views)
Attached is what I think you were telling me to try.  Its making data in rows, and cant figure out how to get it into columns. 
0 Kudos
Message 14 of 20
(1,323 Views)
Hi, at first glance it looks like you are doing basically the right thing.

As a general tip for getting better results when posting questions to the discussion forums, it is a lot easier for someone to look at code and suggest a workaround or solution if the specific problem you have can be posted as a code snippet that is actually runnable and demonstrates the problem you are seeing -- I think the formatting issue you are seeing is probably fairly simple to resolve, but I cannot run your code and see what the problem is since I don't have the Traditional DAQ driver installed on my machine, nor hardware to obtain data.  Could you create a simple test VI that contains dummy data in the form of pre-defined controls or constants and that uses only the small portion of code in question that creates the spreadsheet data you are looking for, in such a way that someone can open the VI, click the run button, and see the problem you are seeing?  Then hopefully we can suggest a solution that will help get you on your way!
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 15 of 20
(1,311 Views)

Doug-

I ended up upgrading our current package of Labview to include support, and the support department worked with me and we got it working.  Basically what you said.  Index through each channel, convert each data channel (decimal into string), build array, transpose array, then array to spreadsheet.  I was so close but yet so far away.  Thanks again for taking your time.

0 Kudos
Message 16 of 20
(1,309 Views)
Great!

I'm glad to know you were able to work things out.

Here are a couple of great tutorials on ways to improve LabVIEW code:

Rules to Wire By -- Part I
Rules to Wire By -- Part II

Always wiring from left to right is a great practice and makes code a lot easier to read.  Best of luck in your project!
Doug M
Applications Engineer
National Instruments
For those unfamiliar with NBC's The Office, my icon is NOT a picture of me 🙂
0 Kudos
Message 17 of 20
(1,299 Views)
Hello All,

I have been trying to setup a text file that has two columns of data that are of different types, Specifically I am reading position from a motor and power from a meter.  I have a couple pieces of code that I wrote that kind of get me what I want but for some reason it only records the latest reading and doesn't continue to write further data to the file.  I have attached what I have in the hopes that some one can help guide me through my problem or even modify what I have written.  Any suggestions would be greatly appreciated. 

Thanks,
Rafael
Download All
0 Kudos
Message 18 of 20
(1,077 Views)

This past has nothing to do with the topic of the old thread, so you probably should start with a new thread.

I would recommend to do some LabVIEW tutorials first, because your code makes very little sense and has some hair-rising code constructs!

I must say I have never seen the iteration counter of a while loop connected to the N of a FOR loop, especially in a case where there is no wait. The FOR loop repeats the same operation N times, overwriting the previous data. In the "rr.." file you have stacked while loops with no waits and the inner loop does nothing but format the same old data over and over again as fast as the CPU allows. If the inner loop stops, the outer loop stops too, oso the outer loop has no purpose. Right? Stacked FOR loops with one iteration each is also not very productive.

All you need is a single while loop. Open the file before the loop, then keep appending inside the loop at the current file position, and close the file after the loop.



Message Edited by altenbach on 06-12-2008 12:43 PM

Message Edited by altenbach on 06-12-2008 12:45 PM
0 Kudos
Message 19 of 20
(1,073 Views)
Thanks,

I was able to come up with something, thanks for your help.

-Rafael
0 Kudos
Message 20 of 20
(1,060 Views)