LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

reads data when i highlight execution

Solved!
Go to solution
When I highlight execution my program reads power meter data...when I don't it gives me an error. I have tried putting waits in there etc and nothing seems to be fixing it. Also, when I take out the vi's which read power meter data, the code runs considerably faster. I don't know if this has to do with global variables or what but I am just modifying a code that was included with this device and it included global variables. I haven't tried messing with those yet. Anyways, if anyone sees something that would possibly cure this problem please let me know. Thanks.
0 Kudos
Message 1 of 21
(3,739 Views)
Using version 8.2
0 Kudos
Message 2 of 21
(3,737 Views)

When a VI works with highlight execution on and not otherwise, it usually indicates a race condition.  If the global variables are being written in more than one place, they may be the problem.

 

Please post the VI so we can see what is going on. 

 

Lynn 

0 Kudos
Message 3 of 21
(3,734 Views)
I attached the VI, did you want all the subvis too?
0 Kudos
Message 4 of 21
(3,729 Views)

The attachment did not show up.  Any subVIs which are not in vi.lib should also be included.  If there are more than one or two, putting everything in a zip file is best.

 

Lynn 

0 Kudos
Message 5 of 21
(3,727 Views)
Let me know if this one attaches
0 Kudos
Message 6 of 21
(3,718 Views)

It attached that time.

 

The stacked sequence is unnecessary.  The dataflow of the error clusters and the VISA resources are sufficient.  The dark coloration in the case structure makes it hard to read.  And wires looped all over are hard to follow.  Look for the Style guide.  It is not just to make things pretty.  Programs are much easier to debug and maintain when well put together.

 

I suspect that your problem is the time it takes the instrument to respond to the commands you are sending.  The writes in SET_OPMWAVELENGTH.vi and OPM.vi will occur as fast as the program can get from one to the other.  How long does it take the instrument to change wavelengths?  50 ms, 1 second, longer?  You probably should have at least that much time between the VIs to allow the instrument to get to the next wavelength before taking a reading.  You may also need a delay between writing the Read command and reading the result.  Check the instrument manual for information on how fast it can respond to commands.

 

Lynn 

0 Kudos
Message 7 of 21
(3,704 Views)
Thanks ill try that tomorrow. I know the wires are a mess but I just copied and pasted from another code taht was running sufficiently. I hadn't bothered to clean all that up yet but I'll be sure I do that first thing. After I try some more to fix some of the timing issues I'll post again if i have any more questions. Thanks again for your help
0 Kudos
Message 8 of 21
(3,698 Views)
I have narrowed it down and the problem subVI is the OPM VI. When I don't have that in there the code runs perfectly fine but as soon as I do it gets an error in the read. When I highlight execution of just the OPM vi it works but when I don't highlight it still doesn't. I put a 5000 ms wait in there, which seems like it is more than enough time and it still wont read. At this point could it just be a faulty device? I don't see how it would be when it updates the wavelength fine with the "set opm wavelength" but then wont read the power back. If you could give me any troubleshooting for this i'd appreciate it.
0 Kudos
Message 9 of 21
(3,673 Views)
Here's the edited program
0 Kudos
Message 10 of 21
(3,672 Views)