LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Need help with chart problem

Thanks Simon,

1. How should I be "opening" the file. I tried many variations and this was the one which seemed to work. Maybe I shouldn't be using the while loop? I found that if I tried to open the file outside of the case it wanted to open a new file on every scan.

2. Perhaps I misunderstood the purpose of the "stop" input on the DAQ assistant. I have since noticed that this vi runs the same if the input is not wired. Also I thought that acquiring N samples would do just that. I wanted to capture for an indeterminant amount of time, depending on how long the machine is in motion. Therefore I do not know how many samples I need to acquire.

3. I want to write one file for each movement. If it takes 2 minutes, I still want it all in one file. What is the source of these "gaps" you speak of? Does it have to do with the way the case passes data out to the write binary.vi? I don't understand where else I could have placed the "write" in relation to the DAQ assistant.

4. I'll try the wait function to see how it affects the operation.

 

I want to thank all of you for your help. I have spent many years programming PLC's, but they did not use loops. Based on the comments I am seeing I need to study the operation of loops to better understand what happens. Most of this feedback suggests ways of doing things that I have not even considered. Back to the books....

 

Thanks

technomage

0 Kudos
Message 11 of 12
(474 Views)
If I were tackling this problem I'd move all of the file related code inside the case structure.  That way it only gets executed when appropriate.  I'd then put another while loop inside the case structure but around just the DAQ Assistant and the write VI.  If you then wire the inverse of the trigger to the stop terminal this while loop will stop once the trigger returns to false.  In this setup the DAQ Assistant needs to be configured as continuous (in which case the number of samples parameter determines how many samples are read on each loop iteration).

I have attached a screenshot of what I was thinking.  The outer while loop keeps the program running and checking the trigger value.  In the false case of the case structure you'd want to put a wait statement so you don't overload the processor by running the loop as fast as possible.  In the true case you'll want to get the current time to generate your file name and create your file.  Then have another while loop which acquires all the data and writes it to file.  Once that loop has completed close the file.  Adding some error handling is always a good idea so you know when something goes wrong.

As with most programming languages there are multiple ways to achieve similar results - this is just a suggestion.  Let me know if something is unclear and you would like me to explain in more detail.

Regards,

Simon H
Message 12 of 12
(445 Views)