From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I write to file at a discrete time step?

Solved!
Go to solution

Could you maybe offer me an example of what you're talking about.  I've tried this before, but didn't have much sucess, it ended up slowing things down a bit.  Aren't there potential problems with writing and reading the same memory at the same time?

 

Adam

0 Kudos
Message 11 of 14
(638 Views)
Solution
Accepted by topic author AdamBlues

Hi AdamBlues,

 

Below is a link that gives an overview of producer consumer architecture:

http://www.ni.com/white-paper/3023/en/

 

And here is an example of using it to acquire data from a DAQ device and then log that data to a file:

https://decibel.ni.com/content/docs/DOC-2431

 

I am not sure that I understand your question about problems reading and writing memory at the same time. Producer-consumer architecture uses queues to pass data. You add elements to the queue when you read your data. Your consumer loop then removes elements from the queue to do processing such as writing to a file. This can help prevent timing problems by moving the slower tasks such as processing to a separate loop so they do not interfere with or slow down your producing/acquisition tasks.

Catherine B.
Applications Engineer
National Instruments
Message 12 of 14
(608 Views)

Thank you so much for the help with the producer/consumer architecture.  I had something like this set up before, but I was writing and reading it from a structure array rather than a queue.  I have it set up and working with one problem still: I need the consumer loop to read from the queue until it is empty and for some reason, the program is hanging when the producer loop finishes, even when I put a manual control on the stopping condition for the consumer loop.

 

Please see the attached VI (Labview 10)

 

Any chance someone can help me out here?  Thank you for your time.

 

Best Regards,


Adam

0 Kudos
Message 13 of 14
(590 Views)

Your code is in need of some serious cleanup. You do not need to use the flat sequence frame. Learn how to use dataflow to control the order of execution rather than relying on the frame structure.

 

You do not have a coordinated exit control for your application. The FOR loop and one WHILE are using the Abort button to exit. The FOR loop will execute No_Lines times if the abort is not triggered. Your consumer loop is waiting for a different control in order for it to stop. You do not provide any means for it to stop if the data collection is complete. I generally prefer to use explicit messages to control operations rather than queues with simple data types. Your consumer loop will also stop and wait forever on both queues before it can exit. Therefore you are seeing the behaviour of your program hanging. It is also a good idea to only dequeue from a single queue within a consumer loop.As written your consumer loop must wait for data in both queues before it can process anything. This will be a major issue if you are not posting the same amount of data elements to both queues.

 

I would also move your configure subVI for the motion controller to be outside of your FOR loop. There is no reason to configure it every iteration.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 14 of 14
(584 Views)