LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

while loop stop control

It may be simple for others but I just have no idea how...

 

I have two while loops, one is for "VISA write" and the other is for "VISA read".

"VISA write" sends data to serial port continuously.

"VISA read" is a state machine structure with each state reads one byte from serial port. If the data read is expected, stop "VISA read" while loop And "VISA write" while loop.

 

How can I stop the "VISA write" while loop as required? Local variable is not reasonable, and I don't other ways yet.

 

Any suggestions?

 

Thank you.

0 Kudos
Message 1 of 10
(3,286 Views)

Search for "notifier" in the forums.

 

Why would a local variable not be reasonable for you?

 

Why do you need VISA Write and VISA Read in different loops?  Most serial port applications are a back and forth, write and read, scenario.

0 Kudos
Message 2 of 10
(3,278 Views)

This is one instance where Local is a good solution, but scratching that you can use Global (just a worse version of Local in this case), Action Engine, Events, queue or notifier.

 

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 3 of 10
(3,271 Views)

Attached pls find a solution for that.

0 Kudos
Message 4 of 10
(3,251 Views)

I attached the VI in another post http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/serial-port-VISA-read-error/td-p/1418364

 

This VI will be used as a sub-VI and no extra boolean button or other control can be reached by caller-VI.

I'm not sure what you meant by back and forth. I have to send out a complete command to serial port and read the command response back from serial port and intepret it.

Do you mean to have a loop outside this one scenario (send out a command and read back the response)?

I tried this but most of the time i got error like memory structure damage at "unflatten from string" vi.

 

0 Kudos
Message 5 of 10
(3,205 Views)

Better yet, if everything is already typdefed, edit the typedef, changing the ring to an enum, apply changes, edit the strings, then apply changes again.

 

0 Kudos
Message 6 of 10
(3,179 Views)

I think I used enum instead of ring.

0 Kudos
Message 7 of 10
(3,170 Views)

Edit:

 

Haha I misinterpreted your jpg.  Ignore this post. 😄

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 10
(3,145 Views)

@MileP wrote:

I'm not sure what you meant by back and forth. I have to send out a complete command to serial port and read the command response back from serial port and intepret it.


Yes.  That is exactly what I mean.  You send out a command then read the response back.  That means a Write then a Read in that order, all in a single loop.  Putting the write in a loop and the read in a separate parallel loop makes no sense and would make it that much more difficult to due the Write then Read that you are looking for.

 

Have you looked as the Serial port examples in the Example Finder?

0 Kudos
Message 9 of 10
(3,112 Views)

Thank you. I've tried what you said. It is better.

0 Kudos
Message 10 of 10
(3,091 Views)