10-11-2017 05:57 PM
Hi,
I need some help regarding appending (writing) data to a file after reading the input value from all lines. So, I have came so far that it reads the inputs and can write to a .txt file. However there are two problems with current solution:
I have attached a figure of my current solution, and the attempt to switch to spreadsheet. The thing I find difficult to figure out is how I can transfer the boolean array to be appended to the file. I guess I have to use the "Write delimited spreadsheet" to append current reads with the previous but I am not able to import a 2D array from the boolean array used in the current solution.
All help will be highly appreciated. Thanks in advance.
10-11-2017 11:23 PM
Well, I don't have much experience with LabVIEW NXG, but can make some observations about LabVIEW and the File I/O functions, particularly the Read and Write Delimited Spreadsheet functions.
Bob Schor
10-12-2017 01:55 AM
Thanks for the answer. Yes, I am aware that the Write Delimited Spreadsheet function is probably the way to go to achieve what I want. However, the thing I do not understand is how I can create a 2D array that from a 1D boolean array such that the Write Delimited Spreadsheet can be used.
10-12-2017 02:13 AM
Hi salasjad,
convert the boolean array to 0/1 resulting in an 1D array of U8. Then use BuildArray to create a 2D array from this 1D array:
Btw. atleast in LabVIEW (without NXG) the WriteSpreadsheetFile function also accepts 1D arrays at its inputs…
10-12-2017 03:03 AM
Hi GerdW,
Thanks for the reply. Can I ask what the second last block is called? I am not able to find it.
10-12-2017 03:37 AM
10-12-2017 04:03 AM
Indeed I did not read your message properly. Now I am able to create the 2D array. Thanks for that.
Here comes a followup question:
I use DAQmx task to read the inputs, which returns a boolean array with the value of inputs. Let us say that I only want to store the inputs that have a high value to the 2D array. And in addition I want to store the line number (pin number) of the input. So the question is whether there is a straight forward way to store input value that are high together with the line number as a 2D array?
10-12-2017 04:10 AM
Hi salasjad,
Let us say that I only want to store the inputs that have a high value to the 2D array.
So you want to create an array containing only TRUE booleans? Use InitArray… (Yes, sarcasm… :D)
in addition I want to store the line number (pin number) of the input. So the question is whether there is a straight forward way to store input value that are high together with the line number as a 2D array?
Sure there is!
Use a FOR loop to iterate over your boolean signal array. For each TRUE bit you store the FOR loop iterator in an array to receive an array of the TRUE channel numbers…
This is pretty basic LabVIEW stuff. Did you take the free beginner courses?
You still don't attach your VI to show what you have tried so far - we will not solve your homework for you!