LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Exporting data to spreadsheet from different states in a state machine

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.

0 Kudos
Message 1 of 13
(1,308 Views)

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. 

0 Kudos
Message 2 of 13
(1,272 Views)

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.

Message 3 of 13
(1,218 Views)

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?

 

 

0 Kudos
Message 4 of 13
(1,214 Views)

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).

  1. Open a file, get the reference.
  2. Pass the reference between states
  3. write 1 line(s) per state

mcduff

 

snip.png

0 Kudos
Message 5 of 13
(1,209 Views)

Here is the current status of my VI. Not working exactly like I'd want it to.

0 Kudos
Message 6 of 13
(1,199 Views)

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.

0 Kudos
Message 7 of 13
(1,177 Views)

Good start using a state machine but here's some advice

 

  1. This is temperature data, how fast is your acquisition?
  2. You have tons of redundant code converting each sensor to a waveform.
    1. I don't understand why you are turning everything into a waveform?
    2. Even so if you started with an array you could use a For Loop and auto index all that conversion in one loop.
  3. Don't use DDT Dynamic data wires or Express VI's
    1. Just don't 😛
    2. Lower level VI's have better control for more complex applications
  4.  Make all of  your Case/State selector Enums into a Type Def Enum!
    1. Updating the Type Def updates every selector Enum
  5. Again do you really need a Producer /Consumer?
========================
=== Engineer Ambiguously ===
========================
Message 8 of 13
(1,169 Views)

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!!

0 Kudos
Message 9 of 13
(1,160 Views)

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.

0 Kudos
Message 10 of 13
(1,146 Views)