From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI only runs when highlighted but stop working at full speed

Hey everyone,

 

I am an Undergraduate Research Assistant working on chemical research. The VI I am writing is pretty straightforward. All it needs to do is read the voltage coming off a silicon detector as a monochromator (the Digikröm CM110) shines a beam of light at it. 

 

The point of this is to get a voltage reading from the beam every 2nm from 350nm to 650nm. I have put together a VI using some stock smaller VIs, but the issue is that the sequence will run smoothly up until 522nm, where the next number will suddenly be in the 4000s, and consequently break the <650 while loop. However, when I run the VI using the highlighting tool, it runs just fine, and does not give out at 522nm.

 

Here is an outline of how the VI works:

 

-The initial wavelength and step sizes are established through a sequence outside the loop.

-The loop commences and the step function is run, and the silicon detector on an AI0 USB6008 A/D converter reads the voltage (compensated for the ground discrepancy).

 

I'm pretty lost on where to even start looking. I've messed with timeout values and timers, as I thought giving the whole thing time between frames to catch up would fix the issue, or placing the step function inside the loop, but none of those have rendered any fixes so far.

 

Any form of help would be greatly appreciated.

 

(I have set the current go to wavelength to 510 so that you wouldn't have to watch it go from 350 - 522nm.)

 

The VI in question is the voltage read + wavelength.vi, the other file contains some files that are depended upon.

 

 

 

.

 
Download All
0 Kudos
Message 1 of 3
(2,030 Views)

Right now there is nothing in your code that says whether to run initialization (set wavelength and step size) first, or to start recording data first. You can enforce the order of execution with a simple wire going from the bottom sequence structure to the while loop. 

HOWEVER

Now is a good time to really rethink your code. You are sending many device specific commands without any comments on your code. If someone else picks up your code (or you come back to it after Christmas break), how are they supposed to know what command 54 does?

This type of sequential problem is begging for a state machine! You would initialize, collect data, step wavelength, collect data, step wavelength ... end. 

 

capture.png

Message 2 of 3
(1,977 Views)

3 things scare me about your VI's.

 

1.  The use of so many stacked sequences.

2.  The need for local variables.

3.  The ancient .llb that uses serial port functions that are long obsolete.  Whre did that .llb come from?

 

I really suspect that LLB is the problem as it uses an ancient version of bytes at port (and as I and others have said thousands of times before in the forums, bytes at port is the wrong thing to use 99.9% of the time.)  It seems it reads bytes a port until it detects the bytes or times out.  And your timeout seems to be a very low value of 200 milliseconds for some of the them.

 

Throw away that LLB and rewrite your VI to use modern VISA functions. Don't use Bytes as Port either.  Read the communication manual for this device to understand what the commands are and expected responses.  It is possible it uses termination characters.

 

0 Kudos
Message 3 of 3
(1,977 Views)