12-22-2020 03:28 PM
I'm looking for some help exporting data out of multiple different states in a state machine.
I'm unsure how to go about gathering the measured data from multiple different states into a single wire of data that i can then export to a spreadsheet. Say state 1 generates 7 data points, state 2 generates 7 data points, state 3 generates 1 data point, state 4 generates one data point, and state 5 generates one data point. I want to gather all these data points together and write them to a spreadsheet (maybe using a consumer loop?) at the same time, before the state machine goes back to state 1 and starts taking data again.
Appreciate any help.
12-22-2020 05:27 PM
If I use merge signals in the while loop with the state machine and merge signals (waveform of data points) and enqueue that I get a spreadsheet where each horizontal row across are the data points from a single state. So row 1 in the spreadsheet is from state 1, row 2 is from state 2, row 3 from state 3, etc. I would like everything to either write to spreadsheet at the same time or write such that state 1 is columns 1-5, state 2 is columns 6-10 etc, and they fill downward.
I'm not sure I have the experience to do this properly.
12-23-2020 09:03 AM
It would help if you post what you have.
'Data point' is ambiguous.
If all data are doubles, simply keep an array in a shift register. Each state can use build array to add to it. The write state adds it to the spreadsheet (file? workbook? indicator? array?) and clears the array.
12-23-2020 09:16 AM
Thanks for your reply!
I will try and get what I have posted, right now I'm not at my computer with LV.
It is ambiguous, by data points I mean mostly temperatures with a few other doubles.
So each state has a build array and it's own shift register for the data? Do you build an array of all the arrays in the write state?
I was trying to incorporate a consumer loop for the writing. Can I enqueue the arrays in a state so they can be written in the consumer?
12-23-2020 09:50 AM
If you are only writing a few points per state and you don't have any tight timing requirements look at the "Format into File" primitive (Exactly like format into string, except for a File).
mcduff
12-23-2020 10:59 AM
Here is the current status of my VI. Not working exactly like I'd want it to.
12-23-2020 12:22 PM
Here is an updated VI. It seems to be more on the right track, but I'm not getting data from one of the states. The spreadsheet creates 16 columns, but only 8 are filled with data.
12-23-2020 12:49 PM
Good start using a state machine but here's some advice
12-23-2020 01:13 PM
Hi RTSLVU,
1. The acquisition rate is variable depending on the usage, but anywhere from every second to every minute is probably the right range. And the data collection could go on for days at a time. So not very fast.
2. I think I did it to get a time stamp with the data? It was months ago that I wrote that code, and I took it from another VI, so I don't exactly remember what I was thinking. But I do need to plot the data with a time stamp. I've never done it with a For Loop
3. Fair enough. It's really the only way I know how to get my data into a spreadsheet at the moment. I haven't had lots of success with the lower level VI's for writing to a file.
4. I will change!
5. Maybe not, but this made the most sense to me.
Appreciate your thoughts here!!
12-23-2020 03:27 PM
So I made some of the changes suggested. Some I still need to work on because I've never done it before. I tried TDMS streaming, it was suggested to be on a post I made awhile back.
I'm still not seeing all 16 data points however, not sure exactly what the issue is.
Attached is the update VI
Appreciate any and all help.