09-11-2013 02:43 AM
I can save it in an older version of labview if you tell me which labview you have.
So is there no way to use the write to file VI without having this problem? Do I need to making the sampling time longer or something? I'm using wires now for my set point instead of the global variable.
09-11-2013 02:49 AM
09-11-2013 03:54 AM
@andrewjoe777 wrote:
Here;s a picture of it giving the wrong initialization when using the write to measurement VI as well the a picture of it giving the right initialization when NOT using write to measurement VI.
Does the file actually get written? In order not to interfere with the PID loop timing, you might want to use a queue and write to the file in a parallel and independent loop.
09-11-2013 09:36 AM
I have removed both global variables and still get the same problem. It is writing to the excel file.
What exactly do you mean by using a "queue"? Like I tell the parallel loop that is writing to the measurement file to wait until the plant model gives an output?
09-11-2013 10:05 AM - edited 09-11-2013 10:24 AM
Your cycle time is 50 ms. Writing to the file probably takes more time and so alters the PID calculations (I never worked with PIDs, but I don't see any other possibility).
Either you store the PV in an array (hosted in a shift register) and write all data at the end or throw the PV into a queue. A queue is FIFO, a useful LV synchronization object.
In another loop, you check if there's something in the queue and write the new data to the file. Beware that the parallel loop would probably run a longer time than the main one, because it's slower.
09-11-2013 10:13 AM
@andrewjoe777 wrote:
What exactly do you mean by using a "queue"? Like I tell the parallel loop that is writing to the measurement file to wait until the plant model gives an output?
Look into the Producer/Consumer architecture. It uses a queue to send data from one loop to another loop. This is a lossless transmission. So whenever your plant model has an output ready, it enqueues the data. The file write loop will dequeue the data whenever it comes in and write the data to disk. You want to do this so that the file writing doesn't interfere with the timing of your model loop.
09-11-2013 03:36 PM
Thanks for the help! This is exactly what I need!
I don't fully understand the example from the link though. I don't understand what's supposed to be the element data type for the input into the Obtain Queue Function VI. I also don't understand how to convert dynamic data to a cluster of 4 elements like the Enqueue and Dequeue Element Functions need. I've attached two pictures that describe my questions.
Note: I've programmed this separately so that I can make sure it works before integrating it into my control VI.
Thanks
09-11-2013 03:55 PM
The LabVIEW help screens are your friends here.
Cameron
09-20-2013 08:08 PM - edited 09-20-2013 08:16 PM
I tried using the help manual but I still couldn't figure it out. Can anyone please help me? 😞
09-20-2013 08:59 PM
Look at this thread for ideas how to create a Dynamic Datatype queue.