04-14-2018 04:50 AM - edited 04-14-2018 05:06 AM
Hi Kevin,
I did like that in the png file at the below but it didn't work. I also tried the second way that you suggested but it gives error too. It would better do it like the second way(seperate A and B and write them into the same file ). I can't add while loop into the main while loop. Can I? I couldn't implement that into that main VI. How can I overcome that problem? Can you help to that issue?
Here the other way,(desired one) but again I doesn't work. While loop into a while loop is meaningless and nonsense. I put data loggings option and file dialog express vi outside the main while loop. I couldn't understand your guidance by the way. I tried many possibilities. 😕
Sincerely.
04-16-2018 12:45 PM
Hi Sheriffff,
I believe we're hitting a wall based on a communication failure between what the examples are supposed to indicate and how you are trying to apply them. Hopefully we can clear this up.
First, the examples included in the VI I uploaded were supposed to help show how to convert the data strings you had into something usable when saving both to a file. There was a double for loop and a while loop. The outer for loop was to act as an example of your main while loop (set to iterate a set number of times rather than indefinitely, in order to produce a small file rather than a file that can potentially grow to be huge), and the inner for loop was to generate a set of fake data in the format that the Alicat "Generate Data Logging String" VI's would output. The circled portion in the image below is the inner while loop, and you can see that the string output labelled "data string similar to Alicat data logging format" is supposed to produce a CSV formatted data string just like the one the Alicat subVI generates:
The While loop inside of the main for loop of the example program is a reformatting loop, and is not a for loop because it will iterate until there is no more data present:
The two options provided in the example are just examples of how this can be done. Essentially, you are either wanting to write 2 CSV formatted strings into a text file (using the write to text file method) OR you are wanting to do the same thing but use two arrays of strings being appended as a 2D array into the file using the write to spreadsheet method. Both are doable, but require you to make them work in your own code.
Here's what option 1 may look like:
and here's what option 2 might look like:
Which route you choose depends on what you want to do, though both should reach the same point. The double for loop should be completely removed when trying to place this into your existing code, as the outer is trying to mimic your main while loop in the example document and the inner is used to produce faux data (which is now redundant in your actual program because you have real data to use in its place). The while loops and associated reformatting code are only needed if you go with option 2, the spreadsheet write.
Please give those a shot with the new view of the example VI as being a rough guideline of how to coerce a CSV formatted data string (or a pair of them) into something that you can use with either the write to text VI (what it was designed to use) or the write to spreadsheet VI (set to append rather than replace). Going with the spreadsheet write, you can even branch out from the comma delimited format into whatever you prefer by altering the delimiter string input.
Feel free to let me know if you have any questions, and I'll do my best to assist.
04-20-2018 07:24 AM - edited 04-20-2018 07:32 AM
Hi Kevin,
I got your point. I did well but because of Data Logging_Generate Data String subVI, the excel file's writing changes w.r.t choosing what kind of data we want to collect. I mean for time cell in the excel file when ı choose for example pressure, it shifts to right and when you look down from the head of the file, you see some some time value and the pressure value in the same column. So it shifts whether you choose the determined data value or not. Is there any way to do the constant data names and write or not into that column? Lİke that;
What I get when I change the data logging e.g. I dont select some value at the beginning of test bec. I dont want it at the very beginning but later I want to select that then the excel file be like;
And I don't understand the ID type was like that? It should go down as Argon/Hydrogen but when I did that I mentioned above, it writes Hydrogen near to the Argon? Is no selecting data while the VI is running the only solution ? I want to fixate measured data and write the only selected ones. The rest of unselected ones should be nothing in the excel.
And one more thing. I couldn't understand the data logging issue.Below there is the original type but it isn't work.
Then I change it into only log data in the below figure.
I am not sure you like this style of writing. If you don't like it I can changed it immediately.
Sincerely Kevin.
04-20-2018 11:14 AM
Hi Sherifff,
No worries.
What you're looking for sounds to be a logging scheme where you are actively selecting the variables to write, and need the columns to remain static. The data being written into the file in odd orders looks like the two devices have different sets of data that you are trying to log (as in: the data being written from A and B might have different numbers of columns). As the example code is not set up for that kind of logging, or logging where the number of columns can change at any time, I would recommend building a new logging VI for your specific purposes.
I would suggest starting with something like this example. Instead of writing an array of doubles, you can convert all data beforehand to strings and write in an array of strings (this will make handling unit ID's, gases, etc. much easier).
For that to work with a selection of what data to write, you can alter the data string generation VI to output an array of strings based on your selections or write a new VI to accomplish this. If going with a new VI, you can do an "unbundle by name" for each selected variable and pass along a constant (0 or empty string constant) for the ones that are not selected (thereby maintaining the positions in the CSV file even if the data you log changes).
To add any additional info like the unit ID's, you would then only need to use the build array subVI from NI to prepend/append to the string array you're writing.
Going this method of writing string arrays (you can either do a single write of a 2D array or 2 sequential writes of 1D arrays, whichever you prefer) should allow fairly easy control of custom formatting choices you may want to use.
As for the removal of the error line check: this likely indicates that you're experiencing an error at some point in the communication line and that it is skipping over the string generation because it assumes that we have lost communication.
Let me know if you have any questions, and I will do my best to assist.
04-23-2018 02:02 PM
Hi again Sherifff,
I hope all is going well. Over the weekend, I realized that there was potentially another way to more easily achieve your desired outcome (keeping the header static and altering what data is written). If you force all data write selections to be true (enabling everything that you will potentially want to write), then the data string that is generated will be static. In places where there is no data, it should either display 0 or NaN, depending on what the default value is. This means that the write to your file should contain a fixed number of columns, where nonexistent data is filled with 0's or NaN's.
If writing two different devices with two different sets of variables, you should select the superset of options that includes all the variables you wish to write from either device. This will help prevent every other line from being a different size. Alternatively, if you wanted a single line to have "A" data followed by "B" data in a single row with multiple columns, you can concatenate their strings together (and remove the carriage return constant that's in between them).
There are several options, but I wanted to give you this info in case it makes life easier when trying to accomplish your data logging scheme.
04-24-2018 07:27 AM
Hi Kevin,
I looked at the link that you sent to me about writeng csv file. In your second message "If writing two different devices with two different sets of variables, you should select the superset of options that includes all the varables you wish to write from either device. ", I couldn't understand your point. What is super set? And so it shouldn't be like in the example? I tried something according to that example but still I have the same type of error. If you want I can send the snippets about my code?
Sincerely.
04-24-2018 08:36 AM - edited 04-24-2018 08:49 AM
Here what I did for block diagram is shown below;
Block Diagram
And here is the result in excel file;
Undesirable Result
It perceives the data types(pressure,mass flow etc.) as a text file ,not a cell of excel file and it takes all of them with together. I mean It doesn't write the type of data into each cell and when still the previous problem remains. When I don't select the data type it shifts. So it isn't shown systematical like in the link that you send. Morover, it doesn't show fixed number of columns, where nonexistent data is filled with 0's or NaN's.
Extra: I tried Write delimited spreadsheet file vi. instead of write to spreadsheet file vi. but again it doesn't work. I am waiting and appeal for your help.
Sincerely.
04-24-2018 10:45 AM - edited 04-24-2018 10:46 AM
@happinesss wrote:
Hi Kevin,
I looked at the link that you sent to me about writeng csv file. In your second message "If writing two different devices with two different sets of variables, you should select the superset of options that includes all the varables you wish to write from either device. ", I couldn't understand your point. What is super set? And so it shouldn't be like in the example? I tried something according to that example but still I have the same type of error. If you want I can send the snippets about my code?
Sincerely.
Hi Sherifff,
By superset, I meant that the CSV file you're trying to write should have the data selections made such that it includes the desired data from both devices A and B. An example of this is if you just want gas, setpoint, and mass flow from unit A, and absolute pressure and temperature from unit B: you would then want to select the data to log for both units A and B to contain gas, setpoint, mass flow, absolute pressure and temperature. The file would then contain all data variables you need and you would just have to ignore unnecessary ones when performing any post-processing (like the gas from unit B).
The error where you needed to remove the error flag and the or clause from the input side of the data generation VI indicates that there was an error in the communication at some point prior and it assumed that the data is no longer either present or trustable.
04-24-2018 10:58 AM
@happinesss wrote:
Here what I did for block diagram is shown below;
Block Diagram
And here is the result in excel file;
Undesirable Result
It perceives the data types(pressure,mass flow etc.) as a text file ,not a cell of excel file and it takes all of them with together. I mean It doesn't write the type of data into each cell and when still the previous problem remains. When I don't select the data type it shifts. So it isn't shown systematical like in the link that you send. Morover, it doesn't show fixed number of columns, where nonexistent data is filled with 0's or NaN's.
Extra: I tried Write delimited spreadsheet file vi. instead of write to spreadsheet file vi. but again it doesn't work. I am waiting and appeal for your help.
Sincerely.
Hi again,
From the snippets you sent, that looks to be a valid approach for getting the data out of the comma delimited data string format and into a 2D array format that you can write to a spreadsheet. The next step would be to check the file extension of your "File Name" control: my guess is that it would be a ".txt". Changing this to a ".csv" format should help with opening in Excel.
I had actually forgotten that the default file type in that example is a txt file. That was one of my first implementations of data logging and I had not realized that the txt vs csv would be so problematic. For any data that is logged with a CSV format (comma delimited with end of line characters marking the row end) and a "txt" extension, simply changing the extension to "csv" will make it open with no issues in excel. It can also be imported into excel using the import data feature, but the extension change is much easier.
This will be fixed in an update I have planned, but I do not know when that release will happen.
04-25-2018 03:21 AM
Hi Kevin,
Thanks for replying and everything. I did something and I am still trying to manage this problem. I have many test program that contains many different approach to that problem and it becomes complexier than I estimated. I did one part but meantime the other part is gone bad. Your suggestions and your comments are which I desire to achieve. If you helped me to get out of that scrape, I will appreciate it. I took your time and sorry about that and I appreciated already so far. By the time you turn back, I will study on it and try to solve the problem.
Sincerely.