03-15-2018 12:07 PM
Hi sheriffff,
Glad to hear that.
Is there a reason you are preferring to go the route of using an XY graph rather than a waveform chart? The waveform chart will greatly simplify handling the data and pushing it to a graph on the front panel. The XY graph requires pairs of XY values, while the chart simply requires you to wire in a single scalar value (other methods can be used to include more than one variable on a single plot). The main downside of the waveform chart would be that the X-axis no longer becomes a user-specified variable, but rather will become sample number... if you have a consistent data rate (let's say 10 Hz), the X-axis will be fairly closely tied to a time.
For writing to a spreadsheet file, the method I usually go with is actually opening/creating a new text file before the main while loop, and then writing a csv formatted string (comma delimited data values that can be text or numbers, with a carriage return denoting the end of each line) to the opened text file reference using the "write to text file" VI block. Please see the examples in the Alicat driver library that include "Logging" in their title for an example of an implementation of this. There is also a subVI titled "Data Logging_Generate Data String", located in the Data Logging folder of the drivers, which takes data from the cluster and converts it into a CSV string using the selected variables, which you can then write to a text file.
All of the drivers also include text descriptions in their context help files, so if you are curious you can hover over the subVI and read the help text (ctrl+H will bring up the context help if it was closed).
Please let me know if you have any additional questions, and I will be happy to assist.
03-21-2018 01:41 AM - edited 03-21-2018 02:06 AM
Hi Kevin,
Thanks a lot. I tried something and I hope I achieved my goal. The reason why I made XY graph instead of waveform chart, I want to only one graph in the front panel and I want to change the shown datas in one graph. That was why I made ring constant for each data. If the waveform chart does it, it will be perfect, but I couldn't achieved to that situation. I couldn't combine the ring constant and each seperate datas. Maybe The create control for VI is the solution but still I couldn't.
03-21-2018 12:18 PM
Hi sheriffff,
I'm happy to hear that it sounds like your project is coming along well. There are a couple of ways to handle the graphing of multiple variables on either waveform charts or XY graphs. Attached is a quick example of one way to do both, where the XY chart is made to act like a waveform by only keeping N data pairs for each plot and the waveform chart is made to show only one plot at a time using property nodes.
I have set the property node write to only occur if the boolean value for which chart needs to be displayed changes. Since the property only needs to be called once to set it, it doesn't need to be called every loop and doing this could potentially help improve performance. If you get OK performance without the case selector where the property node writes occur every loop, that's fine to do as well (and will make it so you have one less variable to keep track of between loops to determine if the state has changed). Alternatively, if you end up placing this in an event structure, you can simply call the property node writes in an event case.
03-22-2018 09:30 AM
Hi Kevin;
Thanks for your all helps. I understood your approach but I couldn't reshape your true/false case in your waveform chart.It is for 2 data but I have 11 data so how can I reshape it for 11 data's true/false case? I did something different in the attached VI. But seems it doesn't work. I also tried to implement true/false case into this VI but I couldn't make it for eleven data.
03-22-2018 11:52 AM
Hi sheriffff,
Sadly, I cannot open your VI to see what sort of solution you came to because I am currently running LabVIEW 2014 (though I plan on upgrading to the 2018 version when it comes out).
Attached is a rewrite of the sample code I provided earlier that is altered to handle N data inputs and control what single variable gets pushed to the XY plot or waveform chart. It is quite possible that your solution is of the same form but even if not, this is just one way of several to get the job done and I make no claims to whether it is better than any others.
04-01-2018 05:52 AM
Hi Kevin,
Thanks a lot. Everything work well. What I did was totally different and it didn't work but your code is okey. I successfully implemented it to the VI. Have a nice day.
04-02-2018 02:30 PM
One more thing 🙂 There is concatenated string that combine the strings that comes from A and B device but I couldn't write it into spreadsheet. Actually I did but it wasn't in desired shape. With the subVI Data-Logging(generate data string) I couldn't seperate them in the text file for desired measurements. I will upload it here but you cannot able to see it :/. Will I upload it here to show you then make an adjustment?
04-03-2018 02:11 PM
The formatting performed in the example code contained in our driver download (Simplified Driver Example_Logging) should be for writing CSV data to a file as the data is taken. This is a much more manual version of the write spreadsheet subVI, where you are writing a text string directly to a file using the "write to text file" subVI.
There is another method which is a little cleaner, where you can pass either a 1D or 2D array of strings/ints/doubles into the write spreadsheet subVI and enable appending to allow it to continually write to an existing file rather than creating a new one each time. The default for that subVI is a tab delimited, but you can modify that too, if desired. Going this route, adding a header and additional data can be done by means of modifying the data array being fed into the subVI.
The write spreadsheet method can be cleaner, and I think the examples only went the route of manual text string generation because I hadn't looked into much at the time... this will likely be updated in a future version to the more streamlined spreadsheet write method as I have come to prefer that method while getting this example prepped for you. See the example I attached for a couple ways of achieving this (both using the spreadsheet write and using the manual text write).
As before, please let me know if you have any questions.
04-03-2018 05:01 PM
Hi Kevin,
I got your point. I understood the method of solution. For continuous data logging, there should be more than one for loops. However, our 'Alicat Simplified Driver Example_Multiple Devices with Setpoint_A AND B' VI, there is a while loop and I think I have to insert for loops outside the while loop but from the other side, the VI cannot work with the while and for loop at the same time I think. You gave 10 for for loop which belongs to initial string but it depends on to the while loop. I couldn't combine (implement) them into the multiple device VI.
04-04-2018 11:54 AM
Hi sheriffff,
I should have added: the example that I gave contains a double for loop. The inner loop essentially generates N data points formatted as a comma separated string of data (with a carriage return at the end), similar to what comes out of the logging subVI's that generate the header and the data. The outer loop is there to serve as an example of logging data N times, in actual use you would place the code inside your while loop so that every iteration of data acquisition gets appended to the desired file (this seemed better for an example than having it in a while loop where the file size could easily grow to be immense if left on and logging for a long time).
Basically, all of the code leading up to the pickoff for the string display is there just to generate mock data in a similar format to what the Alicat data logging string generation subVI outputs. The code after that is either saving this string directly to a file or breaking it out into and array of strings which can then be appended to a file by use of the write to spreadsheet subVI. For multiple devices (A and B), I also had an example of adding a unit ID to the data array before building a new 2D array from A's data and B's data to be written to the end of the file.
In the attached image, I have circled the code that reformats the Alicat CSV string into an array of strings. You would call this once per data string (if you have just "A" and "B", you would run this code for "A" and again for "B" to get A and B data formatted as arrays. Then, it is up to you as to whether you want to add any other info to the data arrays (elapsed time, unit ID, notes, other variables, anything - as long as it is converted to a string) and whether you want to write them both to the file at once or separately.
Please let me know if you have any remaining questions, and I will do my best to assist.