LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why does LabVIEW skip over commands in programming structures

Solved!
Go to solution

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.

0 Kudos
Message 11 of 21
(1,448 Views)
We told you what the problem is, now you simply need to fix the code. There is always a way and it is trivial here to fix. Did you understand my suggestions?
0 Kudos
Message 12 of 21
(1,444 Views)

@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.

Message 13 of 21
(1,427 Views)

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?

0 Kudos
Message 14 of 21
(1,404 Views)

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.

Paolo
-------------------
LV 7.1, 2011, 2017, 2019, 2021
Message 15 of 21
(1,391 Views)
Solution
Accepted by topic author andrewjoe777

@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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 16 of 21
(1,388 Views)

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

Download All
0 Kudos
Message 17 of 21
(1,361 Views)

The LabVIEW help screens are your friends here.

 

Cameron

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 18 of 21
(1,348 Views)

I tried using the help manual but I still couldn't figure it out. Can anyone please help me? 😞

0 Kudos
Message 19 of 21
(1,302 Views)

Look at this thread for ideas how to create a Dynamic Datatype queue.

 

http://forums.ni.com/t5/LabVIEW/How-to-queue-two-waveforms-in-dynamic-data/m-p/647169/highlight/true...

Message 20 of 21
(1,296 Views)