LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Boolean switching error

Solved!
Go to solution

Can someone explain why my control buttons do not switch when I run the vi.

The vi is to send bytes out the serial port each time a button is pressed, for some reason I can't get it to work.

I've had this working without using an event structure, but each time I press a control button, I get multiple commands sent.

I also had it working with just one control button using the event structure, but as soon as I put the rest of the control buttons in to it, they no longer appear to work.

 

0 Kudos
Message 1 of 5
(2,300 Views)

Your code has nothing to do with event based programming in LabVIEW. I suggest you to look into the design patterns in the Template Browser. You can open that by selecting FILE >> NEW.

You should take a close look into the design pattern called "User Interface Event Handler".

 

Here a list of things you have to change in your VI:

1. Don't use same names for different controls/indicators. This makes your code unreadable and can additionally lead to execution issues.

2. Remove the indicators and their value signaling property nodes. This messes up the whole thing you want to achieve.

3. Remove the case structure in which you placed the event structure.

4. Comparison between old and new value is Rube Goldberg. You configured for value CHANGE, not? So what's ALWAYS going to be different? Exactly: The value.

5. Keep the VISA resource handle in a shift register. Make it a rule to keep references and most often the error cluster in a shiftregister when working with loops.

6. Make the stop button part of the event structure by adding an appropriate case.

 

Norbert

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
0 Kudos
Message 2 of 5
(2,292 Views)
Solution
Accepted by topic author NewWorldMan

First of all, your buttons are set to switch until released, so you get two value changes, the release event will be queued up because of the case structure and will be the first to execute next time the case structure turns true. Never hide an evet structure inside a case structure!

 

In addition, you also fire all four events with signaling properties, Since you queue up four events (fired via signaling), but can only service one per iteration, you get an infinite buildup of events.

 

You are completely misunderstanding the singaling property. They are note needed at all.

 

Suggestions:

  1. Delete the FALSE case. If you still want to spin the outer loop at regular intevals, add a timeout event case to the event struture
  2. Delte all value(sgnl) property nodes and all the boolean gynmastics. Events directly react to user interactions.
  3. Make the buttons latch action
  4. remove all that garbage in the event cases and place the terminal of each boolean inside its event case so it properly resets.
  5. All each event case needs is the control and the desired output string (no cases, comparisons, etc.). If you want an indicator, that's fine too.
  6. ...
Message 3 of 5
(2,291 Views)

Clarification: I have just verified that the labels for controls and indicators are not identical (capitilize and spaces in front) but they are so similar that it is really hard to identify that the signaling property nodes as well as the event structure are bound to the indicators.

So remove the indicators and use the buttons as event source.

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 5
(2,286 Views)

Thank you guys for your help.

I see the error of my ways.

Everything is working just fine.

 

All I can say is Doh!!!!!

 

Who knows one day I may even be able to understand the basics.

Thanks

Again.

0 Kudos
Message 5 of 5
(2,273 Views)