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: 

VISA State Machine does not work; feedback node issue

Solved!
Go to solution

Hello;

 

I am very new to LabVIEW and I am trying to make a program to control two VISA resources at the same time. I realize that some of this may not be designed as well as it could be; please let me know where I can improve. The main VI (RESISTANCE AUTOMATION.vi) requires Resistance Scanner.vi to be complete.


I have a serial instrument (a heated bath that takes basic ASCII commands) and a Data Acquisition unit that is hooked up to a device suspended in the bath that I would like to measure the resistance of once the bath reaches 2 specific user-defined set points. Both devices work just fine when communicating with LabVIEW on their own; the issue is really only with this program that tries to get them to respond to the state of the other.

 

I have made a state machine that would ideally cycle through the following states once each: Initialize>Look for Set Point 1>Call scanner for SP1>Change to SP2>Look for SP2>Call scanner for SP2>END. This machine is a modification of the Continuous Serial Write and Read example. It should "look" for the correct temperature by writing "RT" (read internal temperature command) to the bath and using the Search String/Char block on the Response indicator it gets to check the current temp. Once this condition is met, it calls the Resistance Scanner sub-VI that I made and saves the resistance measurements from the specified channels to a spreadsheet.

 

I am pretty sure the issue is that the feedback node on the Read command is preventing the states from moving forward. When I turned on the VI, it remained stuck in Initialize and did not show any readings. Changing the state machine to a simple enum control did not change anything, leading me to believe that the state machine has been set up correctly since the simpler one I made worked fine.

 

Any advice is appreciated; thank you!

 

EDIT: Further testing has shown that the serial write and read loop never progresses past the first iteration.

Download All
0 Kudos
Message 1 of 5
(1,282 Views)
Solution
Accepted by topic author clara_b

Have you run your VI with highlight execution on so you can see what executes and what doesn't?  What has you thinking it  is a problem with the feedback node?

 

I don't see a feedback node problem.  I do see an event structure problem.

 

You have an event structure that is sitting in the big while loop that has only one case, Scan: Value Change.  Because Scan is and indicator and not a control, a user can never change the value of it.    I don't see property nodes for the Scan indicator for Value(Signalling) being written to.  So that event structure never executes.

 

Your while loop can't finish and iterate again until all code inside of it has executed, which can't happen because the event structure can never execute!

 

I would eliminate that event structure and see if it behaves any better.

Message 2 of 5
(1,244 Views)

Thanks for the reply!

 

So after some noodling around I came to the same conclusion, and removing the event structure causes the program to work as intended (but without calling the scanner.) However, I am not sure what other method to use to call the scanner other than an event structure. Do you have any suggestions for that? I wasn't sure if it would work if I put it outside the while loop; I need it to be called only twice in the whole execution of the program.

0 Kudos
Message 3 of 5
(1,184 Views)

When are the two times it needs to be called?  Put it in the respective cases of the state machine.

 

If you move it outside the while loop, then put it in a loop of its own and use a queue or notifier to signal that loop when to execute.

0 Kudos
Message 4 of 5
(1,171 Views)

It works great now, thanks again!

0 Kudos
Message 5 of 5
(1,156 Views)