LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Serial and Elapsed Time as a Timeout

Solved!
Go to solution

Hi folks,

 

Still new to LabView, so please bear with me...

 

I have a VI that sits and wait for a certain character string to arrive over the serial port, but I need a timeout that doesn't rely on the VISA timeout.

I expect a bunch of text through the serial port for ~45 seconds, then my input string will compare the matching string and move on to the next VI.

In the event of no string match, the serial port may keep on sending serial data, or may be inactive (non-determinisitic because this test is to see if a computer system booted correctly). But once the VI starts, I should have 60 seconds to find the match, or set the bool output 'selection' to fail.

 

I have tried putting my Elapsed Time loop inside the main loop, outside, with/without SRs, and now I'm at a loss. I looked at the VI highlighted and the serial activity wasn't active until the 60 second timer expired.

 

Please take a look at the attached, and thanks for taking a look at this post.

0 Kudos
Message 1 of 7
(2,562 Views)
Solution
Accepted by topic author CelerityEDS

I'm not entirely certain that I understand what you are trying to accomplish. However here are my thoughts:

  1. The VI you attached will wait 60 seconds before checking the serial port for waiting bytes ONCE then read bytes if they are availale and quit immediately. This is because you have the while loop around the elapsed time and it must execute completely before moving on to the serial communication loop.
  2. I assume you have setup the serial port and set termination characters, etc in a main vi
  3. Please try the modified VI attached and let us know if that helps

 

Thanks,

 

Charles Chickering

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
Message 2 of 7
(2,556 Views)

Thanks Charles,

 

To answer/comment on your thoughts:

1. I want the serial port for waiting bytes to continually loop while the 60 sec timeout is running.

2. All the setup is in a main VI and is working properly

3. This helps a lot - runs great.

 

The updated VI will always run for 60 seconds. Say I got my string match 35 seconds in - the program won't end until this timer is expired. Can I do that using the express VI, or shall I make a case structure for this instance?

0 Kudos
Message 3 of 7
(2,550 Views)

The boolean coming out of your "Match True/False String" primitive will stop the code if true. So the logic for the stop condition is as follows:

  • Match True/False String = True
  • OR
  • Stop Button = True
  • OR
  • Time Elapsed = True

Perhaps we need to rework the Match True/False String part of the code?

 

Charles

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 4 of 7
(2,547 Views)

You are not reading the code correctly. The VI will stop when the string is found, the time is up, or when the stop button is clicked. No changes are required.

0 Kudos
Message 5 of 7
(2,544 Views)

Perhaps this is caused by doing a segmented read of the serial port? (meaining not all of the data comes in one read). Check out the attached VI, I added a shift register to keep the entire received data in a buffer.

 

Charles

Charles Chickering
Architecture is art with rules.

...and the rules are more like guidelines
0 Kudos
Message 6 of 7
(2,541 Views)

Thanks for all the help Charles and Dennis. It turns out I was reading it incorrectly. I am going to test out the SR addition to the serial string, sounds like a definite improvement to the code.

0 Kudos
Message 7 of 7
(2,520 Views)