LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Headers for Write to Measurement File

Hello,

 

I am trying to output a data from labview to excel and I am having a hard time removing the default labview header.  I would like to just have columns of data with the name of what the data is at the top of each column, but from what I gather I cannot do this with the Express VI "Write to Measurement File".

 

The closest example I have found is the Write to Text file VI, but I do not know how to change my dynamic data to the appropriate data type to be used here. 

 

If someone could help me out, I would appreciate it very much.

 

 

0 Kudos
Message 1 of 21
(4,331 Views)

Over on the left, you're using "Convert from Dynamic Data" to get arrays of numbers.

 

What happens if you feed those arrays into a "Write to text file" function?

 

I also noticed that you have a lot of repeated code.  For each signal, you convert it and then take the mean.  I took the liberty of putting that into a loop so you only have that code written once.

 

I'm missing a subvi, so I can't run it.... but let me know if this helps.

 

 

0 Kudos
Message 2 of 21
(4,321 Views)

On further investigation, I think I may have "cleaned up" your prorgram a little too much.

 

Try this version and tell us how it works.

 

I've never tried to use this method to address signals before, so I'd like to see how it works.

0 Kudos
Message 3 of 21
(4,317 Views)

I suggest a simpler modification of LandBelenky's code: convert the Analog Voltage In (Express) VIs to DAQmx code (right-click to do this).  Move the task initialization outside the loop on the left, and DAQmx Clear Task outside the loop on the right.  Leave the Analog Input inside the loop, but change it to return a 2D Array of DBL instead of a Waveform.  I never remember whether signals are in rows and samples in columns or vice versa, but you might need to transpose the array.  From there you feed the 2D array into the for loop, auto-index out the rows and take the mean of each.

 

Also, as for the header, instead of having one huge string you might consider using an array of strings with one element per column.  Use Array to Spreadsheet String to convert that to a single line of text before writing to the text file.  Somewhat easier to read than the huge string you have now.

0 Kudos
Message 4 of 21
(4,305 Views)

Hey,

 

Sorry for the delayed reply, I have just had a chance recently to try working on this again and I appreciate your help very much.

I fixed some errors I had concerning the analog inputs, but I do not understand what the for-loop is doing, so I am a bit at a loss to fix it.  Could you please explain to me what the signal selector is supposed to be doing? 

I am assuming it lets me choose the incoming signals, yet I do not see all the signals that should be there. I expect there to be 11, but I only see 8.

 

Thank you very much for your time and help.

 

 

 

0 Kudos
Message 5 of 21
(4,259 Views)

Please attach your code.  I can explain exactly what the error message means, but without seeing your code it is difficult to explain how to fix it.

 

A For loop, as you are probably aware, is a loop that runs a specific number of times.  There are two ways to specify how many times it runs: 1) wire a number to the N terminal in the top-left corner, or 2) wire an array to the border of the for loop and enable auto-indexing (the default), in which case the loop runs once for every element of the array.  An array takes precedence over a value wired to the N terminal.  Your error says that you have done neither of these.

0 Kudos
Message 6 of 21
(4,256 Views)

Here is what I have. I atttempted to make the modifications you suggested, but I could not implement the conversion of Analog Voltage in VI to the DAQmx code. Is the waveform data going to cause that much of a problem?

0 Kudos
Message 7 of 21
(4,245 Views)

@aem64 wrote:

Here is what I have. I atttempted to make the modifications you suggested, but I could not implement the conversion of Analog Voltage in VI to the DAQmx code. Is the waveform data going to cause that much of a problem?


Why were you unable to convert to DAQmx code?  It's just a right-click, and then moving the functions around.  What happened when you tried this?

 

The waveform data type is not a problem, but what you have now is "dynamic data" which, as you're finding out, quickly becomes a problem as soon as you want to do anything with it other than what the small set of Express VIs that use it allow.

0 Kudos
Message 8 of 21
(4,238 Views)

When I generate the DAQmx code, I lose the channels I was working with and do not know how to put them as inputs. I apologize, but I am pretty bad at dealing with much beyond express VIs in terms of acquiring signals.

If auto-indexing is the default, why is this not already set up?

0 Kudos
Message 9 of 21
(4,232 Views)

@aem64 wrote:

When I generate the DAQmx code, I lose the channels I was working with and do not know how to put them as inputs. I apologize, but I am pretty bad at dealing with much beyond express VIs in terms of acquiring signals.


What do you mean by "lose the channels"?  The "Generate NI-DAQmx Code" creates a new subVI that sets up the channels.  You can double-click to open it and see what it does.  One thing you'll see inside it is a string array constant, containing the channels that it will configure.  You do need to save that subVI, of course, or you'll lose it when you close LabVIEW.


@aem64 wrote:

If auto-indexing is the default, why is this not already set up?


Because you're using dynamic data and not a standard LabVIEW array.  Wire in a normal array and you'll see what I mean.

0 Kudos
Message 10 of 21
(4,217 Views)