LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VI stops prematurely

Hi,

 

I wonder if someone can help me. I have an issue with a subVI in my program. I have attached 2 png files, "Range.png" and "Specific.png". I want to use the Range VI instead of the Specific VI but it causes the premature ending of the whole program.

 

The intention is to write a position value (for a serial controlled stepper motor) to a Write Buffer (VISA) (in the 'higher-up' VI) and then pass the value through to the subVI. It will then spam the Write Buffer to query the current position and read the Read Buffer output to determine instantaneous position. Once the intended postion is equal to the Read Buffer value then the loop should stop. 

 

The communication format for write is /1 ?P\r and for read it is /0 OK(1000)\r

 

In the Range VI, I want to exit the loop if the write value and read value are within a range since the read buffer occasionally returns a "-1" if the position is meant to be "0". I would like to use this VI instead of the Specifc VI.

 

I notice that if I run the program in the "light bulb mode" it works well but not in normal mode. I looked this up as a race condition but I know for a fact that it cannot be a race condition since the Range VI is the condition to break out of the state in my state machine (the VI that this subVI is executed in).

 

I hope that I have provided enough information and that I was clear (I wrote what I was thinking).

 

Kind regards,

 

Richard

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

You really should not be setting up the port repeatedly inside of the loop.  That should be setup once as the start of the program.  At the very least, it should only be done BEFORE the while loop starts.  Same for clearing the buffer.  I've seen both of these cause interesting problems with serial ports.

 

You might also want to use the In Range And Coerce function since that will do the job of 3 functions for you.


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
0 Kudos
Message 2 of 3
(2,084 Views)

Hi,

 

Thank you for your reply. I have now only cleared the buffer once and set up the port once (apart from the setup of the stop bits, parity etc - which is done in a higher-up VI).

 

I have tried using the Range and Coerce function, which does the job. BUT, the whole program still stops prematurely.

 

I am not able to reveal much (secrecy) but an overview of the process (5 stage state machine) is:

 

Initialise the motor (first state) -> Zero position (second state) -> Rotate a specified amount (third state) -> Rotate at a specific velocity while checking position using the Range/Specific VI (then stopping at it) (fourth state) -> Return the zero postion (fifth state).

 

The problem occurs between the 4th and 5th stage. Instead of returning, it just simply ends the program at the end position of stage 4. If I use the "Specific VI" I dont have that problem, however, since the Read Buffer returns a value that may be off by +/- 1 step, the loop takes ages to break. I could keep using it (with your previous recommendations) but I would prefer a ranged position reading VI.

 

I have tried my best trying to find anything that could cause this. During the "light bulb" run, there are no problems.

 

Regards,

 

Richard

0 Kudos
Message 3 of 3
(2,066 Views)