11-20-2021 12:02 PM
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
Solved! Go to Solution.
11-21-2021 10:42 AM
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…
11-22-2021 09:17 AM
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
11-24-2021 01:02 PM
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
11-24-2021 01:30 PM - edited 11-24-2021 01:31 PM
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… 😄
See this:
11-25-2021 09:49 AM
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
11-25-2021 12:06 PM
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! 😉
11-26-2021 05:47 AM
Hi GerdW,
you made it very clear.
Thanks again for your useful suggestions! I'll keep studying
Best regards