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: 

String Indicator w/feedback node won't reinitialize/clear

Solved!
Go to solution

Hello;

 

I have a VI that has a constantly-updating string indicator (named Response) and also uses a state machine. At one point in the state machine, I want to clear the string indicator. I have tried wiring an empty string constant to the indicator using a local variable, and also tried using a property node to reinitialize the indicator (pictured.) Neither of these had any effect on the indicator, and I suspect that the feedback node is to blame for this somehow. 

 

How can I change this program so that this case/state in the state machine clears the indicator?

 

You need specific VISA instruments for this code to work so I did not bother to attach it. Please let me know if there is any other info I can provide.

 

Thanks!

0 Kudos
Message 1 of 6
(1,830 Views)

Hi clara,

 


@clara_b wrote:

At one point in the state machine, I want to clear the string indicator. I have tried wiring an empty string constant to the indicator using a local variable, and also tried using a property node to reinitialize the indicator (pictured.) Neither of these had any effect on the indicator, and I suspect that the feedback node is to blame for this somehow. 

THINK DATAFLOW: Trying to clear the datasink (aka your string indicator) is nonsense, when the datasource (aka feedback nodes) still holds the data!

 

Yes, the feedback nodes are to blame. Infact you are to blame as you are using even two of them just to show some text in a string indicator. Why do you need two of them?

 


@clara_b wrote:

How can I change this program so that this case/state in the state machine clears the indicator?

… so I did not bother to attach it. Please let me know if there is any other info I can provide.


Well, you decided to attach just an image of code. You didn't bother to attach real code.

But you still want help on better implementations? (Please attach real code!)

 

Solution: Implement this "text collector" using only one (1) shift register. Wire the data through your state machine and clear the data when you need to inside the state machine…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 6
(1,818 Views)

Very well, I have attached the VI and associated sub-VI. RESISTANCE AUTOMATION.vi is the main code.

 

I did originally use only one feedback node; you may notice that this is a modification of the Serial I/O example, Continuous Serial Write and Read. However, LabVIEW automatically added the second feedback node when I took the Read block out of the case structure it had originally been in, and when I try to disconnect/delete it, another will be added automatically. I have no idea why.

 

You are right that I should have attached the code in the first place, as you are unaware that I actually need both shift registers for the program to work. I will try to work out how to clear the feedback nodes another way.

 

Here is a brief overview of what the code does: the serial device is a heated calibration bath that will be set to two different temperatures. The bath is being continuously polled for its current temp in the "Looking for Set Point 1/Set Point 2" states. The reason I would  like to clear the indicator is that I am polling it by searching the entire string for the target Set Point, so if I don't clear it in between, there is a potential for error if the second set point had been reached previously (and would therefore still be kicking around in the Response string.)

Download All
0 Kudos
Message 3 of 6
(1,798 Views)
Solution
Accepted by topic author clara_b

@clara_b wrote:

Very well, I have attached the VI and associated sub-VI. RESISTANCE AUTOMATION.vi is the main code.


You may not be aware of this, but if you save a VI in a new version of LabVIEW (e.g. LV2020), people with older versions of LabVIEW cannot open it.

(But thank you for attaching your VIs. It's much better than nothing.)

 

@GerdW wrote:

Solution: Implement this "text collector" using only one (1) shift register. Wire the data through your state machine and clear the data when you need to inside the state machine…



@clara_b wrote:

You are right that I should have attached the code in the first place, as you are unaware that I actually need both shift registers for the program to work. I will try to work out how to clear the feedback nodes another way.


I think @GerdW was not saying that you should remove your existing shift registers. Instead, I think @GerdW was saying that you should replace your two (2) feedback nodes with only one (1) shift register.

In case that doesn't make sense, I will explain further:

 

Spoiler

In LabVIEW, the function of a feedback node and a shift register are identical. In all cases*, they are so identical that you can right-click a Feedback Node and choose "Replace with Shift Register", and vice versa.

Since they're so similar, and since Shift Registers are often easier to read**, @GerdW is recommending you use one instead of any feedback node.

(*I'm inexperienced, so there may be an exception. But I think it's all cases.)
(**I am not going to go into the debate about this one... Both Shift Registers and Feedback Nodes have their merits, and everybody has a preference. You choose your preference, based on the application, and go from there.)

 

I've attached a quick example VI of what it might look like, and also included the snippet here:

 

Spoiler
SR_example_snippet_JoB.png

 

Does this help?

-joeorbob

 

P.S. If someone more experienced comes along and gives better examples, please use what they provide. I'm inexperienced and just doing my best.

Download All
Message 4 of 6
(1,761 Views)
Solution
Accepted by topic author clara_b

Hi Clara,

 

like this:

Now you can clear the data stored in the shift register whenever you like inside the state machine…

 

You really should clean up this block diagram:

  • Straight wires, left to right wiring (read the Style Guide in the LabVIEW help!)
  • Avoid local variables, like this "Current state" string indicator: no need to write to a local in each state when you can do the same before the case structure! (You don't even need to convert to string when the "Current state" would be an enum indictor!)
  • Typedefine all enums and clusters…
  • Simplify by using functions like "Is Empty String?" instead of comparing with empty string…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 5 of 6
(1,721 Views)

Joerbob, I was not aware of that. In the future I will post with older versions.

 

Thank you both so much for the help! The program now works as intended. 😄

0 Kudos
Message 6 of 6
(1,677 Views)