LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unwanted Delay in while loop

Hi - ok, so i'm not much of an expert with labview - in fact i'm quite new to everything - so i apologise if this is a stupid question with an obvious answer...
...i'm controlling 3 valves and a digital syringe with labview - i've been able to control them fine so far, but in order to be able to change the ports of the valves, and the volume in the syringe, i've put the whole sequence structure inside a while loop (wired to run continuously), and i'm using shift registers and case structures to check the values so that it'll only send data when the values are changed.
This is all well and good and, theoretically, it's working...but i have the weirdest delay. It's almost like it's only sending information ant some set interval?
    for example, if i change the values of one of the valves, there is a delay (i think i measured about 15 seconds or so), but then if i change one and then change another about 5 seconds later (assuming the first hasn't changed yet), they'll change at the very same time (after about another 10 seconds)

(I apologise if i'm making this sound more complicated than i need to, but i'm just so desperate at this stage, cause i've only 3 weeks left to finish this program, and this is really dragging me down!! Smiley Happy)
0 Kudos
Message 1 of 5
(2,794 Views)
Well, what is the loop time of the main loop?
 
We cannot really troubleshoot by a description alone. Why don't you attach your VI? Thanks! 🙂
0 Kudos
Message 2 of 5
(2,791 Views)
Ok - well i've attached the vi, but i don't know what you mean by the loop time?? unless it's the ~15 secs i mentioned??
0 Kudos
Message 3 of 5
(2,789 Views)
Frankly, I don't understand how some of the program works at all. It's very difficult to follow with the bad wiring you've done but I can tell that the VISA Write associated with the front panel Boolean is being called with every iteration. Is that intentional? You have 4 VISA Reads in the second frame of the same resource. I have no idea why you would need 4. Three of them will probably never read anything or if they are read, then some will probably be a partial read.
 
What version of LabVIEW do you have? Is it the base version only? If you have the full, you should really, really use the event structure instead of the shift registers and comparisons. There may even be a wiring mistake in those but it's so difficult to follow, I can't tell. If you only have the base version, you should look at the shipping example called Queued Message Handler. It demonstrates a much cleaner way to poll for front panel control changes.
0 Kudos
Message 4 of 5
(2,780 Views)
Here is an example using the event structure. Without your instruments I can't test it, and it will require you to have more than the base release of LabVIEW. It is done in LabVIEW 7.1.1, which is back compatible with 7.1  As Dennis points out you are writing the boolean A/B value every iteration, and with the multiple reads you will get back what ever happens to be in the serial buffer, not necessarily that which is a response from any specific command. I've tried to make it so that it read back immediately after a control change is sent, but this still doesn't guarantee that the data is a result of the latest control change. Without knowing how the instrument at the other end of the serial connection responds to commands (it could be several seconds ??) I don't know what is actually being read back. I've got it waiting until a response before reading back, may help...This was a quick and dirty rewrite so use it with caution ...


Message Edited by LV_Pro on 03-22-2007 10:37 PM

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 5 of 5
(2,776 Views)