LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

create a new TDMS file while the program is running

Hi everyone, 

 

I think the problem I'm about to post in here was already discussed. However, the solutions I found didn't really help in my case. #

 

with TDMS tools: 

 

  • While the program is running I want to be able to enter a new path (or file name) and click a boolean element to create this file. And when the boolean is false I want to close the created file. 

 

I apreciate your help 😄 

 

 

best regards

0 Kudos
Message 1 of 11
(1,976 Views)

You have to think with data flow.  Things happen one after another, and things cannot happen a second time, unless there are loops or conditions, calling that function again.

 

So if we look at your code you have the TDMS Open on the outside of your while loop.  This means it is ran once, no mater what.  Then it goes into this loop where it will loop over and over again, until a stop condition is met. once it stops, it will then perform the TDMS Close option once.

 

If you want the behavior of the TDMS Open to change, you must somehow call it, within the loop somehow.  Either conditionally, or in some kind of state.  This looks like very basic LabVIEW code so you might want to research topics like Queued Message Handlers, or State Machines.  That way you can have code in a loop doing stuff, and then when the user interacts with things, the code can do different things.  Here is the Online Training section of the LabVIEW Wiki.  Up one level is the Getting Started.

0 Kudos
Message 2 of 11
(1,930 Views)

Hi Hooovahh,

 

I think it was my fault that I didn't mention this in my first post:

 

the attache VI is just an example if someone would like to modify the code. It's not even a try to solve the problem. (However, I tried to solve it in other VIs ofc)

0 Kudos
Message 3 of 11
(1,918 Views)

@Ezzow wrote:

 

However, I tried to solve it in other VIs ofc


Well then post what you got, and describe what isn't working.  Again my suggestion is a state machine, or QMH, because they are quite flexible.  Maybe my brain just thinks that way now, having used it for so long.

0 Kudos
Message 4 of 11
(1,870 Views)

hi Hooovahh, 

 

I solved the problem ysterday. My problem was how to create a condition that switches from "true" to "false" after I switch to true from the boolean element. In other words I have a boolean element on my front panel that's by the default (before starting the program) "false". When I start the program and switch the boolean to "true" it should keep this state for only one iteration to create a new file with the desired path and then switch the boolean to "false" (to avoid create the file multiple times). At the same time I want this condition to control the process of writing data into a TDMS-file: boolean true --> write data ; boolean false --> stop writing data into the created file. 

 

attached the vi with my solution. I would apreciate it if you could take a look on it and give me feedback if I should mark it as solution or if it's just some garbage code 😅

 

have a nice day everyone 

 

0 Kudos
Message 5 of 11
(1,849 Views)

Oh there certainly things that can be improved, but I'm glad you found a solution, and you did more or less do what I was describing.  You correctly realized that you need to close the reference to the current file, then make a new reference.  I'm also not sure I've ever seen the Implies function actually used.  I've always ended up using the Compound Arithmetic, which has the invert option on both each input, and an output.

 

For testing you might also want to throw in some kind of wait.  This will create files as fast as it can over and over.

 

I also see a random boolean control with no label.  Is that intended to work like a false constant?  If so you can just turn it into a constant. 

 

So another thing you might want to consider is using a button, instead of the boolean toggle type.  Drop down an OK Button.  By default it will be set to latch when released.  What this will do is become true when someone clicks it, but then goes back to false immediately.  This will allow you do to something once, every time it is clicked.

 

Another method is to put an event structure inside you while loop taking up the whole thing.  In it you can have an event when a button is clicked (value change) and handle it.  In the timeout case you can have it do normal stuff like read or log or whatever.

 

Attached is a way to do this with a state machine.  I obviously got carried away and added features you don't need like incrementing the file on a click, exiting using the close button, graphing the data, allowing for stopping of logging, and an explore button to find the data.  

0 Kudos
Message 6 of 11
(1,821 Views)

Thank you Hooovahh! 

 

the only reason why I used the implies function is that I can control the creating of a new file and the process of writing data into this file with only one boolean element. The OK button will disturb this methode because it switches to "false" automatically. I actually want it to switch to false automatically but not for both case structures. For the second case case structure I want the boolean to work very nromal so I can control the process of writing data at the same time. 

 

Ezzow_0-1668760578287.png

 

 

 

 

0 Kudos
Message 7 of 11
(1,790 Views)

@Ezzow wrote:

 

the only reason why I used the implies function is that I can control the creating of a new file and the process of writing data into this file with only one boolean element.


I'm pretty sure the compound arithmetic node can also do this in a single function too.  And it can eliminate the need for the NOT after it.

0 Kudos
Message 8 of 11
(1,773 Views)

I'm clueless about how to use it in this case. I would apreciate it if you show me the methode 😄 

0 Kudos
Message 9 of 11
(1,761 Views)

Well drop the Compound Arithmetic function from the Boolean palette.  Then resize it for the number of inputs you want.  Then you can right click and change the mode to what you want.  AND, OR, XOR, ADD, or Multiply.  Then you can right click any input or output and select Invert.  So if you want to function like an Implies with a NOT change it to OR mode, invert the first input, and invert the output.

 

Did you also check out the VI I attached?  It has lots to learn in it too.

0 Kudos
Message 10 of 11
(1,753 Views)