LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Timing problem with my LabView VI

I am relatively green, and self taught in my VI design methods, so in many way I know my VI is inefficient and clumsy.  Because of this I have a screen shot of the specific problem I am having (I think).  http://img521.imageshack.us/img521/2275/timercodepic3dh6.png

 

My focus is the Elapsed Time express VI.  The purpose of this Vi is to automate a 3 tier temperature gradient (94 --> 50 --> 72°C) while holding the temperature constant at each temperature for a specified duration (30 seconds in this case).  Holding the temperature constant for 30sec is where my VI is failing.  For the first 6 iterations (Case Loop 0-5) the VI is fine, each temperature is reached and held correctly.  However, after the 5th case, where the middle While Loop ends (atleast I think it does) then the main While Loop iterates, and the process starts over but the timers don’t seem to be resetting.  Case 0 works fine (it's condition is not timed, instead it is based on reaching a temperature) but when Case 1 starts, it immediately kicks out to Case 2, which works fine (again not time dependant) and then Case 3 kicks out instantly which also has the Elapsed Time VI as its condition.  To help any confusion, this is what is happening currently in the Case Structure:

 

Case 0 = heat to 90°C ; Case 1 = Hold Temp 30sec ; Case 2 = cool to 50°C ; Case 3 = Hold Temp 30sec ; Case 4 = heat to 72°C ; Case 5 = Hold Temp 30sec ; While loop ends, kicks out, main While iterates, back to Case 0 = heat to 90 °C ; Case 1 = LED lights up for split second ; Case 2 = cool to 50°C   etc...   

 

I want the temperature to be held for 30sec each time Case 1, 3, 5 are called.  I have "Automatically reset after time target" option turned on, I also have a True Boolean tunneling into this loop every time the Case loop is called.  Without this Boolean the end result is the same, I added it and it changed absolutely nothing.  I tried having a True Boolean tunnel in to the "Reset" node on the Elapsed Time express vi, but that definitely did not work.

Any advice is welcome I will try anything.  I know there are better, more efficient ways to program this type of timing using more basic functions, but I exasperated myself trying different ones from tutorials.  Other than this timing issue I think my VI is operating as intended, albeit very inefficiently.

0 Kudos
Message 1 of 5
(3,397 Views)
Hi,

Its hard to see where the problem is without running the program. Have you run this in highlight execution mode to see where the problem is. Also, it seems like this kind of architecture would be best solved using the state machine pattern, where your vi goes to many different states. You can find this one by going into labview and opening up file >> new >> frameworks >> design patterns >> state machine.

-Tim
0 Kudos
Message 2 of 5
(3,381 Views)
One thing I see in your VI is that your elapsed time express VI is in the same case as the other VI's that look like the heating and cooling controls, but there is no data flow between them.  That express VI looks like it would start as soon as you enter the case.  So if elapsed time is 30 seconds, it would run concurrently witht the heating or cooling whether those would take more or less than 30 seconds.
 
I would highly recommend you take Tim's suggestion and restructure this into a state machine.
 
Definitely spend some time doing right click/clean wires to clean up some of the wiring to make things easier to read.  Have the direction of data flow go from left to right, out of controls and into indicators.  I would say more than half the wires are in a backwards direction.
You have a lot of local variables going on.  Try to eliminate those where you can.  Perhaps you have race conditions with the timing of the read and write to the variables hurting you.
In some places where you have multiple OR's you can use the compound arithmetic VI and set it to OR mode.  That way you can take any number of booleans and OR them together in one function.
A few places there is just a constant being passed through the tunnels of the while loops or case structures.  Try to clean up these situations for clarity.
A number like Duration1 times 1 is itself.  So eliminate Rube Goldberg code.
 
One more thing.  Post the VI so others can look at it in its entirety.  Actual code is easier to look at then a screenshot.

Message Edited by Ravens Fan on 06-28-2007 09:02 PM

0 Kudos
Message 3 of 5
(3,371 Views)

 

I thought I would post my code in its entirety.  I’m not sure if my confounded while loop structure is the cause of the timing issue.  It seems to me that on the second go around, the Elapsed Time express VIs are not being reset, so they start at 30seconds and automatically kick out.  Maybe this is not the cause but again the first go around all 6 case loop steps work perfectly.  Yes the Elapsed Time is in the same box as the other Daq Assistants and at this stage all they do is maintain the temperature within about 2°C of the desired temperature, the previous case loop is what brings the temperature to this desired degree.  Hopefully seeing the entire code will clear this all up.  Thank you again for your help and I will fool around with this standard state machine structure.  I don't think it will solve the timing problem, but it will certainly make everything cleaner. 

 

PS: There are 4 Boolean controls on the Front Panel that don't do anything yet, I plan to implement them but they are not required for the VI to function as desired, they only give added safety shutoff control.  And the shift registers in the 2 outer while loops don't do much yet either... infact I don’t know why I put them there...  Side question: What is the difference between using a shift register to record the loop iteration, versus just using the iteration function default in any while loop?

 

Thanks again,

--Andrew

 

 

 

0 Kudos
Message 4 of 5
(3,344 Views)

If the express VI's are giving problems, you may want to turn them into code you can look at.  Right click in the express VI and select Open Front Panel.  This will turn the code into a subVI that you can open up and look into.  You may want to eliminate the express VI and replace them with a simple loop structure that keeps the start time in a shift register and continually subtracts that from the current time.  Search the forums as I am sure there are numerous examples on how to do that.


@Anfu wrote:

 

 Side question: What is the difference between using a shift register to record the loop iteration, versus just using the iteration function default in any while loop?

 




With the way you have them set up, there is no difference between the iteration i node and the value going through the shift register.  Both start at zero and increment by 1 on every iteration. 
0 Kudos
Message 5 of 5
(3,330 Views)