LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Writing simulated signals including relative time column

Solved!
Go to solution

Hi,

 

I'm trying to write multiple simulated signals to a txt file (VI attached).
When a Record button is pressed, Labview starts writing data to a txt file. Right now I can write signals values but I also need to have one column with the relative time (e.g. for 10Hz rate -> relative time: 0, 0.1, 0.2, 0.3...). Signals have the same dt.


I'm using Labview 2018.

 

I hope someone could help me with this.
Thank you

0 Kudos
Message 1 of 8
(1,202 Views)

Hi kerb,

 


@kerb9989 wrote:

Right now I can write signals values but I also need to have one column with the relative time


When you want to save timing information too, then why do you delete that information from your signals???

 

You create your signals using ExpressVIs (why not use functions from SignalProcessing palette?) and convert them to an array of waveforms. Such waveforms contain your timing information, but the you choose to get rid of that information by converting the waveform sample data into a plain 2D array! (Btw. learn to use autoindeixing tunnels, no need for a shift register and BuildArray here!)

 

Suggestion:

When you need an additional column of relative time data you need to append/prepend that additional column!

You can easily calculate that timing information by using "dt" from your waveforms and the number of samples written so far…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 8
(1,146 Views)

Hi GerdW,

 

thanks for your response. Ok, I wired Y directly to Write delimited spreadsheet.
Regarding the relative time array, I'm trying to multiply dt for i in a for loop inside the case structure, setting the count terminal to the number of samples written to the txt file.
I'm trying to build an array containing only Y values sent to Write delimited spreadsheet and then get the number of samples with Size array, without any success.
I can only build an array containing all Y generated values using shift register.

(VI attached).

 

Regards

0 Kudos
Message 3 of 8
(1,113 Views)

Hi,

 

I've made some progress. The attached VI writes relative time data and waveform values to a txt file. As a beginner I'm happy with it but I'm not sure if that's the right way... I refer in particular to the way it gets the number of samples written to the txt file.

Any suggestions would be greatly appreciated!

 

Thank you

0 Kudos
Message 4 of 8
(1,079 Views)
Solution
Accepted by topic author kerb9989

Hi kerb,

 


@kerb9989 wrote:

I've made some progress. The attached VI writes relative time data and waveform values to a txt file. As a beginner I'm happy with it but I'm not sure if that's the right way... I refer in particular to the way it gets the number of samples written to the txt file.

Any suggestions would be greatly appreciated!


It's a beginning… 😄

 

  • You don't need any local variables in your little VI: use (more) wires!
  • You don't need to (over)write the spreadsheet file in each iteration: writing only once after the time has elapsed is enough!
  • Have you ever considered to use AutoCleanup (Ctrl-U)?
  • You already use StripPath, so you should know the BuildPath function too: there is no need to use string functions to build paths! (This can become error prone once you use different targets!

See this:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 8
(1,076 Views)

Hi GerdW,

 

 

thanks for your useful tips! I now understand why I should use more wires instead of local variables.
I took a quick look at the code:  if I wire the "Time has elapsed" output (along with the logical negation) to the shift register, the output terminal of the case structure becomes white/green. Labview reports an error due to "Missing assignment to tunnel" and, even if I check "Use default if unwired" option, the output terminal never becomes just green (but VI works well).
Is that a problem?

 

Regards

0 Kudos
Message 6 of 8
(1,063 Views)

Hi kerb,

 


@kerb9989 wrote:

I took a quick look at the code:  if I wire the "Time has elapsed" output (along with the logical negation) to the shift register, the output terminal of the case structure becomes white/green. Labview reports an error due to "Missing assignment to tunnel" and, even if I check "Use default if unwired" option, the output terminal never becomes just green (but VI works well).
Is that a problem?


This is one point in the LabVIEW basics courses: the different behaviours of loop and structure tunnels! Learn about them…

 

In this specific case your VI will work as expected no matter if you wire the tunnel in the other case or not (default if unwired). Think about why it works as expected! 😉

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 7 of 8
(1,056 Views)

Hi GerdW,

 

 

you made it very clear.

Thanks again for your useful suggestions! I'll keep studying

 

 

Best regards

0 Kudos
Message 8 of 8
(1,031 Views)